Skip to content

Commit f750f87

Browse files
authored
Add CMake support for FSTLocalSerializer (#3753)
* Add support for building Objective-C protos in CMake * Add support for building FSTLocalSerializer to CMake * Build ProtoSizer with CMake * Build memory components with CMake * Build LevelDB components with CMake
1 parent 5ecb670 commit f750f87

File tree

9 files changed

+218
-14
lines changed

9 files changed

+218
-14
lines changed

Firestore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
add_subdirectory(Example/Benchmarks)
1616

1717
add_subdirectory(Protos)
18+
add_subdirectory(Source)
1819
add_subdirectory(core)
1920
add_subdirectory(fuzzing)

Firestore/Protos/CMakeLists.txt

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,26 @@ target_include_directories(
167167
${FIREBASE_SOURCE_DIR}/Firestore/Protos/cpp
168168
)
169169

170+
if(APPLE)
171+
cc_library(
172+
firebase_firestore_protos_objc
173+
SOURCES
174+
${PROTOBUF_OBJC_GENERATED_SOURCES}
175+
DEPENDS
176+
libprotobuf_objc
177+
EXCLUDE_FROM_ALL
178+
)
179+
180+
target_include_directories(
181+
firebase_firestore_protos_objc PRIVATE
182+
${FIREBASE_SOURCE_DIR}/Firestore/Protos/objc/firestore/local
183+
${FIREBASE_SOURCE_DIR}/Firestore/Protos/objc/google/firestore/v1
184+
${FIREBASE_SOURCE_DIR}/Firestore/Protos/objc/google/api
185+
${FIREBASE_SOURCE_DIR}/Firestore/Protos/objc/google/rpc
186+
${FIREBASE_SOURCE_DIR}/Firestore/Protos/objc/google/type
187+
)
188+
endif()
189+
170190

171191
# Generate the python representation of descriptor.proto.
172192
set(PROTOBUF_DIR ${FIREBASE_BINARY_DIR}/external/src/grpc/third_party/protobuf)
@@ -306,3 +326,95 @@ add_custom_target(
306326
generate_cpp_protos
307327
generate_objc_protos
308328
)
329+
330+
if(APPLE)
331+
set(
332+
protobuf_objc_source_dir
333+
${FIREBASE_EXTERNAL_SOURCE_DIR}/grpc/third_party/protobuf/objectivec
334+
)
335+
objc_framework(
336+
Protobuf
337+
HEADERS
338+
${protobuf_objc_source_dir}/GPBArray.h
339+
${protobuf_objc_source_dir}/GPBArray_PackagePrivate.h
340+
${protobuf_objc_source_dir}/GPBBootstrap.h
341+
${protobuf_objc_source_dir}/GPBCodedInputStream.h
342+
${protobuf_objc_source_dir}/GPBCodedInputStream_PackagePrivate.h
343+
${protobuf_objc_source_dir}/GPBCodedOutputStream.h
344+
${protobuf_objc_source_dir}/GPBCodedOutputStream_PackagePrivate.h
345+
${protobuf_objc_source_dir}/GPBDescriptor.h
346+
${protobuf_objc_source_dir}/GPBDescriptor_PackagePrivate.h
347+
${protobuf_objc_source_dir}/GPBDictionary.h
348+
${protobuf_objc_source_dir}/GPBDictionary_PackagePrivate.h
349+
${protobuf_objc_source_dir}/GPBExtensionInternals.h
350+
${protobuf_objc_source_dir}/GPBExtensionRegistry.h
351+
${protobuf_objc_source_dir}/GPBMessage.h
352+
${protobuf_objc_source_dir}/GPBMessage_PackagePrivate.h
353+
${protobuf_objc_source_dir}/GPBProtocolBuffers.h
354+
${protobuf_objc_source_dir}/GPBProtocolBuffers_RuntimeSupport.h
355+
${protobuf_objc_source_dir}/GPBRootObject.h
356+
${protobuf_objc_source_dir}/GPBRootObject_PackagePrivate.h
357+
${protobuf_objc_source_dir}/GPBRuntimeTypes.h
358+
${protobuf_objc_source_dir}/GPBUnknownField.h
359+
${protobuf_objc_source_dir}/GPBUnknownFieldSet.h
360+
${protobuf_objc_source_dir}/GPBUnknownFieldSet_PackagePrivate.h
361+
${protobuf_objc_source_dir}/GPBUnknownField_PackagePrivate.h
362+
${protobuf_objc_source_dir}/GPBUtilities.h
363+
${protobuf_objc_source_dir}/GPBUtilities_PackagePrivate.h
364+
${protobuf_objc_source_dir}/GPBWellKnownTypes.h
365+
${protobuf_objc_source_dir}/GPBWireFormat.h
366+
${protobuf_objc_source_dir}/google/protobuf/Any.pbobjc.h
367+
${protobuf_objc_source_dir}/google/protobuf/Api.pbobjc.h
368+
${protobuf_objc_source_dir}/google/protobuf/Duration.pbobjc.h
369+
${protobuf_objc_source_dir}/google/protobuf/Empty.pbobjc.h
370+
${protobuf_objc_source_dir}/google/protobuf/FieldMask.pbobjc.h
371+
${protobuf_objc_source_dir}/google/protobuf/SourceContext.pbobjc.h
372+
${protobuf_objc_source_dir}/google/protobuf/Struct.pbobjc.h
373+
${protobuf_objc_source_dir}/google/protobuf/Timestamp.pbobjc.h
374+
${protobuf_objc_source_dir}/google/protobuf/Type.pbobjc.h
375+
${protobuf_objc_source_dir}/google/protobuf/Wrappers.pbobjc.h
376+
377+
SOURCES
378+
${protobuf_objc_source_dir}/GPBArray.m
379+
${protobuf_objc_source_dir}/GPBCodedInputStream.m
380+
${protobuf_objc_source_dir}/GPBCodedOutputStream.m
381+
${protobuf_objc_source_dir}/GPBDescriptor.m
382+
${protobuf_objc_source_dir}/GPBDictionary.m
383+
${protobuf_objc_source_dir}/GPBExtensionInternals.m
384+
${protobuf_objc_source_dir}/GPBExtensionRegistry.m
385+
${protobuf_objc_source_dir}/GPBMessage.m
386+
${protobuf_objc_source_dir}/GPBProtocolBuffers.m
387+
${protobuf_objc_source_dir}/GPBRootObject.m
388+
${protobuf_objc_source_dir}/GPBUnknownField.m
389+
${protobuf_objc_source_dir}/GPBUnknownFieldSet.m
390+
${protobuf_objc_source_dir}/GPBUtilities.m
391+
${protobuf_objc_source_dir}/GPBWellKnownTypes.m
392+
${protobuf_objc_source_dir}/GPBWireFormat.m
393+
${protobuf_objc_source_dir}/google/protobuf/Any.pbobjc.m
394+
${protobuf_objc_source_dir}/google/protobuf/Api.pbobjc.m
395+
${protobuf_objc_source_dir}/google/protobuf/Duration.pbobjc.m
396+
${protobuf_objc_source_dir}/google/protobuf/Empty.pbobjc.m
397+
${protobuf_objc_source_dir}/google/protobuf/FieldMask.pbobjc.m
398+
${protobuf_objc_source_dir}/google/protobuf/SourceContext.pbobjc.m
399+
${protobuf_objc_source_dir}/google/protobuf/Struct.pbobjc.m
400+
${protobuf_objc_source_dir}/google/protobuf/Timestamp.pbobjc.m
401+
${protobuf_objc_source_dir}/google/protobuf/Type.pbobjc.m
402+
${protobuf_objc_source_dir}/google/protobuf/Wrappers.pbobjc.m
403+
)
404+
target_include_directories(
405+
Protobuf
406+
PRIVATE
407+
${protobuf_objc_source_dir}/google/protobuf
408+
INTERFACE
409+
${PROJECT_BINARY_DIR}/Headers/Protobuf
410+
PUBLIC
411+
${protobuf_objc_source_dir}
412+
)
413+
target_compile_options(
414+
Protobuf PRIVATE
415+
-fno-objc-arc
416+
-Wno-missing-noescape
417+
)
418+
add_alias(libprotobuf_objc Protobuf)
419+
420+
endif()

Firestore/Source/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019 Google
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
add_subdirectory(Public)
16+
add_subdirectory(Remote)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019 Google
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
if(APPLE)
16+
cc_library(
17+
firebase_firestore_public_objc
18+
HEADER_ONLY
19+
SOURCES
20+
FIRFirestoreErrors.h
21+
)
22+
23+
target_include_directories(
24+
firebase_firestore_public_objc
25+
INTERFACE
26+
${FIREBASE_SOURCE_DIR}/Firestore/Source/Public
27+
)
28+
29+
endif()
30+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2019 Google
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
if(APPLE)
16+
cc_library(
17+
firebase_firestore_remote_objc
18+
SOURCES
19+
FSTSerializerBeta.h
20+
FSTSerializerBeta.mm
21+
DEPENDS
22+
absl_algorithm
23+
firebase_firestore_nanopb
24+
firebase_firestore_public_objc
25+
libprotobuf_objc
26+
)
27+
28+
endif()

Firestore/Source/Remote/FSTSerializerBeta.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ - (ObjectValue)decodedMapValue:(GCFSMapValue *)map {
450450
- (ObjectValue)decodedFields:(NSDictionary<NSString *, GCFSValue *> *)fields {
451451
__block ObjectValue result = ObjectValue::Empty();
452452
[fields enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, GCFSValue *_Nonnull obj,
453-
BOOL *_Nonnull stop) {
453+
BOOL *_Nonnull) {
454454
FieldPath path{util::MakeString(key)};
455455
FieldValue value = [self decodedFieldValue:obj];
456456
result = result.Set(path, std::move(value));
@@ -725,7 +725,7 @@ - (GCFSArrayValue *)encodedArrayTransformElements:(const std::vector<FieldValue>
725725

726726
- (std::vector<FieldValue>)decodedArrayTransformElements:(GCFSArrayValue *)proto {
727727
__block std::vector<FieldValue> elements;
728-
[proto.valuesArray enumerateObjectsUsingBlock:^(GCFSValue *value, NSUInteger idx, BOOL *stop) {
728+
[proto.valuesArray enumerateObjectsUsingBlock:^(GCFSValue *value, NSUInteger, BOOL *) {
729729
elements.push_back([self decodedFieldValue:value]);
730730
}];
731731
return elements;
@@ -1167,7 +1167,7 @@ - (SnapshotVersion)versionFromListenResponse:(GCFSListenResponse *)watchChange {
11671167
WatchTargetChangeState state = [self decodedWatchTargetChangeState:change.targetChangeType];
11681168
__block std::vector<TargetId> targetIDs;
11691169

1170-
[change.targetIdsArray enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
1170+
[change.targetIdsArray enumerateValuesWithBlock:^(int32_t value, NSUInteger, BOOL *) {
11711171
targetIDs.push_back(value);
11721172
}];
11731173

@@ -1203,7 +1203,7 @@ - (WatchTargetChangeState)decodedWatchTargetChangeState:(GCFSTargetChange_Target
12031203
- (std::vector<TargetId>)decodedIntegerArray:(GPBInt32Array *)values {
12041204
__block std::vector<TargetId> result;
12051205
result.reserve(values.count);
1206-
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
1206+
[values enumerateValuesWithBlock:^(int32_t value, NSUInteger, BOOL *) {
12071207
result.push_back(value);
12081208
}];
12091209
return result;

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ cc_library(
1616
firebase_firestore_local_persistence_leveldb
1717
SOURCES
1818
leveldb_index_manager.h
19-
#leveldb_index_manager.mm
19+
leveldb_index_manager.mm
2020
leveldb_key.cc
2121
leveldb_key.h
2222
leveldb_migrations.cc
2323
leveldb_migrations.h
2424
leveldb_mutation_queue.h
25-
#leveldb_mutation_queue.mm
25+
leveldb_mutation_queue.mm
2626
leveldb_query_cache.h
27-
#leveldb_query_cache.mm
27+
leveldb_query_cache.mm
2828
leveldb_remote_document_cache.h
29-
#leveldb_remote_document_cache.mm
29+
leveldb_remote_document_cache.mm
3030
leveldb_transaction.cc
3131
leveldb_transaction.h
3232
leveldb_util.cc
@@ -44,6 +44,14 @@ cc_library(
4444
EXCLUDE_FROM_ALL
4545
)
4646

47+
if(APPLE)
48+
target_link_libraries(
49+
firebase_firestore_local_persistence_leveldb
50+
PRIVATE
51+
firebase_firestore_protos_objc
52+
)
53+
endif()
54+
4755
cc_library(
4856
firebase_firestore_local
4957
SOURCES
@@ -62,12 +70,14 @@ cc_library(
6270
memory_index_manager.cc
6371
memory_index_manager.h
6472
memory_mutation_queue.h
65-
#memory_mutation_queue.mm
73+
memory_mutation_queue.mm
6674
memory_query_cache.h
67-
#memory_query_cache.mm
75+
memory_query_cache.mm
6876
memory_remote_document_cache.h
69-
#memory_remote_document_cache.mm
77+
memory_remote_document_cache.mm
7078
mutation_queue.h
79+
proto_sizer.h
80+
proto_sizer.mm
7181
query_cache.h
7282
query_data.cc
7383
query_data.h
@@ -88,3 +98,10 @@ cc_library(
8898
firebase_firestore_remote
8999
firebase_firestore_util
90100
)
101+
102+
if(APPLE)
103+
target_link_libraries(
104+
firebase_firestore_local PRIVATE
105+
firebase_firestore_protos_objc
106+
)
107+
endif()

Firestore/core/src/firebase/firestore/local/leveldb_mutation_queue.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ BatchId LoadNextBatchIdFromDb(DB* db) {
154154
return empty;
155155
}
156156

157-
void LevelDbMutationQueue::AcknowledgeBatch(const MutationBatch& batch,
157+
void LevelDbMutationQueue::AcknowledgeBatch(const MutationBatch&,
158158
const ByteString& stream_token) {
159159
SetLastStreamToken(stream_token);
160160
}

Firestore/core/src/firebase/firestore/local/memory_mutation_queue.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ MutationBatch batch(batch_id, local_write_time, std::move(base_mutations),
211211
// The requested batchID may still be out of range so normalize it to the
212212
// start of the queue.
213213
int raw_index = IndexOfBatchId(next_batch_id);
214-
int index = raw_index < 0 ? 0 : raw_index;
214+
size_t index = raw_index < 0 ? 0 : static_cast<size_t>(raw_index);
215215
if (queue_.size() <= index) {
216216
return absl::nullopt;
217217
}
@@ -230,7 +230,7 @@ MutationBatch batch(batch_id, local_write_time, std::move(base_mutations),
230230
}
231231

232232
int index = IndexOfBatchId(batch_id);
233-
if (index < 0 || index >= queue_.size()) {
233+
if (index < 0 || static_cast<size_t>(index) >= queue_.size()) {
234234
return absl::nullopt;
235235
}
236236

0 commit comments

Comments
 (0)