@@ -141,7 +141,8 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library, cleanup=True
141141 utils .clean_vcpkg_temp_data ()
142142
143143def 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 ):
145146 """ CMake configure.
146147
147148 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
156157 config (str): Release/Debug config.
157158 If its not specified, cmake's default is used (most likely Debug).
158159 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.
159162 """
160163 cmd = ['cmake' , '-S' , '.' , '-B' , build_dir ]
161164
@@ -170,19 +173,18 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
170173 # workaround, absl doesn't build without tests enabled
171174 cmd .append ('-DBUILD_TESTING=off' )
172175
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 ))
186188
187189 if utils .is_windows_os ():
188190 # If building for x86, we should supply -A Win32 to cmake configure
@@ -202,31 +204,38 @@ def cmake_configure(build_dir, arch, msvc_runtime_library='static', linux_abi='l
202204 cmd .append ('-DFIREBASE_XCODE_TARGET_FORMAT={0}' .format (target_format ))
203205
204206 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+
205212 utils .run_command (cmd )
206213
207214def main ():
208215 args = parse_cmdline_args ()
209216
210217 # Ensure that the submodules are initialized and updated
211218 # 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' ])
214222
215223 # To build x86 on x86_64 linux hosts, we also need x86 support libraries
216224 if args .arch == 'x86' and utils .is_linux_os ():
217225 install_x86_support_libraries ()
218226
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 )
222231
223232 if args .vcpkg_step_only :
224233 print ("Exiting without building the Firebase C++ SDK as just vcpkg step was requested." )
225234 return
226235
227236 # CMake configure
228237 cmake_configure (args .build_dir , args .arch , args .msvc_runtime_library , args .linux_abi ,
229- args .build_tests , args .config , args .target_format )
238+ args .build_tests , args .config , args .target_format , args . disable_vcpkg , args . verbose )
230239
231240 # CMake build
232241 # cmake --build build -j 8
@@ -238,14 +247,6 @@ def main():
238247 cmd .append ('--target' )
239248 cmd .extend (args .target )
240249 utils .run_command (cmd )
241- # Copy libraries from appropriate vcpkg directory to build output
242- # directory for later inclusion.
243- vcpkg_path = ('external/vcpkg/installed/%s/%slib/' %
244- (utils .get_vcpkg_triplet (args .arch , args .msvc_runtime_library ),
245- 'debug/' if args .config == 'Debug' else '' ))
246- if (os .path .exists (vcpkg_path )):
247- shutil .rmtree ('vcpkg-libs' , ignore_errors = True )
248- shutil .copytree (vcpkg_path , os .path .join (args .build_dir , 'vcpkg-libs' ), )
249250
250251
251252def parse_cmdline_args ():
@@ -257,6 +258,8 @@ def parse_cmdline_args():
257258 help = 'C++ ABI for Linux (legacy or c++11)' )
258259 parser .add_argument ('--build_dir' , default = 'build' , help = 'Output build directory' )
259260 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.' )
260263 parser .add_argument ('--vcpkg_step_only' , action = 'store_true' , help = 'Just install cpp packages using vcpkg and exit.' )
261264 parser .add_argument ('--config' , default = 'Release' , help = 'Release/Debug config' )
262265 parser .add_argument ('--target' , nargs = '+' , help = 'A list of CMake build targets (eg: firebase_app firebase_auth)' )
0 commit comments