@@ -65,7 +65,8 @@ 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
+ attempt_auto_fix = False ):
69
70
"""Install packages with vcpkg.
70
71
71
72
This does the following,
@@ -75,6 +76,13 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library):
75
76
Args:
76
77
arch (str): Architecture (eg: 'x86', 'x64').
77
78
msvc_runtime_library (str): Runtime library for MSVC (eg: 'static', 'dynamic').
79
+ attempt_auto_fix (bool): In case of errors, try to auto fix.
80
+ Returns:
81
+ (bool): True if installation was successful.
82
+ False if installation wasn't successful but auto fix was attempted
83
+ and we should retry the installation.
84
+ Raises:
85
+ (ValueError): If installation wasn't successful and auto fix wasn't attempted.
78
86
"""
79
87
80
88
# Install vcpkg executable if its not installed already
@@ -101,11 +109,14 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library):
101
109
102
110
# Some errors in vcpkg installation are not bubbled up. Verify existence
103
111
# of certain important directories before proceeding.
104
- utils .verify_vcpkg_build (vcpkg_triplet )
112
+ success = utils .verify_vcpkg_build (vcpkg_triplet , attempt_auto_fix )
113
+ if not success :
114
+ return False
105
115
106
116
# Clear temporary directories and files created by vcpkg buildtrees
107
117
# could be several GBs and cause github runners to run out of space
108
118
utils .clean_vcpkg_temp_data ()
119
+ return True
109
120
110
121
111
122
def cmake_configure (build_dir , arch , msvc_runtime_library = 'static' ,
@@ -180,7 +191,16 @@ def main():
180
191
install_x86_support_libraries ()
181
192
182
193
# Install platform dependent cpp dependencies with vcpkg
183
- install_cpp_dependencies_with_vcpkg (args .arch , args .msvc_runtime_library )
194
+ # Try once with auto-fixing any errors (if any)
195
+ success = install_cpp_dependencies_with_vcpkg (args .arch ,
196
+ args .msvc_runtime_library ,
197
+ attempt_auto_fix = True )
198
+ if not success :
199
+ # If auto-fix was attempted, give it one more try.
200
+ # If it fails again, a ValueError will be raised and script will exit.
201
+ install_cpp_dependencies_with_vcpkg (args .arch ,
202
+ args .msvc_runtime_library ,
203
+ attempt_auto_fix = False )
184
204
185
205
# CMake configure
186
206
cmake_configure (args .build_dir , args .arch , args .msvc_runtime_library ,
0 commit comments