Skip to content

Commit d0fc238

Browse files
committed
Merge remote-tracking branch 'origin/master' into ghm
2 parents ab5ecec + 21bafe8 commit d0fc238

File tree

71 files changed

+791
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+791
-132
lines changed

Android/firebase_dependencies.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def firebaseDependenciesMap = [
2323
'auth' : ['com.google.firebase:firebase-auth:19.2.0'],
2424
'database' : ['com.google.firebase:firebase-database:19.2.1'],
2525
'dynamic_links' : ['com.google.firebase:firebase-dynamic-links:19.1.0'],
26+
'firestore' : ['com.google.firebase:firebase-firestore:21.4.0'],
2627
'functions' : ['com.google.firebase:firebase-functions:19.0.2'],
2728
'instance_id' : ['com.google.firebase:firebase-iid:20.0.2'],
2829
'invites' : ['com.google.firebase:firebase-invites:17.0.0'],
@@ -42,6 +43,7 @@ def firebaseResourceDependenciesMap = [
4243
'admob' : [':admob:admob_resources'],
4344
'auth' : [':auth:auth_resources'],
4445
'database' : [':database:database_resources'],
46+
'firestore' : [':firestore:firestore_resources'],
4547
'storage' : [':storage:storage_resources']
4648
]
4749

@@ -74,6 +76,9 @@ class Dependencies {
7476
def getDynamicLinks() {
7577
libSet.add('dynamic_links')
7678
}
79+
def getFirestore() {
80+
libSet.add('firestore')
81+
}
7782
def getFunctions() {
7883
libSet.add('functions')
7984
}

CMakeLists.txt

Lines changed: 115 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,52 @@ set (CMAKE_CXX_STANDARD 11)
2020
# Turn on virtual folders for visual studio
2121
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
2222

23+
# Top level option that determines the default behavior of the include options
24+
# below. Useful for turning off all at once, and then turning on a specific one.
25+
option(FIREBASE_INCLUDE_LIBRARY_DEFAULT
26+
"Should each library be included by default." ON)
2327
# Different options to enable/disable each library being included during
2428
# configuration.
25-
option(FIREBASE_INCLUDE_ADMOB "Include the AdMob library." ON)
29+
option(FIREBASE_INCLUDE_ADMOB "Include the AdMob library."
30+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
2631
option(FIREBASE_INCLUDE_ANALYTICS
27-
"Include the Google Analytics for Firebase library." ON)
28-
option(FIREBASE_INCLUDE_AUTH "Include the Firebase Authentication library." ON)
32+
"Include the Google Analytics for Firebase library."
33+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
34+
option(FIREBASE_INCLUDE_AUTH "Include the Firebase Authentication library."
35+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
2936
option(FIREBASE_INCLUDE_DATABASE
30-
"Include the Firebase Realtime Database library." ON)
37+
"Include the Firebase Realtime Database library."
38+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
3139
option(FIREBASE_INCLUDE_DYNAMIC_LINKS
32-
"Include the Firebase Dynamic Links library." ON)
40+
"Include the Firebase Dynamic Links library."
41+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
42+
option(FIREBASE_INCLUDE_FIRESTORE
43+
"Include the Cloud Firestore library."
44+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
3345
option(FIREBASE_INCLUDE_FUNCTIONS
34-
"Include the Cloud Functions for Firebase library." ON)
46+
"Include the Cloud Functions for Firebase library."
47+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
3548
option(FIREBASE_INCLUDE_INSTANCE_ID
36-
"Include the Firebase Instance ID library." ON)
49+
"Include the Firebase Instance ID library."
50+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
3751
option(FIREBASE_INCLUDE_MESSAGING
38-
"Include the Firebase Cloud Messaging library." ON)
52+
"Include the Firebase Cloud Messaging library."
53+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
3954
option(FIREBASE_INCLUDE_REMOTE_CONFIG
40-
"Include the Firebase Remote Config library." ON)
55+
"Include the Firebase Remote Config library."
56+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
4157
option(FIREBASE_INCLUDE_STORAGE
42-
"Include the Cloud Storage for Firebase library." ON)
58+
"Include the Cloud Storage for Firebase library."
59+
${FIREBASE_INCLUDE_LIBRARY_DEFAULT})
60+
4361
option(FIREBASE_CPP_BUILD_TESTS
4462
"Enable the Firebase C++ Build Tests." OFF)
4563
option(FIREBASE_FORCE_FAKE_SECURE_STORAGE
4664
"Disable use of platform secret store and use fake impl." OFF)
4765
option(FIREBASE_CPP_BUILD_PACKAGE
4866
"Bundle the Firebase C++ libraries into a zip file." OFF)
67+
option(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD
68+
"When building with Gradle, use the previously built libraries." OFF)
4969

5070
# Define this directory to be the root of the C++ SDK, which the libraries can
5171
# then refer to.
@@ -94,10 +114,37 @@ set(FIREBASE_BINARY_DIR ${PROJECT_BINARY_DIR})
94114
set(FIREBASE_INSTALL_DIR ${PROJECT_BINARY_DIR}/opt)
95115
set(FIREBASE_DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads)
96116

97-
# Run the CMake build logic that will download all the external dependencies.
98-
message(STATUS "Downloading external project dependencies...")
99-
download_external_sources()
100-
message(STATUS "Download complete.")
117+
if(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
118+
# Figure out where app's binary_dir was.
119+
string(REGEX REPLACE
120+
"${CMAKE_CURRENT_LIST_DIR}/[^/]+/(.*)"
121+
"${CMAKE_CURRENT_LIST_DIR}/app/\\1"
122+
APP_BINARY_DIR "${FIREBASE_BINARY_DIR}")
123+
124+
set(FIRESTORE_SOURCE_DIR ${APP_BINARY_DIR}/external/src/firestore)
125+
else()
126+
# Run the CMake build logic that will download all the external dependencies.
127+
message(STATUS "Downloading external project dependencies...")
128+
download_external_sources()
129+
message(STATUS "Download complete.")
130+
131+
set(FIRESTORE_SOURCE_DIR ${FIREBASE_BINARY_DIR}/external/src/firestore)
132+
endif()
133+
134+
# Include Firestore's external build early to resolve conflicts on packages.
135+
if(NOT ANDROID AND FIREBASE_INCLUDE_FIRESTORE)
136+
set(FIRESTORE_BINARY_DIR ${FIRESTORE_SOURCE_DIR}-build)
137+
138+
set(
139+
FIREBASE_IOS_BUILD_TESTS
140+
${FIREBASE_CPP_BUILD_TESTS}
141+
CACHE BOOL "Force Firestore build tests to match"
142+
)
143+
144+
add_subdirectory(${FIRESTORE_SOURCE_DIR} ${FIRESTORE_BINARY_DIR})
145+
146+
copy_subdirectory_definition(${FIRESTORE_SOURCE_DIR} NANOPB_SOURCE_DIR)
147+
endif()
101148

102149
# Disable the Flatbuffer build tests, install and flathash
103150
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
@@ -109,13 +156,17 @@ if(IOS OR ANDROID)
109156
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "")
110157
endif()
111158

112-
# Add flatbuffers as a subdirectory, and set the directory variables for it,
113-
# so that the sub Firebase projects can depend upon it if necessary.
114-
add_external_library(flatbuffers)
159+
if(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
160+
message(STATUS "flatbuffers is added with APP_BINARY_DIR ${APP_BINARY_DIR}")
161+
add_external_library(flatbuffers BINARY_DIR "${APP_BINARY_DIR}")
162+
else()
163+
message(STATUS "flatbuffers is added normally")
164+
add_external_library(flatbuffers)
165+
endif()
115166

116-
if(FIREBASE_CPP_BUILD_TESTS)
167+
if(FIREBASE_CPP_BUILD_TESTS AND NOT FIREBASE_INCLUDE_FIRESTORE)
168+
# Firestore's external build pulls in googletest
117169
add_external_library(googletest)
118-
add_external_library(absl)
119170
endif()
120171

121172
# Some of the external libraries are not used for mobile.
@@ -202,15 +253,31 @@ if (NOT ANDROID AND NOT IOS)
202253
zlibstatic
203254
)
204255
endif()
256+
endif()
205257

206-
find_package(Protobuf)
207-
if (PROTOBUF_FOUND)
208-
# NanoPB requires Protobuf to be present, so only add it if it was found.
209-
add_external_library(nanopb)
210-
# NanoPB has a FindNanopb which defines the function to generate files, so
211-
# add it to the module path, and use that.
212-
list(INSERT CMAKE_MODULE_PATH 0 ${NANOPB_SOURCE_DIR}/extra)
213-
find_package(Nanopb)
258+
if(NOT ANDROID)
259+
if(FIREBASE_INCLUDE_FIRESTORE)
260+
# The Firestore build includes protobuf and nanopb already
261+
list(APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR}/extra)
262+
find_package(Nanopb REQUIRED)
263+
264+
set(PROTOBUF_FOUND ON)
265+
else()
266+
find_package(Protobuf)
267+
if (PROTOBUF_FOUND)
268+
# NanoPB requires Protobuf to be present, so only add it if it was found.
269+
add_external_library(nanopb)
270+
271+
# NanoPB has a FindNanopb which defines the function to generate files,
272+
# so add it to the module path, and use that.
273+
list(APPEND CMAKE_MODULE_PATH ${NANOPB_SOURCE_DIR}/extra)
274+
find_package(Nanopb)
275+
276+
target_compile_definitions(
277+
protobuf-nanopb-static
278+
PUBLIC -DPB_FIELD_32BIT -DPB_ENABLE_MALLOC
279+
)
280+
endif()
214281
endif()
215282
endif()
216283

@@ -290,8 +357,24 @@ if(FIREBASE_CPP_BUILD_TESTS)
290357
add_subdirectory(testing)
291358
endif()
292359

293-
# App needs to come first, since other libraries will depend upon it.
294-
add_subdirectory(app)
360+
if(NOT FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
361+
add_subdirectory(app)
362+
else()
363+
# Add firebase_app as a target on the previously built app.
364+
add_library(firebase_app STATIC IMPORTED GLOBAL)
365+
file(MAKE_DIRECTORY "${APP_BINARY_DIR}/generated")
366+
file(MAKE_DIRECTORY "${FIREBASE_BINARY_DIR}/generated")
367+
set(app_include_dirs
368+
"${CMAKE_CURRENT_LIST_DIR}/app/src/include"
369+
"${APP_BINARY_DIR}/generated"
370+
"${FIREBASE_BINARY_DIR}/generated"
371+
)
372+
set_target_properties(firebase_app PROPERTIES
373+
IMPORTED_LOCATION "${APP_BINARY_DIR}/libfirebase_app.a"
374+
INTERFACE_INCLUDE_DIRECTORIES "${app_include_dirs}"
375+
)
376+
endif()
377+
295378
if (FIREBASE_INCLUDE_ADMOB)
296379
add_subdirectory(admob)
297380
endif()
@@ -307,6 +390,9 @@ endif()
307390
if (FIREBASE_INCLUDE_DYNAMIC_LINKS)
308391
add_subdirectory(dynamic_links)
309392
endif()
393+
if (FIREBASE_INCLUDE_FIRESTORE)
394+
add_subdirectory(firestore)
395+
endif()
310396
if (FIREBASE_INCLUDE_FUNCTIONS)
311397
add_subdirectory(functions)
312398
endif()

admob/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ android {
6262
externalNativeBuild {
6363
cmake {
6464
targets 'firebase_admob'
65+
// Args are: Re-use app library prebuilt by app gradle project.
66+
// Don't configure all the cmake subprojects.
67+
// Only include needed project.
68+
arguments '-DFIREBASE_CPP_USE_PRIOR_GRADLE_BUILD=ON',
69+
'-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF',
70+
'-DFIREBASE_INCLUDE_ADMOB=ON'
6571
}
6672
}
6773
}

analytics/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ android {
6262
externalNativeBuild {
6363
cmake {
6464
targets 'firebase_analytics'
65+
// Args are: Re-use app library prebuilt by app gradle project.
66+
// Don't configure all the cmake subprojects.
67+
// Only include needed project.
68+
arguments '-DFIREBASE_CPP_USE_PRIOR_GRADLE_BUILD=ON',
69+
'-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF',
70+
'-DFIREBASE_INCLUDE_ANALYTICS=ON'
6571
}
6672
}
6773
}

android_build_files/generate_proguard.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def generateFinalProguard(Set<File> proguardSet, String outputProguard) {
6464
def defineGenerateProguardFile(String subproject, String buildType,
6565
Action<File> callback) {
6666
Task t = tasks.getByName("externalNativeBuild$buildType").with {
67-
String outputProguard = "$buildDir/${subproject}.pro"
67+
String outputProguard = "$buildDir/$buildType/${subproject}.pro"
6868

6969
outputs.file "$outputProguard"
7070
doLast {

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ android {
6262
externalNativeBuild {
6363
cmake {
6464
targets 'firebase_app'
65+
// Don't configure all the cmake subprojects.
66+
arguments '-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF'
6567
}
6668
}
6769
}

app/rest/tests/CMakeLists.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Google
1+
# Copyright 2019 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -42,22 +42,22 @@ target_include_directories(sample_resource_lib
4242
${FLATBUFFERS_SOURCE_DIR}/include
4343
)
4444

45-
cc_test(firebase_app_rest_request_test
45+
firebase_cpp_cc_test(firebase_app_rest_request_test
4646
SOURCES
4747
request_test.h
4848
request_test.cc
4949
DEPENDS
5050
firebase_rest_lib
5151
)
5252

53-
cc_test(firebase_app_rest_request_binary_test
53+
firebase_cpp_cc_test(firebase_app_rest_request_binary_test
5454
SOURCES
5555
request_binary_test.cc
5656
DEPENDS
5757
firebase_rest_lib
5858
)
5959

60-
cc_test(firebase_app_rest_request_json_test
60+
firebase_cpp_cc_test(firebase_app_rest_request_json_test
6161
SOURCES
6262
../request_json.h
6363
request_json_test.cc
@@ -67,43 +67,43 @@ cc_test(firebase_app_rest_request_json_test
6767
sample_resource_lib
6868
)
6969

70-
cc_test(firebase_app_rest_response_test
70+
firebase_cpp_cc_test(firebase_app_rest_response_test
7171
SOURCES
7272
response_test.cc
7373
DEPENDS
7474
firebase_rest_lib
7575
)
7676

77-
cc_test(firebase_app_rest_response_binary_test
77+
firebase_cpp_cc_test(firebase_app_rest_response_binary_test
7878
SOURCES
7979
response_binary_test.cc
8080
DEPENDS
8181
firebase_rest_lib
8282
)
8383

84-
cc_test(firebase_app_rest_response_json_test
84+
firebase_cpp_cc_test(firebase_app_rest_response_json_test
8585
SOURCES
8686
response_json_test.cc
8787
DEPENDS
8888
firebase_rest_lib
8989
sample_resource_lib
9090
)
9191

92-
cc_test(firebase_app_rest_util_test
92+
firebase_cpp_cc_test(firebase_app_rest_util_test
9393
SOURCES
9494
util_test.cc
9595
DEPENDS
9696
firebase_rest_lib
9797
)
9898

99-
cc_test(firebase_app_rest_www_form_url_encoded_test
99+
firebase_cpp_cc_test(firebase_app_rest_www_form_url_encoded_test
100100
SOURCES
101101
www_form_url_encoded_test.cc
102102
DEPENDS
103103
firebase_rest_lib
104104
)
105105

106-
cc_test(firebase_app_rest_transport_mock_test
106+
firebase_cpp_cc_test(firebase_app_rest_transport_mock_test
107107
SOURCES
108108
transport_mock_test.cc
109109
../transport_mock.h
@@ -119,31 +119,31 @@ cc_test(firebase_app_rest_transport_mock_test
119119
#[[
120120
121121
# google3 Dependency: FLAGS_test_tmpdir, CHECK(), CHECK_EQ
122-
cc_test(firebase_app_rest_request_file_test
122+
firebase_cpp_cc_test(firebase_app_rest_request_file_test
123123
SOURCES
124124
request_file_test.cc
125125
DEPENDS
126126
firebase_rest_lib
127127
)
128128
129129
# google3 Dependency: absl/strings/escaping (absl::CEscape)
130-
cc_test(firebase_app_rest_gzipheader_unittest
130+
firebase_cpp_cc_test(firebase_app_rest_gzipheader_unittest
131131
SOURCES
132132
gzipheader_unittest.cc
133133
DEPENDS
134134
firebase_rest_lib
135135
)
136136
137137
# google3 Dependency: absl/strings/escaping (absl::CEscape)
138-
cc_test(firebase_app_rest_zlibwrapper_unittest
138+
firebase_cpp_cc_test(firebase_app_rest_zlibwrapper_unittest
139139
SOURCES
140140
zlibwrapper_unittest.cc
141141
DEPENDS
142142
firebase_rest_lib
143143
)
144144
145145
# google3 Dependency: net/.../http2server, net/util/ports.h (net_util::PickUnusedPort())
146-
cc_test(firebase_app_rest_transport_curl_test
146+
firebase_cpp_cc_test(firebase_app_rest_transport_curl_test
147147
SOURCES
148148
transport_curl_test.cc
149149
DEPENDS

0 commit comments

Comments
 (0)