Commit Graph
34 Commits
Author SHA1 Message Date
rsgowman aa0dba767e Merge pull request #747 from firebase/rsgowman/nanopb
Integrate nanopb
2018-02-06 14:39:26 -05:00
zxu a441190635 Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++

* temporary stash changes; blocking on the massive renaming of .m to .mm

* add database_info_test to project

* finish port DatabaseId and fix style, modular fixing DatabaseInfo

* port DatabaseInfo

* remove FSTDatabase{ID,Info} and their tests from project

* fix unit test

* use namespace alias

* use namespace alias, leftover

* address more changes

* refactoring to use raw pointer instead of value for property

* address changes

* remove self->

* fix style

* remove the name suffix Alloc

* fix a bug
2018-02-06 13:51:11 -05:00
Rich Gowman c896fab35f ./style.sh 2018-02-06 10:02:30 -05:00
Rich Gowman 3fcdf510ce Hook up nanopb to firestorep project
Use remote/serializer placeholder class as a hook for the test to ensure
nanopb headers can be found, and test can be linked.
2018-02-06 10:02:30 -05:00
Gil 515625c47f Remove predecessorKey,Object,Document, etc (#735)
This is dead code.

I think it was probably useful in the RTDB because of the way it notified of changes, but we give changes with indexes in Firestore so I think we don't need it.
2018-02-01 07:55:49 -08:00
Gil ac30522234 Start on ArraySortedMap in C++ (#721)
* Implement ArraySortedMap.remove
* Implement ArraySortedMap.insert
* Ensure ArraySortedMap.insert avoids copying on duplicates
* Port more ArraySortedMapTests
2018-01-31 14:28:20 -08:00
zxu 6474a82fd6 Firestore DatabaseId in C++ (#727)
* Implement DataBaseId in C++

* add database_id_test to project

* fix project

* address changes

* fix style
2018-01-29 15:55:01 -05:00
rsgowman 05ef5aea13 Add absl_strings to firebase_firestore_util_test dependencies (#725)
Required to link the test on rodete.
2018-01-29 12:10:25 -05:00
Gil 5a280ca1d6 Import iterator_adaptors from google3 (#718)
* Import iterator_adapters from google3

* Remove -Wconversion which is annoyingly hard to satisfy

* Strip dependency on absl_container from iterator_adapters_test

* Format and lint iterator_adaptors

* More flexible copyright checking in Travis
2018-01-29 08:38:32 -08:00
Gil 63a380ba33 Use fixed-sized types (#719)
Should have caught this during review, but cpplint caught it
2018-01-28 19:40:53 -05:00
rsgowman a74d39f02b Fix a number of c++ build errors (#715)
* Move -fvisibility-inlines-hidden from common_flags to cxx_flags

This option isn't supported by C (and causes the build to fail under
at least rodete).

Manifested error was:

```
-- Looking for include file openssl/rand.h
-- Looking for include file openssl/rand.h - not found
CMake Error at core/src/firebase/firestore/util/CMakeLists.txt:94 (message):
  No implementation for SecureRandom available.

-- Configuring incomplete, errors occurred!
```

which is completely misleading. :(

* Fix exception include for std::logic_error

Was causing compiler error on (at least) rodete.

(http://en.cppreference.com/w/cpp/error/logic_error suggests that
stdexcept is the correct header.)

* Remove 'const' from vector contents.

vectors cannot contain const objects as the contained objects are
required to be assignable and copy constructable. (Not *quite* strictly
true; since c++11, this requirement now depends on the operations
performed on the container. But my compiler objects at any rate.)

http://en.cppreference.com/w/cpp/container/vector

https://stackoverflow.com/questions/8685257/why-cant-you-put-a-const-object-into-a-stl-container

* Add brackets as suggested (required) by my compiler.

* Add missing include

For LLONG_MIN, etc.

* Enable gnu extension to c++11 for firestore/util *test*.

We disable them by default (in cmake/CompilerSetup.cmake) but our tests
requires hexidecimal floating point, which is not supported in c++11
(though is supported in C++17, gnu++11, and others).

http://en.cppreference.com/w/cpp/language/floating_literal
https://bugzilla.redhat.com/show_bug.cgi?id=1321986

* Fix printf format for uint64_t

http://en.cppreference.com/w/cpp/types/integer
https://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c

* Allow 0 length printf template strings in tests.

* Get rid of a multi line comment.

The backslash is apparently interpreted by the compiler cause the next
line to be ignored too. In this case, the next line is (currently) a
comment, and would be ignored anyways. (But that doesn't stop the
compiler from yelling.)

* Run ./scripts/style.sh
2018-01-27 16:16:41 -08:00
zxu af6976a907 normalize and port the rest of Firebase/Port code (#713)
* normalize bits
* normalize ordered_code
2018-01-27 14:53:27 -08:00
zxu 7226b4adf3 port TargetIdGenerator to iOS (#709)
* port TargetIdGenerator to iOS

* fix style

* move pointer property to instance variable

* TriggerTravis
2018-01-25 18:39:46 -05:00
zxu 821fb909a3 implement TargetIdGenerator in C++ for Firestore (#701)
* implement `TargetIdGenerator`

* address changes
2018-01-25 13:05:30 -05:00
zxu 5fdda3fa83 normalize string_util (#708)
* refactoring string_util
* port string_util to iOS
2018-01-25 13:03:07 -05:00
zxu bfa0e40795 Implement the rest of FieldValue types for C++ (#687)
* implement FieldValue for null and boolean.
* Implement number and string FieldValue.
* Implement object FieldValue.
* implement timestamp FieldValue.
* Implement number and string FieldValue.
* implement public type `Blob` and `GeoPoint`
* implement Blob FieldValue
* Implement GeoPoint FieldValue
* refactoring `Blob`
2018-01-25 09:14:19 -05:00
Gil cd0cbe94d0 Use Comparator in FieldValue. (#686) 2018-01-19 16:34:13 -05:00
Gil 39d8252300 Port comparison to C++ (#678)
This reimplements our comparison functions as C++ Comparators and then provides compatibility shims for interoperating with existing Objective-C usage.

A few specialized comparators aren't suitable for porting but only have a single usage (e.g. CompareBytes for comparing NSData * instances). In these cases I've moved them into the caller.

* Use int32_t for typeof(ID) in FSTDocumentReference

* Migrate callers of FSTComparison.h to Objective-C++

* Port comparison to C++

* Migrate usages of FSTComparison.h to C++ equivalents

* Remove FSTComparison
2018-01-19 12:27:11 -08:00
Gil 9f7c094f9f Add platform detection logic for SecureRandom (#676)
* Add CMake platform detection logic for SecureRandom

Now only builds secure_random_arc4random.cc if available.

Remove firebase/firestore/base/port.h. Nothing else was in that
directory.

* Add a SecureRandom implementation that uses OpenSSL

This is usable on Linux, Windows, and Android

* Properly check return from RAND_bytes
2018-01-19 12:20:46 -08:00
Gil b341356be1 Fix CMake build and lint warnings in field_value.cc (#677)
Fixes these cpplint warnings:

Firestore/core/src/firebase/firestore/model/field_value.cc:162:  Semicolon defining empty statement. Use {} instead.  [whitespace/semicolon] [5]
Firestore/core/src/firebase/firestore/model/field_value.cc:170:  Semicolon defining empty statement. Use {} instead.  [whitespace/semicolon] [5]
Firestore/core/src/firebase/firestore/model/field_value.cc:126:  Add #include <utility> for swap  [build/include_what_you_use] [4]
2018-01-17 13:47:18 -05:00
Gil 6a3379db62 Add a cc_library to the CMake build (#670)
* Rewrite cc_test to take named arguments

Cut down on build file verbosity by having cc_test take SOURCES and
DEPENDS. The separate invocation of target_link_libraries is no longer
necessary.

* Add a cc_library rule to parallel cc_test

This cuts down on build file verbosity.

* Automatically add OBJC_FLAGS to cc_libraries if applicable

* Exclude platform-specific libraries from 'all'

This is makes it possible to declare this kind of library
unconditionally. Usage within a test or as a dependency will actually
trigger building.

* Restore secure_random_test.cc; clean-up comments
2018-01-17 10:24:27 -08:00
zxu cac2c3ff7a implement FieldValue for null, boolean, and array in C++. (#637)
* implement FieldValue for null and boolean.

* refactoring to use union type instead of poly

* refactor using union design intead of poly

* refactoring to use anonymous union and fix styles

* small fix

* add field_value_test to the project

* fix warning of cmake and fix style
2018-01-17 13:18:54 -05:00
Gil 128e9cb170 Fix C++ lint errors (#668)
* Misc style.sh fixes

  * Allow test-only to use a revision; to check your changes since
    master:

    ./scripts/style.sh test-only master
  * Avoid diffing deleted files
  * 80 columns

* Fix C++ lint errors
2018-01-17 10:02:42 -08:00
Gil df71c9ad8c Enable warnings in the CMake build (#669)
* Enable warnings when building with GCC or clang

* Fix warnings
2018-01-16 13:17:27 -05:00
Gil b15283bd27 Build gRPC for Firestore C++ (#652)
* Clean up quoting and other minor issues

* Reorganize CMake build output

Make it clearer which parts of the output pertain to external projects.

* Use a consistent ordering of ExternalProject arguments

* Prevent the top-level build from running in parallel

This prevents spurious failures when running make -j.

* Actually parse arguments in the xcodebuild function

* Use ExternalProject features when available

  * submodule limits from CMake 3.0
  * shallow clones from CMake 3.6
  * git progress output from CMake 3.8

* Only build the parts of leveldb we need

Skip building the tools and other libraries

* Avoid installing ExternalProjects

Consume build output directly so that we can build just the targets we
need. Installing causes all targets to be built.

This doesn't matter as much for these targets but the gRPC build
includes a ton of stuff we don't need so it's worth adopting this as a
general strategy.

* Define an external build for grpc

* Test that grpc can link successfully.

* Add a FindGRPC CMake module

* Actually comment ExternalProjext_GitSource
2018-01-13 15:21:01 -08:00
Michael Lehenbauer dc0b29e9cf Run style.sh (#636)
Run style.sh (w/ clang-format version 6)
2018-01-10 09:28:44 -08:00
zxu 64d1e6bbc4 implement C++ assert (stdio, apple) (#612)
* implement C++ assert (stdio, apple)

* Update tests for firebase_firestore_util renames

* renaming `assert.h` to `firebase_assert.h`

* refactoring to a common `WrapNSStringNoCopy()`
2018-01-08 17:48:28 -08:00
Gil 0f6103e404 Port StringPrintf from //base (#624)
* Port StringPrintf from //base.

  Prefer this to approaches based on variadic templates. While the variadic
  template mechanisms are strictly safer, they result in binary bloat we
  can't afford.

  This is essentially the same StringPrintf previously open sourced as a
  part of protobuf, though updated for C++11 which saves a copy and a
  temporary buffer on the heap.

* Add abseil as a subdirectory of Firestore

  This saves having to redefine all the libraries that abseil defines as
  imported libraries.

* Rename firebase_firesture_util_log_* targets

  Cut the log out of the name to reflect that these will get more
  components besides just logging.
2018-01-08 08:57:36 -08:00
Gil 5a6155f6a3 Build and test both C++ loggers where possible (#595)
* Rename FIREBASE_BINARY_DIR to FIREBASE_INSTALL_DIR

  Make this consistent with the outer superbuild and also make the
  association with CMAKE_INSTALL_PREFIX more obvious.

* Build and test log_stdio separate from the rest of util

  This is in preparation for adding a test for log_apple

* Build and test log_apple under CMake

  Also add notes about how FIRLogger's debug mode can break this test

* Refactor log_apple to cut down duplicate switch statements

  There's also a slight reduction in final binary size.
2018-01-03 07:00:54 -08:00
Gil 13da48d8a4 Build FirebaseCore from CMake (#594)
* Don't bother specifying a download directory to CMake ExternalProject
* Teach CMake to build pure Xcode projects as dependencies

  This allows downstream code (like log_apple.mm) to consume this for
  testing within the CMake build without requiring a CMake-native build
  for these components.

  This makes integrating these components into the cmake build essentially
  free from the point of view of the consumed component.

* Get the CMake build semi-working on Linux again

  Many prebuilt versions of cmake on Linux lack the ability to download
  over https so use git to get googletest.

  Don't attempt to build FirebaseCore on Linux; there's no xcodebuild.

  Note the build is still ultimately broken because we don't yet have an
  alternative to arc4random on Linux but at least this is no more broken
  than it was before.
2018-01-01 21:00:32 -08:00
zxu 3ff3f9f003 implement C++ logger (#575)
* implement logger, apple impl and other impl, with test.

* some minor fixes

*   re-organize cmake build rules;
*   fix bugs in log_apple.mm;

* style fix by style.sh

* Complete removal of LogAssert
2017-12-20 13:32:57 -05:00
Gil ea3369c192 Use angle brackets for nonlocal #includes in Firestore (#580) 2017-12-19 07:44:28 -08:00
Gil 32bdc38400 Rework the top-level cmake build to be a superproject (#538)
All projects are now ExternalProjects

This makes it much easier to build them all in a single pass.
2017-12-06 16:10:59 -08:00
Gil 530437ea7a Move sources into firebase::firestore and internal namespaces (#494)
* Move sources into firebase::firestore and internal namespaces

Combine support and core/util packages; this distinction wasn't really
paying its freight.
2017-11-30 12:26:16 -08:00