@@ -141,7 +141,8 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library, cleanup=True
141
141
utils .clean_vcpkg_temp_data ()
142
142
143
143
def cmake_configure (build_dir , arch , msvc_runtime_library = 'static' , linux_abi = 'legacy' ,
144
- build_tests = True , config = None , target_format = None ):
144
+ build_tests = True , config = None , target_format = None ,
145
+ disable_vcpkg = False , verbose = False ):
145
146
""" CMake configure.
146
147
147
148
If you are seeing problems when running this multiple times,
@@ -156,6 +157,8 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
156
157
config (str): Release/Debug config.
157
158
If its not specified, cmake's default is used (most likely Debug).
158
159
target_format (str): If specified, build for this targetformat ('frameworks' or 'libraries').
160
+ disable_vcpkg (bool): If True, skip vcpkg and just use CMake for deps.
161
+ verbose (bool): If True, enable verbose mode in the CMake file.
159
162
"""
160
163
cmd = ['cmake' , '-S' , '.' , '-B' , build_dir ]
161
164
@@ -170,19 +173,18 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
170
173
# workaround, absl doesn't build without tests enabled
171
174
cmd .append ('-DBUILD_TESTING=off' )
172
175
173
- if utils .is_linux_os () and arch == 'x86' :
174
- # Use a separate cmake toolchain for cross compiling linux x86 builds
175
- vcpkg_toolchain_file_path = os .path .join (os .getcwd (), 'external' , 'vcpkg' ,
176
- 'scripts' , 'buildsystems' , 'linux_32.cmake' )
177
- else :
178
- vcpkg_toolchain_file_path = os .path .join (os .getcwd (), 'external' ,
179
- 'vcpkg' , 'scripts' ,
180
- 'buildsystems' , 'vcpkg.cmake' )
181
-
182
- cmd .append ('-DCMAKE_TOOLCHAIN_FILE={0}' .format (vcpkg_toolchain_file_path ))
183
-
184
- vcpkg_triplet = utils .get_vcpkg_triplet (arch , msvc_runtime_library )
185
- cmd .append ('-DVCPKG_TARGET_TRIPLET={0}' .format (vcpkg_triplet ))
176
+ if not disable_vcpkg :
177
+ if utils .is_linux_os () and arch == 'x86' :
178
+ # Use a separate cmake toolchain for cross compiling linux x86 builds
179
+ vcpkg_toolchain_file_path = os .path .join (os .getcwd (), 'external' , 'vcpkg' ,
180
+ 'scripts' , 'buildsystems' , 'linux_32.cmake' )
181
+ else :
182
+ vcpkg_toolchain_file_path = os .path .join (os .getcwd (), 'external' ,
183
+ 'vcpkg' , 'scripts' ,
184
+ 'buildsystems' , 'vcpkg.cmake' )
185
+ cmd .append ('-DCMAKE_TOOLCHAIN_FILE={0}' .format (vcpkg_toolchain_file_path ))
186
+ vcpkg_triplet = utils .get_vcpkg_triplet (arch , msvc_runtime_library )
187
+ cmd .append ('-DVCPKG_TARGET_TRIPLET={0}' .format (vcpkg_triplet ))
186
188
187
189
if utils .is_windows_os ():
188
190
# If building for x86, we should supply -A Win32 to cmake configure
@@ -202,37 +204,38 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
202
204
cmd .append ('-DFIREBASE_XCODE_TARGET_FORMAT={0}' .format (target_format ))
203
205
204
206
cmd .append ('-DFIREBASE_USE_BORINGSSL=ON' )
207
+
208
+ # Print out every command while building.
209
+ if verbose :
210
+ cmd .append ('-DCMAKE_VERBOSE_MAKEFILE=1' )
211
+
205
212
utils .run_command (cmd )
206
213
207
214
def main ():
208
215
args = parse_cmdline_args ()
209
216
210
217
# Ensure that the submodules are initialized and updated
211
218
# Example: vcpkg is a submodule (external/vcpkg)
212
- utils .run_command (['git' , 'submodule' , 'init' ])
213
- utils .run_command (['git' , 'submodule' , 'update' ])
219
+ if not args .disable_vcpkg :
220
+ utils .run_command (['git' , 'submodule' , 'init' ])
221
+ utils .run_command (['git' , 'submodule' , 'update' ])
214
222
215
223
# To build x86 on x86_64 linux hosts, we also need x86 support libraries
216
224
if args .arch == 'x86' and utils .is_linux_os ():
217
225
install_x86_support_libraries ()
218
226
219
- # Install C++ dependencies using vcpkg
220
- install_cpp_dependencies_with_vcpkg (args .arch , args .msvc_runtime_library ,
221
- cleanup = True )
227
+ if not args .disable_vcpkg :
228
+ # Install C++ dependencies using vcpkg
229
+ install_cpp_dependencies_with_vcpkg (args .arch , args .msvc_runtime_library ,
230
+ cleanup = True )
222
231
223
232
if args .vcpkg_step_only :
224
233
print ("Exiting without building the Firebase C++ SDK as just vcpkg step was requested." )
225
234
return
226
235
227
236
# CMake configure
228
237
cmake_configure (args .build_dir , args .arch , args .msvc_runtime_library , args .linux_abi ,
229
- args .build_tests , args .config , args .target_format )
230
-
231
- # Small workaround before build, turn off -Werror=sign-compare for a specific Firestore core lib.
232
- if not utils .is_windows_os ():
233
- append_line_to_file (os .path .join (args .build_dir ,
234
- 'external/src/firestore/Firestore/core/CMakeLists.txt' ),
235
- 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=sign-compare")' )
238
+ args .build_tests , args .config , args .target_format , args .disable_vcpkg , args .verbose )
236
239
237
240
# CMake build
238
241
# cmake --build build -j 8
@@ -244,14 +247,6 @@ def main():
244
247
cmd .append ('--target' )
245
248
cmd .extend (args .target )
246
249
utils .run_command (cmd )
247
- # Copy libraries from appropriate vcpkg directory to build output
248
- # directory for later inclusion.
249
- vcpkg_path = ('external/vcpkg/installed/%s/%slib/' %
250
- (utils .get_vcpkg_triplet (args .arch , args .msvc_runtime_library ),
251
- 'debug/' if args .config == 'Debug' else '' ))
252
- if (os .path .exists (vcpkg_path )):
253
- shutil .rmtree ('vcpkg-libs' , ignore_errors = True )
254
- shutil .copytree (vcpkg_path , os .path .join (args .build_dir , 'vcpkg-libs' ), )
255
250
256
251
257
252
def parse_cmdline_args ():
@@ -263,6 +258,8 @@ def parse_cmdline_args():
263
258
help = 'C++ ABI for Linux (legacy or c++11)' )
264
259
parser .add_argument ('--build_dir' , default = 'build' , help = 'Output build directory' )
265
260
parser .add_argument ('--build_tests' , action = 'store_true' , help = 'Build unit tests too' )
261
+ parser .add_argument ('--verbose' , action = 'store_true' , help = 'Enable verbose CMake builds.' )
262
+ parser .add_argument ('--disable_vcpkg' , action = 'store_true' , help = 'Disable vcpkg and just use CMake.' )
266
263
parser .add_argument ('--vcpkg_step_only' , action = 'store_true' , help = 'Just install cpp packages using vcpkg and exit.' )
267
264
parser .add_argument ('--config' , default = 'Release' , help = 'Release/Debug config' )
268
265
parser .add_argument ('--target' , nargs = '+' , help = 'A list of CMake build targets (eg: firebase_app firebase_auth)' )
0 commit comments