Commit Graph
81 Commits
Author SHA1 Message Date
Konstantin Varlamov dbca369b0e Fix CMake build with Clang 10 (#3972)
The as-of-yet-unreleased Clang 10 adds some new warnings which make the CMake build fail (due to `-Werror`):
* BoringSSL build now fails because some of its C code contains fallthroughs in switch statements that aren't properly annotated. This wasn't an issue before because previous versions of Clang ignored `-Wimplicit-fallthrough` in C mode;
* serializer test contains an expression that produces the following warning:
```
/src/firebase-ios-sdk/Firestore/core/test/firebase/firestore/remote/serializer_test.cc:446:29:
error: implicit conversion from 'std::__1::numeric_limits<long>::type' (aka 'long') to 'double'
changes value from 9223372036854775807 to 9223372036854775808 [-Werror,
-Wimplicit-int-float-conversion]
```

Fixes:
* upgrade the version of BoringSSL used to the latest master. There's no particular reason to choose this commit, other than it happens to be the latest. The actual fixes we need are [this](https://github.com/google/boringssl/commit/05cd93068b0a553afc48f69acbceae10c6a17593) and [this](https://github.com/google/boringssl/commit/fbebe833b180a1a0685803c59bba38916826dd2b);
* apply `static_cast` to the serializer test. Also, because the cast produces a different value, add a couple of additional values to test.

The breakage was discovered thanks to the fuzz build (which already uses Clang 10 from trunk).
2019-10-01 20:48:56 -04:00
Gil 75a8356c98 Upgrade GoogleTest to 1.8.1 (#3898)
This gives access to testing::ScopedTrace, which was previously
internal.
2019-09-26 11:41:47 -07:00
Gil 266a025421 Enable LevelDB on Windows under CMake (#3503)
* Update leveldb to 1.22

This adds Windows support (which was added to LevelDB in 1.21).

* Make use of LevelDB unconditional
2019-08-07 17:19:11 -07:00
Gil 49387ec9c5 Fix build under Linux/GCC Windows/MSVC (#3502)
* Avoid unconditionally setting C++ flags

These were already handled via CMAKE_C_FLAGS and CMAKE_CXX_FLAGS and
this breaks when compiling plain C under GCC, which considers unknown
options an error when compiling with -Werror.

* Fix compilation in Linux/GCC and also Windows/MSVC

GCC and MSVC aren't happy about `using Query = testutil::Query;` when
there's already `class Query` in scope.

* Fix objc_class.h in Windows

* Fix warnings that have crept in on Windows
2019-08-05 20:31:01 -07:00
Gil 766e8723d7 Rework CMake builds of Firebase Frameworks (#3499)
* Add sed scripts that find the versions of podspecs

... without fully loading those via Pod::Spec, which is slow.

* Avoid compiling with different visibility settings

... in different translation units. This removes warnings about linking
googletest causing weak symbols becoming strong.

* Add CMake objc_framework

* Define FirebaseCore via objc_framework

* Define FIRCoreDiagnosticsInterop via objc_framework

* Define GoogleUtilities with objc_framework

* Define FirebaseCoreDiagnosticsInterop via objc_framework

* Define FirebaseAuthInterop via objc_framework

* Don't duplicate Core's dependency information everywhere

* Remove podspec_framework

* Fix compilation error with -Wstrict-prototyes
2019-08-05 16:46:28 -07:00
Gil ec11035d1c Work around duplicate nanopb symbols in gRPC build (#3269)
gRPC packages 0.3.7-dev from 2016 in its own third_party directory and
builds it into libraries produced by CMake. Firestore depends on 0.3.9.2
via external dependency.

Firestore checks in its nanopb-generated sources for compatibility with
CocoaPods, where running the generator at build time on remote users'
machines is perilous. This means that Firestore's generated code must
match the version of nanopb available in CocoaPods.

Unfortunately, generated code from 0.3.7-dev and 0.3.9.2 are not
compatible with each other so we can't just downgrade the Firestore
CMake build to match gRPC and use its copy.

This change excludes gRPC's copy of nanopb until we get this fixed
upstream.
2019-06-26 20:05:56 -07:00
Gil afc71a4e84 CMake fixes for GoogleDataTransport (#3268)
* Fix a few things that should have been splatted but weren't

* Define PODS_TARGET_SRCROOT in CMake for compatibility with CocoaPods

* Compile pods we depend upon with looser settings

* Rename the nanopb dependency to match what CMake actually has

* Make #include <nanopb/pb.h> work

Remove the old way of #include <pb.h> once we change the Firestore
nanopb generator to match.
2019-06-26 17:30:44 -07:00
Gil 9892903266 Prep for FIRTimestampValue migration to C++ (#3155)
* Clean up GeoPoint port to C++

... based on things learned porting Timestamps.

There's no good way to include conversions equivalent to toGeoPoint in
FIRTimestamp, so pull out separate conversion functions that match other
similar things.

* Extract MakeTimePoint into time_testing.h

... for reuse elsewhere

* Add TimestampInternal Hash/Truncate

* Use a method similar to NSDate to get current time on apple platforms
2019-06-11 09:03:01 -07:00
Gil e2630d5b38 Fix builds with GCC/Linux (#3141)
* Remove _Nullable in plain C++
  * Avoid adding -framework Foundation multiplatform targets on
    non-Apple platforms
  * Fix ordered_code_benchmark to be in a .cc file
2019-06-05 07:19:43 -07:00
Gil 53d3ca199a CMake: Upgrade nanopb to 0.3.9.2 (#2985)
* Update nanopb to 0.3.9.2

This matches google3, even though 0.3.9.3 is out

* Regenerate protos with nanopb 0.3.9.2
2019-05-13 08:24:54 -07:00
Gil eb6ee49b54 CMake fixes (#2966)
* cc_binaries should not be tests

This will keep more involved benchmarks from extending test time
unreasonably.

* Fix target_link_libraries conformance with CMP0023

Avoid mixing keyword and non-keyword forms of target_link_libraries.

* Set target_include_directories to PRIVATE for cc_binary and cc_test

* Set add_sources to private

Fixes a warning about policy CMP0076, which wants to make sources
relative if they're public.

* Enable @rpath by default

This silences warnings about policy CMP0042, which we don't care much
about since we don't have install targets.

* Disable griping about undeclared byproducts

... when using the Ninja generator. In our case the undeclared outputs
come from dependencies and we'd need to fix them before we can adopt the
new policy here.
2019-05-08 09:09:04 -07:00
Gil 9f93a53347 When expanding all subspecs, exclude test specs (#2949)
Fixes CMake build broken by #2943.
2019-05-06 17:58:21 -07:00
Gil ff8032ada0 Move the util::objc namespace to just objc (#2865)
* Move the util::objc namespace to just objc

This removes all the namespace objc = firebase::firestore::util::objc
gunk to make it seem as if this was really the arrangement.

This is motivated by wanting to put additional things in this namespace
and use them in headers without having to use util::objc::Foo

* Add CMake support for header-only cc_library targets

* Have the linter allow #include <objc/objc.h>, a C header
2019-04-19 10:02:21 -07:00
Gil e4dcc96e52 Eliminate Objective-C BOOL in Firestore/core (#2574)
* Add objc::EqualTo and objc::Hash

These make it possible to use std::unordered_map with Objective-C object
keys.

* Use std::unordered_map in MemoryQueryCache

* Fix objective-C library detection

This ensures that .mm files are compiled with -fobjc-arc (among other
things).

* Remove BOOL in FSTDocument to eliminate static_cast<bool>
2019-03-18 17:28:46 -07:00
Konstantin Varlamov 8b1efabd82 gRPC: replace Objective-C implementation with the new C++ implementation (#2068)
* Revert "Revert "gRPC: replace Objective-C implementation with the new C++ implementation (#1968)" (#2030)"

This reverts commit ea567dca47.

* gRPC: fix bugs found during testing (#2039)

All in `GrpcStream`:
* make sure there are no pending completions when "finish" operation is enqueued;
* always finish gRPC calls;
* when connectivity changes, reset not just the calls, but the underlying channel as well.

* Revert "Partially revert "Update CHANGELOG for Firestore v0.14.0 (#2025)" (#2031)"

This reverts commit b2437b80f6.

* Update changelog for v0.15.0.

* gRPC: add gRPC wrapper classes to CMake build (#2015)

* add a C++ equivalent of `FIRFirestoreVersionString`. This eliminates the only Objective-C dependency of `grpc_connection.mm` and allows making it a pure C++ file;
* open-source `binary_to_array.py` script and use it in the build to embed `roots.pem` certificate file from gRPC into the Firestore binary. The embedded char array is then used to load certificate at runtime.

* Revert local change -- do not enable sanitizers by default
2018-11-13 11:51:06 -08:00
rsgowman ae6c85759d Move -Wreorder to cxxflag (instead of common, which impacts cflags) (#1881)
-Wreorder is not a valid cflag on at least linux/gcc.
2018-09-26 23:00:04 -04:00
Greg Soltis b11aab6441 Enforce field initialization order (#1873)
Add -Wreorder flag, make it an error, and fix the errors

This is enforced via CI in some cases, so make it enforced in all of Firestore.
2018-09-26 10:45:57 -07:00
Konstantin Varlamov 4fdd8e6d6c C++: slightly refactor Datastore and GrpcConnection (#1817)
Several minor changes related to `Datastore`:
* `WatchStream` and `WriteStream` now use `GrpcConnection` instead of `Datastore` to create the underlying `GrpcStream`. This is in line with consolidating management of gRPC objects into `GrpcConnection` and removes dependence of streams on `Datastore`;
* Add `CreateWatchStream`/`CreateWriteStream` functions to `Datastore`;
* For functions creating gRPC wrappers (`GrpcStream`), pass token as `auth::Token` instead of `string_view`. This prevents confusing the argument order between the token and the RPC name, and allows moving the logic for retrieving a token for an unauthenticated user into `GrpcConnection`.
* Most significantly, move conversion from `grpc::Status` to `util::Status` from `Datastore` into the `util::Status` class itself. The main motivation is to avoid any dependence of `GrpcStream`, a pure C++ class, on `Datastore`, an Objective-C++ class. The downside is diverging from `FSTDatastore`. I think it's fine, because a) other platforms don't have an equivalent of `Datastore::ConvertStatus`; b) this is in line with how Windows/Apple Foundation/POSIX errors are handled by `util::Status` already;
* in CMake build, bump the used version of gRPC to 1.14.2. This is to be able to include gRPC headers using `grpcpp` path, not deprecated `grpc++`.
2018-09-19 22:19:15 -04:00
rsgowman bb045a5b90 Create process to build proto sources (#1704)
* Rename nanopb/.../*.pb.c to nanopb/.../*.nanopb.c

This ensures that all generated nanopb files use the same (sub)
extension of nanopb. This matches up with nanopb's --extension
parameter (which will be enabled later in this PR.)

* Remove references to NANOPB_PROTOC_BIN

Which wasn't being used, and wasn't pointing to a valid protoc.

* Add ability to generate protos from cmake build.

Currently, it's an entirely manual process via 'generate_protos' target.
This target is not automatically run during a build.

See Firestore/Protos/build-protos.sh for expected usage.

* cleanup/update license in build-protos.sh

* Build grpc proto sources (objc only)

* Use 32bit nanopb fields (instead of 16)

To match xcode build, but also to allow google/api/annotations.proto to
compile. (A recent change to nanopb now enforces this.) This isn't
strictly necessary, since we don't make use of that proto, so we
could've simply removed it instead (and in fact, the objc protos do
exactly that) but matching the xcode build certainly seems worthwhile.

* Rebuild all proto sources

* Skip whitespace checks on protoc generated files
2018-09-04 12:26:28 -04:00
Gil 5a707ab44e Update CMake build instructions (#1730)
* Use bundler only when .bundle exists

This makes the build compatible with Travis which needs bundler and
local installs of cocoapods.

* Update gitignore

* Update CMake instructions
2018-08-23 09:14:14 -07:00
Gil 7bdcd93dfb Fix benchmark builds on non-Apple platforms (#1677) 2018-08-13 12:57:23 -07:00
Gil b5c4e0706c Add Google Benchmark to the CMake build (#1670) 2018-08-13 07:13:26 -07:00
Gil 162a14d9b6 Add a cc_binary CMake rule (#1671) 2018-08-09 18:22:47 -07:00
Mina Farid 67fce1d276 Add cc_fuzz_test build rule (#1655)
* Created `cc_fuzz_test` build rule that automatically:
  - Searches for `Fuzzer` package (libFuzzer or whatever is provided by
    OSS Fuzz).
  - Adds dependency of `Fuzzer`.
  - Copies the dictionary file and corpus directory to the target binary
    destination directory with the appropriate name.
* Modified fuzzing targets to use `cc_fuzz_test` rule.
2018-08-08 15:07:20 -04:00
Mina Farid af0e5fca4c OSS Fuzz CMake changes (#1611)
* Detect OSS Fuzz thorough `LIB_FUZZING_ENGINE` env var.
* Avoid building libFuzzer if not fuzzing.
* Load the fuzzing library either from the library provided by OSS Fuzz or from libFuzzer.a that was manually built from sources.
2018-08-01 16:30:15 -04:00
Gil ca7f161fb8 Simplify/normlaize CMake platform libraries (#1605)
* Remove no-longer relevant comment

Nanopb headers now have distinct names so search order no longer
matters.

* cc_* rules now automatically filter out objc sources

* Combine executor and async queue into a single library

* Add cc_select

Adds a mechanism similar to blaze/bazel's select() for choosing an
implementation of a library.

This also makes the platform-neutral generic name for the library a
proper CMake library, which removes the need to keep libraries in
dependency order within CMakeLists.txt.

* Alphabetize rules
2018-07-31 17:14:32 -07:00
Mina Farid 8766e5dda7 Fuzz Testing Firestore using CMake (#1593)
* Added `cc_binary` rule to allow executables.
* Added `libFuzzer` as an external project that Firestore depends on.
  * LibFuzzer is checked out from its SVN repository.
  * LibFuzzer is built using its `build.sh` script to produce the library `libFuzzer.a`.
  * Added a `FindLibFuzzer.cmake` script that looks for `libFuzzer.a`.
* Added a new cmake option `FUZZING` to enable fuzzing and adding the appropriate compiler flags.
  * Added `fuzzing_options.cmake` rules to check for compiler type and add the fuzzing flags accordingly.
* Added a `firebase_firestore_fuzzing_serializer` target that depends on `libFuzzer` and `firebase_firestore_remote` to fuzz test the serializer.
2018-07-30 15:53:42 -04:00
Gil 6aaf6e6fd0 Add initial support for non-UTF-8 compilation and filenames (#1599)
* Add UTF-8 to wide character conversions for Windows pathnames.

* Explicitly mark UTF-8 string literals

Without this, string literals are encoded in the host's encoding, which
can be anything including CP-1252 on Windows, which will generate
invalid UTF-8 data when fed through our serializer.
2018-07-28 10:13:48 -07:00
Gil 1be2405ee9 Add CMake support for building under Visual Studio 2017 (#1588)
* Add compiler flags for MSVC on VS2017

* Force gtest to use the dynamic runtime on Windows.

* Avoid setting flags that MSVC does not understand

* Add compiler_id: cheap shortcuts for conditional features on a compiler

* Fix googletest build under VS2017

* Force disable Abseil's tests, which don't compile under VS2017.

* Make Firestore CMake a self-contained build

Now shell out to a sub-CMake to prepare depenencies without needing an
explciit superbuild structure. This makes the Visual Studio and CLion
projects driven from the CMake configuration actually usable.

* Make LevelDB an optional dependency.

* Move third-party dependencies to the top-level
2018-07-26 18:09:53 -07:00
Gil 579f76ce43 Make Firestore CMake a self-contained build (#1587)
* Make Firestore CMake a self-contained build

Now shell out to a sub-CMake to prepare depenencies without needing an
explciit superbuild structure. This makes the Visual Studio and CLion
projects driven from the CMake configuration actually usable.

* Move third-party dependencies to the top-level
2018-07-26 09:44:03 -07:00
Marek Gilbert e6bff30844 Adjust include order
This prevents build failures when the CMake build picks up the
CocoaPods-generated config.h
2018-07-25 12:12:32 -07:00
Marek Gilbert fabcbfe37d Use add_external_subdirectory to cut down on noise 2018-07-16 15:09:06 -07:00
Marek Gilbert 0d7e2b8922 Rename CMake modules filenames to snake_case.
* SanitizerOptions to sanitizer_options
  * CompilerSetup to compiler_setup
2018-07-16 15:09:06 -07:00
Marek Gilbert c739f9d356 Add color output to ninja builds 2018-07-16 15:09:06 -07:00
Marek Gilbert 95696e16dc Remove add_include_directories from the top-level build 2018-07-16 15:09:06 -07:00
Gil e9b56959f1 Use CMake to build LevelDB (#1542) 2018-07-16 14:55:30 -07:00
Gil f6a53e1faf Get cocaopods from bundler (#1544) 2018-07-16 14:37:40 -07:00
Gil c7fb0a4875 Generate CMake frameworks from podspecs (#1531)
* Rename utils.cmake to cc_rules.cmake

This makes it less of a dumping ground

* Fix sign mismatch in FIRApp

* Implement a podspec_framework CMake function

... that generates a CMake framework library target from a podspec.

* Remove manual CMake scripts for xcodebuild
2018-07-16 11:46:55 -07:00
Gil cda87fa3af Convert grpc and protobuf CMake builds to add_subdirectory (#1537)
* Build zlib with grpc's add_subdirectory

* Build grpc and its children with add_subdirectory.

* Build c-ares with grpc's add_subdirectory

* Convert protobuf to a download-only ExternalProject

* Temporarily break protobuf within grpc

This works because libgrpc has no actual dependency on protobuf

* Update boringssl to master@{2018-07-10}
2018-07-16 08:50:53 -07:00
Gil fb9f24eaee Convert googletest and nanopb CMake builds to add_subdirectory (#1522)
* Add a download-only boringssl ExternalProject

Match boringssl version to grpc submodule version

Note: not yet in use

* Split grpc into separate download and build tasks

This allows other external targets to download into the gRPC source tree
before grpc is actually built.

* Convert grpc to an http download

* Build googletest with add_subdirectory

Also:
  * Revert library-name modifications in the abseil-cpp build
  * Move abseil-cpp add_subdirectory build into place

* Build nanopb with add_subdirectory

* Force nanopb first to work around ODR violations

This is a temporary work-around for b/111328563.
2018-07-13 11:09:44 -07:00
Gil 49f2493e14 Convert the gRPC external build to use an HTTP download (#1520)
* Add a download-only boringssl ExternalProject

Match boringssl version to grpc submodule version

* Split grpc into separate download and build tasks

This allows other external targets to download into the gRPC source tree
before grpc is actually built.

* Convert grpc to an http download
2018-07-11 19:32:24 -07:00
Gil 7fc953fc6f Firestore CMake cleanup (#1510)
* Pull out sanitizer options into a separate file

* Reorder packages

* Remove the extra "external/$target" directory from PREFIX

Instead of BINARY_DIR/external/foo/src/foo the contents will be in
BINARY_DIR/src/foo.

* Make libprotobuf-nanopb targets line up with nanopb's CMakeLists.txt

* Fix CMake style
2018-07-11 15:55:36 -07:00
Gil 50cbfab391 Reorganize cmake dependencies (#1508)
* Add cmake dependencies where required

... instead of relying on a topological sort in the top-level
CMakeLists.txt.

* Add early exits to external project builds
2018-07-10 07:57:54 -07:00
Paul Beusterien 98b6eef71e Split GoogleUtilities from FirebaseCore (#1370) 2018-07-06 09:37:23 -07:00
Gil b8eb4e0449 Add a CMake external build for c-ares (#1472)
* Add an external build for c-ares

* Use installed c-ares package configuration

* Adjust protobuf configuration to use the standard Protobuf_DIR variable.

* Have grpc depend on c-ares

* Drop UPDATE_COMMAND where it doesn't matter
2018-06-28 14:03:52 -07:00
Gil bb9fd3136b Add an external build for zlib (#1473) 2018-06-28 11:28:43 -07:00
Gil 3722deff12 Install protobuf during CMake build (#1460)
* Install protobuf

  * Use the built-in FindProtobuf.cmake
  * Add additional build configuration flags
  * Preserve generator configuration in the protobuf sub-build

    Without this, the build fails on Win64 because the default
    configuration builds a Win32 libprotobuf and the Win64 build rejects
    it.
  * Wire the installed protobuf into the gRPC build.

* Install nanopb
2018-06-26 15:05:28 -07:00
Gil d03050653f Install googletest (#1461)
Also add FindGMock to Find gmock after installation
2018-06-26 14:57:40 -07:00
Gil ae7078ca2b Install FirebaseCore during CMake build (#1462) 2018-06-26 13:43:21 -07:00
Gil 2810a09c58 Prepare for installed sub-projects (#1459)
* Ignore vim backup files

* Prepare for installed subprojects

This adds FIREBASE_BINARY_DIR to point to the out-of-source build
directory (which previously was passed around as FIREBASE_INSTALL_DIR).

This repurposes FIREBASE_INSTALL_DIR to point to
${FIREBASE_BINARY_DIR}/opt, and installation root for subprojects that
have an install step.

* Allow download directory to be specified
2018-06-26 11:58:10 -07:00