Skip to content

Commit fb441a0

Browse files
authored
Build all sources with CMake (#4159)
* Fix field initialization order * Reduce dependencies in objc_compatibility_apple_test This makes it possible to build and test util without having to build everything * Add a lint check for CMake files * Find XCTest, if available * Fix CMakeLists.txt to include all sources * Fix test flake in local store tests This doesn't affect production because we always set the additional references pointer there, but it's technically optional and some tests don't do this.
1 parent 67de928 commit fb441a0

24 files changed

+538
-88
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ target_include_directories(
210210
)
211211

212212

213+
# XCTest
214+
if(${CMAKE_VERSION} VERSION_LESS "3.3.0")
215+
set(XCTest_FOUND OFF)
216+
else()
217+
find_package(XCTest)
218+
endif()
219+
220+
213221
enable_testing()
214222
include(compiler_setup)
215223

Firestore/Source/CMakeLists.txt

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,82 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
add_subdirectory(Public)
15+
if(APPLE)
16+
podspec_version(firestore_version ${PROJECT_SOURCE_DIR}/FirebaseFirestore.podspec)
17+
18+
cc_library(
19+
firebase_firestore_objc_api
20+
SOURCES
21+
API/FIRCollectionReference+Internal.h
22+
API/FIRCollectionReference.mm
23+
API/FIRDocumentChange+Internal.h
24+
API/FIRDocumentChange.mm
25+
API/FIRDocumentReference+Internal.h
26+
API/FIRDocumentReference.mm
27+
API/FIRDocumentSnapshot+Internal.h
28+
API/FIRDocumentSnapshot.mm
29+
API/FIRFieldPath+Internal.h
30+
API/FIRFieldPath.mm
31+
API/FIRFieldValue+Internal.h
32+
API/FIRFieldValue.mm
33+
API/FIRFirestore+Internal.h
34+
API/FIRFirestore.mm
35+
API/FIRFirestoreSettings+Internal.h
36+
API/FIRFirestoreSettings.mm
37+
API/FIRFirestoreSource+Internal.h
38+
API/FIRFirestoreSource.mm
39+
API/FIRFirestoreVersion.h
40+
API/FIRFirestoreVersion.mm
41+
API/FIRGeoPoint+Internal.h
42+
API/FIRGeoPoint.mm
43+
API/FIRListenerRegistration+Internal.h
44+
API/FIRListenerRegistration.mm
45+
API/FIRQuery+Internal.h
46+
API/FIRQuery.mm
47+
API/FIRQuerySnapshot+Internal.h
48+
API/FIRQuerySnapshot.mm
49+
API/FIRSnapshotMetadata+Internal.h
50+
API/FIRSnapshotMetadata.mm
51+
API/FIRTimestamp+Internal.h
52+
API/FIRTransaction+Internal.h
53+
API/FIRTransaction.mm
54+
API/FIRWriteBatch+Internal.h
55+
API/FIRWriteBatch.mm
56+
API/FSTFirestoreComponent.h
57+
API/FSTFirestoreComponent.mm
58+
API/FSTUserDataConverter.h
59+
API/FSTUserDataConverter.mm
60+
API/converters.h
61+
API/converters.mm
62+
Core/FSTTypes.h
63+
Public/FIRCollectionReference.h
64+
Public/FIRDocumentChange.h
65+
Public/FIRDocumentReference.h
66+
Public/FIRDocumentSnapshot.h
67+
Public/FIRFieldPath.h
68+
Public/FIRFieldValue.h
69+
Public/FIRFirestore.h
70+
Public/FIRFirestoreErrors.h
71+
Public/FIRFirestoreSettings.h
72+
Public/FIRFirestoreSource.h
73+
Public/FIRGeoPoint.h
74+
Public/FIRListenerRegistration.h
75+
Public/FIRQuery.h
76+
Public/FIRQuerySnapshot.h
77+
Public/FIRSnapshotMetadata.h
78+
Public/FIRTimestamp.h
79+
Public/FIRTransaction.h
80+
Public/FIRWriteBatch.h
81+
Public/FirebaseFirestore.h
82+
Util/FSTClasses.h
83+
DEPENDS
84+
absl_strings
85+
firebase_firestore_api
86+
)
87+
88+
target_include_directories(
89+
firebase_firestore_objc_api
90+
PUBLIC
91+
${FIREBASE_SOURCE_DIR}/Firestore/Source/Public
92+
)
93+
endif()

Firestore/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_subdirectory(src/firebase/firestore/util)
2828

2929
add_subdirectory(test/firebase/firestore/testutil)
3030
add_subdirectory(test/firebase/firestore)
31+
add_subdirectory(test/firebase/firestore/api)
3132
add_subdirectory(test/firebase/firestore/auth)
3233
add_subdirectory(test/firebase/firestore/core)
3334
add_subdirectory(test/firebase/firestore/immutable)

Firestore/core/include/firebase/firestore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# issue tracker: https://gitlab.kitware.com/cmake/cmake/issues/15234)
1818
add_custom_target(firebase_firestore_types_ide SOURCES
1919
firestore_errors.h
20+
firestore_version.h
2021
geo_point.h
2122
timestamp.h
2223
)

Firestore/core/src/firebase/firestore/api/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,34 @@ cc_library(
1717
SOURCES
1818
collection_reference.cc
1919
collection_reference.h
20-
collection_reference.cc
2120
document_change.cc
2221
document_change.h
22+
document_reference.h
23+
document_reference.mm
2324
document_snapshot.cc
2425
document_snapshot.h
26+
firestore.h
27+
firestore.mm
28+
listener_registration.h
2529
query_core.h
2630
query_core.mm
31+
query_listener_registration.h
32+
query_listener_registration.mm
2733
query_snapshot.cc
2834
query_snapshot.h
2935
settings.cc
3036
settings.h
3137
snapshot_metadata.cc
3238
snapshot_metadata.h
39+
snapshots_in_sync_listener_registration.h
40+
snapshots_in_sync_listener_registration.mm
41+
source.h
42+
write_batch.h
43+
write_batch.mm
3344
DEPENDS
3445
absl_meta
3546
firebase_firestore_core
47+
firebase_firestore_local
3648
firebase_firestore_model
3749
firebase_firestore_util
3850
)

Firestore/core/src/firebase/firestore/core/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ cc_library(
2525
database_info.h
2626
direction.cc
2727
direction.h
28+
event_listener.h
29+
event_manager.h
30+
event_manager.mm
2831
field_filter.cc
2932
field_filter.h
3033
filter.cc
3134
filter.h
35+
firestore_client.h
36+
firestore_client.mm
3237
in_filter.cc
3338
in_filter.h
3439
key_field_in_filter.cc
@@ -43,8 +48,15 @@ cc_library(
4348
query.h
4449
query_listener.cc
4550
query_listener.h
51+
sync_engine.h
52+
sync_engine.mm
53+
sync_engine_callback.h
4654
target_id_generator.cc
4755
target_id_generator.h
56+
transaction.h
57+
transaction.mm
58+
transaction_runner.h
59+
transaction_runner.mm
4860
user_data.cc
4961
user_data.h
5062
view.cc
@@ -53,6 +65,7 @@ cc_library(
5365
view_snapshot.h
5466
DEPENDS
5567
absl_strings
68+
firebase_firestore_local
5669
firebase_firestore_model
5770
firebase_firestore_objc
5871
firebase_firestore_remote

Firestore/core/src/firebase/firestore/local/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ cc_library(
6868
local_documents_view.h
6969
local_serializer.cc
7070
local_serializer.h
71+
local_store.cc
72+
local_store.h
7173
local_view_changes.cc
7274
local_view_changes.h
75+
local_write_result.h
7376
lru_garbage_collector.cc
7477
lru_garbage_collector.h
7578
memory_eager_reference_delegate.cc

Firestore/core/src/firebase/firestore/local/memory_eager_reference_delegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ class MemoryEagerReferenceDelegate : public ReferenceDelegate {
6060
orphaned_;
6161

6262
// This instance is owned by MemoryPersistence.
63-
MemoryPersistence* persistence_;
63+
MemoryPersistence* persistence_ = nullptr;
6464

6565
// The ReferenceSet is owned by LocalStore.
66-
ReferenceSet* additional_references_;
66+
ReferenceSet* additional_references_ = nullptr;
6767
};
6868

6969
} // namespace local

Firestore/core/src/firebase/firestore/nanopb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cc_library(
1717
SOURCES
1818
byte_string.cc
1919
byte_string.h
20+
fields_array.h
2021
message.cc
2122
message.h
2223
nanopb_util.cc

Firestore/core/src/firebase/firestore/remote/CMakeLists.txt

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cc_library(
2121
DEPENDS
2222
absl_base
2323
firebase_firestore_util
24+
"-framework SystemConfiguration"
2425
EXCLUDE_FROM_ALL
2526
)
2627

@@ -46,21 +47,28 @@ cc_select(
4647
# alongside gRPC and is necessary to establish SSL connections. Embed this file
4748
# into the binary by converting it to a char array.
4849
add_custom_command(
49-
OUTPUT grpc_root_certificates_generated.h grpc_root_certificates_generated.cc
50-
COMMAND python ${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
51-
--output_header=grpc_root_certificates_generated.h
52-
--output_source=grpc_root_certificates_generated.cc
53-
--cpp_namespace=firebase::firestore::remote
54-
--array=grpc_root_certificates_generated_data
55-
--array_size=grpc_root_certificates_generated_size
56-
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/etc/roots.pem
57-
DEPENDS
50+
OUTPUT
51+
grpc_root_certificates_generated.h # NOLINT(generated)
52+
grpc_root_certificates_generated.cc # NOLINT(generated)
53+
COMMAND python ${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
54+
--output_header=grpc_root_certificates_generated.h
55+
--output_source=grpc_root_certificates_generated.cc
56+
--cpp_namespace=firebase::firestore::remote
57+
--array=grpc_root_certificates_generated_data
58+
--array_size=grpc_root_certificates_generated_size
59+
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/etc/roots.pem
60+
DEPENDS
5861
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/etc/roots.pem
5962
)
6063

64+
# TODO(wilhuff): Build grpc_root_certificate_finder_apple.mm NOLINT(not built)
65+
6166
cc_library(
6267
firebase_firestore_remote
6368
SOURCES
69+
datastore.cc
70+
datastore.h
71+
existence_filter.h
6472
exponential_backoff.cc
6573
exponential_backoff.h
6674
grpc_call.h
@@ -84,25 +92,24 @@ cc_library(
8492
grpc_util.cc
8593
grpc_util.cc
8694
grpc_util.h
95+
online_state_tracker.cc
96+
online_state_tracker.h
8797
remote_event.cc
8898
remote_event.h
99+
remote_objc_bridge.h
100+
remote_objc_bridge.mm
101+
remote_store.cc
102+
remote_store.h
89103
serializer.cc
90104
serializer.h
105+
stream.cc
106+
stream.h
91107
watch_change.cc
92108
watch_change.h
93-
94-
# TODO(varconst): add these files once they no longer depend on Objective-C
95-
# serializer.
96-
# datastore.h
97-
# datastore.cc
98-
# remote_objc_bridge.h
99-
# remote_objc_bridge.mm
100-
# stream.h
101-
# stream.cc
102-
# watch_stream.h
103-
# watch_stream.cc
104-
# write_stream.h
105-
# write_stream.cc
109+
watch_stream.cc
110+
watch_stream.h
111+
write_stream.cc
112+
write_stream.h
106113

107114
DEPENDS
108115
# TODO(b/111328563) Force nanopb first to work around ODR violations

0 commit comments

Comments
 (0)