Skip to content

Commit 1ad1722

Browse files
committed
cleaner way to retry and attempt to auto fix known issues
vcpkg installation can fail with a known issue on some Windows machines with NFS drives.
1 parent 8ad594e commit 1ad1722

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

scripts/gha/build_desktop.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def install_x86_support_libraries():
6565
utils.run_command(['apt', 'install', 'libsecret-1-dev:i386'], as_root=True)
6666

6767

68-
def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library,
69-
attempt_auto_fix=False):
68+
def _install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library):
7069
"""Install packages with vcpkg.
7170
7271
This does the following,
@@ -76,13 +75,6 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library,
7675
Args:
7776
arch (str): Architecture (eg: 'x86', 'x64').
7877
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.
8678
"""
8779

8880
# Install vcpkg executable if its not installed already
@@ -107,17 +99,36 @@ def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library,
10799
utils.run_command([vcpkg_executable_file_path, 'install',
108100
'@' + vcpkg_response_file_path, '--disable-metrics'])
109101

110-
# Some errors in vcpkg installation are not bubbled up. Verify existence
111-
# of certain important directories before proceeding.
112-
success = utils.verify_vcpkg_build(vcpkg_triplet, attempt_auto_fix)
113-
if not success:
114-
return False
102+
def install_cpp_dependencies_with_vcpkg(arch, msvc_runtime_library, cleanup=True):
103+
"""Install packages with vcpkg and optionally cleanup any intermediates.
104+
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.
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.
115112
116-
# Clear temporary directories and files created by vcpkg buildtrees
117-
# could be several GBs and cause github runners to run out of space
118-
utils.clean_vcpkg_temp_data()
119-
return True
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)
120127

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()
121132

122133
def cmake_configure(build_dir, arch, msvc_runtime_library='static',
123134
build_tests=True, config=None, target_format=None):
@@ -190,22 +201,12 @@ def main():
190201
if args.arch == 'x86' and utils.is_linux_os():
191202
install_x86_support_libraries()
192203

193-
# Install platform dependent cpp dependencies with vcpkg
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-
print("Installation was not successful but auto fix was attempted. "
202-
"Retrying installation...")
203-
install_cpp_dependencies_with_vcpkg(args.arch,
204-
args.msvc_runtime_library,
205-
attempt_auto_fix=False)
204+
# Install C++ dependencies using vcpkg
205+
install_cpp_dependencies_with_vcpkg(args.arch, args.msvc_runtime_library,
206+
cleanup=True)
206207

207208
if args.vcpkg_step_only:
208-
print("Exiting without building the SDK as just vcpkg step was requested.")
209+
print("Exiting without building the Firebase C++ SDK as just vcpkg step was requested.")
209210
return
210211

211212
# CMake configure

0 commit comments

Comments
 (0)