Problem: CI jobs were very often failing at the install-vcpkg step, after the prebuilt-vcpkg-tool download fails with an HTTP 504. Cause: The bootstrap-vcpkg.sh script’s curl call retries span only a few seconds — too soon to get past an outage — and the build_vcpkg.py script runs with no retry at all. So one transient 504 hard-fails everything. Fix: Do the bootstrap in build_vcpkg.py with retries and some backoff — so one transient download failure no longer breaks the entire build.
78 lines
2.3 KiB
Python
Executable file
78 lines
2.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2024, pheonixfirewingz <luke.a.shore@proton.me>
|
|
# Copyright (c) 2024-2026, Tim Flynn <trflynn89@ladybird.org>
|
|
#
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
import json
|
|
import pathlib
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
META_SOURCE_DIR = pathlib.Path(__file__).resolve().parent.parent
|
|
LADYBIRD_SOURCE_DIR = META_SOURCE_DIR.parent
|
|
|
|
sys.path.append(str(META_SOURCE_DIR))
|
|
|
|
from Utils.host_platform import HostSystem # noqa: E402
|
|
from Utils.host_platform import Platform # noqa: E402
|
|
|
|
|
|
def build_vcpkg():
|
|
platform = Platform()
|
|
|
|
with open(LADYBIRD_SOURCE_DIR / "vcpkg.json", "r") as vcpkg_json_file:
|
|
vcpkg_json = json.load(vcpkg_json_file)
|
|
|
|
git_repo = "https://github.com/microsoft/vcpkg.git"
|
|
git_rev = vcpkg_json["builtin-baseline"]
|
|
|
|
build_dir = LADYBIRD_SOURCE_DIR / "Build"
|
|
build_dir.mkdir(parents=True, exist_ok=True)
|
|
vcpkg_checkout = build_dir / "vcpkg"
|
|
|
|
if not vcpkg_checkout.is_dir():
|
|
subprocess.check_call(args=["git", "clone", git_repo], cwd=build_dir)
|
|
else:
|
|
bootstrapped_vcpkg_version = (
|
|
subprocess.check_output(["git", "-C", vcpkg_checkout, "rev-parse", "HEAD"]).strip().decode()
|
|
)
|
|
|
|
if bootstrapped_vcpkg_version == git_rev:
|
|
return
|
|
|
|
print(f"Building vcpkg@{git_rev}")
|
|
|
|
subprocess.check_call(args=["git", "fetch", "origin"], cwd=vcpkg_checkout)
|
|
subprocess.check_call(args=["git", "checkout", git_rev], cwd=vcpkg_checkout)
|
|
|
|
bootstrap_script = "bootstrap-vcpkg.bat" if platform.host_system == HostSystem.Windows else "bootstrap-vcpkg.sh"
|
|
arguments = [vcpkg_checkout / bootstrap_script, "-disableMetrics"]
|
|
|
|
if platform.libc_name() == "musl":
|
|
arguments.append("-musl")
|
|
|
|
max_attempts = 3
|
|
for attempt in range(1, max_attempts + 1):
|
|
try:
|
|
subprocess.check_call(args=arguments, cwd=vcpkg_checkout)
|
|
return
|
|
except subprocess.CalledProcessError:
|
|
if attempt == max_attempts:
|
|
raise
|
|
delay_seconds = 15 * attempt
|
|
print(
|
|
f"vcpkg bootstrap failed (attempt {attempt}); retrying in {delay_seconds}s",
|
|
file=sys.stderr,
|
|
)
|
|
time.sleep(delay_seconds)
|
|
|
|
|
|
def main():
|
|
build_vcpkg()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|