@@ -65,7 +65,7 @@ def install_x86_support_libraries():
65
65
utils .run_command (['apt' , 'install' , 'libsecret-1-dev:i386' ], as_root = True )
66
66
67
67
68
- def install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library ):
68
+ def _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library ):
69
69
"""Install packages with vcpkg.
70
70
71
71
This does the following,
@@ -99,14 +99,36 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library):
99
99
utils .run_command ([vcpkg_executable_file_path , 'install' ,
100
100
'@' + vcpkg_response_file_path , '--disable-metrics' ])
101
101
102
- # Some errors in vcpkg installation are not bubbled up. Verify existence
103
- # of certain important directories before proceeding.
104
- utils .verify_vcpkg_build (vcpkg_triplet )
102
+ def install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library , cleanup = True ):
103
+ """Install packages with vcpkg and optionally cleanup any intermediates.
105
104
106
- # Clear temporary directories and files created by vcpkg buildtrees
107
- # could be several GBs and cause github runners to run out of space
108
- utils .clean_vcpkg_temp_data ()
105
+ This is a wrapper over a low level installation function and attempts the
106
+ installation twice, a second time after attempting to auto fix known issues.
109
107
108
+ Args:
109
+ arch (str): Architecture (eg: 'x86', 'x64').
110
+ msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
111
+ cleanup (bool): Clean up intermediate files used during installation.
112
+
113
+ Raises:
114
+ (ValueError) If installation wasn't successful.
115
+ """
116
+ _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library )
117
+ vcpkg_triplet = utils .get_vcpkg_triplet (arch , msvc_runtime_library )
118
+ # Verify the installation with an attempt to auto fix any issues.
119
+ success = utils .verify_vcpkg_build (vcpkg_triplet , attempt_auto_fix = True )
120
+ if not success :
121
+ print ("Installation was not successful but auto fix was attempted. "
122
+ "Retrying installation..." )
123
+ # Retry once more after attempted auto fix.
124
+ _install_cpp_dependencies_with_vcpkg (arch , msvc_runtime_library )
125
+ # Check for success again. If installation failed, this call will raise a ValueError.
126
+ success = utils .verify_vcpkg_build (vcpkg_triplet , attempt_auto_fix = False )
127
+
128
+ if cleanup :
129
+ # Clear temporary directories and files created by vcpkg buildtrees
130
+ # could be several GBs and cause github runners to run out of space
131
+ utils .clean_vcpkg_temp_data ()
110
132
111
133
def cmake_configure (build_dir , arch , msvc_runtime_library = 'static' ,
112
134
build_tests = True , config = None , target_format = None ):
@@ -179,8 +201,13 @@ def main():
179
201
if args .arch == 'x86' and utils .is_linux_os ():
180
202
install_x86_support_libraries ()
181
203
182
- # Install platform dependent cpp dependencies with vcpkg
183
- install_cpp_dependencies_with_vcpkg (args .arch , args .msvc_runtime_library )
204
+ # Install C++ dependencies using vcpkg
205
+ install_cpp_dependencies_with_vcpkg (args .arch , args .msvc_runtime_library ,
206
+ cleanup = True )
207
+
208
+ if args .vcpkg_step_only :
209
+ print ("Exiting without building the Firebase C++ SDK as just vcpkg step was requested." )
210
+ return
184
211
185
212
# CMake configure
186
213
cmake_configure (args .build_dir , args .arch , args .msvc_runtime_library ,
@@ -219,6 +246,7 @@ def parse_cmdline_args():
219
246
help = 'Runtime library for MSVC (static(/MT) or dynamic(/MD)' )
220
247
parser .add_argument ('--build_dir' , default = 'build' , help = 'Output build directory' )
221
248
parser .add_argument ('--build_tests' , action = 'store_true' , help = 'Build unit tests too' )
249
+ parser .add_argument ('--vcpkg_step_only' , action = 'store_true' , help = 'Just install cpp packages using vcpkg and exit.' )
222
250
parser .add_argument ('--config' , default = 'Release' , help = 'Release/Debug config' )
223
251
parser .add_argument ('--target' , nargs = '+' , help = 'A list of CMake build targets (eg: firebase_app firebase_auth)' )
224
252
parser .add_argument ('--target_format' , default = None , help = '(Mac only) whether to output frameworks (default) or libraries.' )
0 commit comments