diff --git a/.github/workflows/nuget-static-graphics.yml b/.github/workflows/nuget-static-graphics.yml index a495062..325bbab 100644 --- a/.github/workflows/nuget-static-graphics.yml +++ b/.github/workflows/nuget-static-graphics.yml @@ -35,7 +35,7 @@ jobs: - name: Install native build dependencies run: | sudo apt-get update - sudo apt-get install -y clang lld llvm ninja-build pkg-config libfontconfig1-dev libglib2.0-dev + sudo apt-get install -y clang lld llvm libclang-rt-dev ninja-build pkg-config libfontconfig1-dev libglib2.0-dev - name: Build Linux static graphics libraries env: diff --git a/scripts/build-linux-static-graphics.sh b/scripts/build-linux-static-graphics.sh index e987f57..4d1cf47 100755 --- a/scripts/build-linux-static-graphics.sh +++ b/scripts/build-linux-static-graphics.sh @@ -11,6 +11,7 @@ ANGLE_BRANCH="${ANGLE_BRANCH:-7151}" BUILD_JOBS="${BUILD_JOBS:-$(nproc)}" ANGLE_PATCH_DIR="${ANGLE_PATCH_DIR:-$ROOT_DIR/External/NativeStatic/patches}" LLVM_AR="${LLVM_AR:-llvm-ar-19}" +SKIA_DEPS_RETRIES="${SKIA_DEPS_RETRIES:-3}" usage() { cat <<'USAGE' @@ -69,10 +70,37 @@ sync_skiasharp() { echo "$src" } +prepare_skia_git_sync_deps() { + local sync_deps="$1/tools/git-sync-deps" + python3 - "$sync_deps" <<'PY' +import pathlib +import sys + +path = pathlib.Path(sys.argv[1]) +text = path.read_text() +old = " multithread(git_checkout_to_directory, list_of_arg_lists)" +new = " for args in list_of_arg_lists:\n git_checkout_to_directory(*args)" +if old in text: + path.write_text(text.replace(old, new)) +PY +} + sync_skia_deps() { local skia_dir="$1/externals/skia" if [[ ! -x "$skia_dir/bin/gn" ]]; then - python3 "$skia_dir/tools/git-sync-deps" + prepare_skia_git_sync_deps "$skia_dir" + + local attempt + for attempt in $(seq 1 "$SKIA_DEPS_RETRIES"); do + if python3 "$skia_dir/tools/git-sync-deps"; then + return 0 + fi + if [[ "$attempt" == "$SKIA_DEPS_RETRIES" ]]; then + return 1 + fi + echo "git-sync-deps failed; retrying ($attempt/$SKIA_DEPS_RETRIES)..." >&2 + sleep 10 + done fi } diff --git a/scripts/build-macos-static-graphics.sh b/scripts/build-macos-static-graphics.sh index 534861c..f841609 100755 --- a/scripts/build-macos-static-graphics.sh +++ b/scripts/build-macos-static-graphics.sh @@ -10,6 +10,7 @@ SKIASHARP_VERSION="${SKIASHARP_VERSION:-3.119.2}" ANGLE_BRANCH="${ANGLE_BRANCH:-7151}" BUILD_JOBS="${BUILD_JOBS:-$(sysctl -n hw.ncpu)}" ANGLE_PATCH_DIR="${ANGLE_PATCH_DIR:-$ROOT_DIR/External/NativeStatic/patches}" +SKIA_DEPS_RETRIES="${SKIA_DEPS_RETRIES:-3}" require_cmd() { if ! command -v "$1" >/dev/null 2>&1; then @@ -64,6 +65,38 @@ sync_skiasharp() { echo "$src" } +prepare_skia_git_sync_deps() { + local sync_deps="$1/tools/git-sync-deps" + python3 - "$sync_deps" <<'PY' +import pathlib +import sys + +path = pathlib.Path(sys.argv[1]) +text = path.read_text() +old = " multithread(git_checkout_to_directory, list_of_arg_lists)" +new = " for args in list_of_arg_lists:\n git_checkout_to_directory(*args)" +if old in text: + path.write_text(text.replace(old, new)) +PY +} + +sync_skia_deps() { + local skia_dir="$1" + prepare_skia_git_sync_deps "$skia_dir" + + local attempt + for attempt in $(seq 1 "$SKIA_DEPS_RETRIES"); do + if python3 "$skia_dir/tools/git-sync-deps"; then + return 0 + fi + if [[ "$attempt" == "$SKIA_DEPS_RETRIES" ]]; then + return 1 + fi + echo "git-sync-deps failed; retrying ($attempt/$SKIA_DEPS_RETRIES)..." >&2 + sleep 10 + done +} + build_skia() { ensure_tools ensure_depot_tools @@ -71,7 +104,7 @@ build_skia() { src="$(sync_skiasharp)" local skia_dir="$src/externals/skia" if [[ ! -x "$skia_dir/bin/gn" ]]; then - python3 "$skia_dir/tools/git-sync-deps" + sync_skia_deps "$skia_dir" fi local out_dir="$skia_dir/out/mac-static-$TARGET_CPU" diff --git a/scripts/build-windows-static-graphics.ps1 b/scripts/build-windows-static-graphics.ps1 index d188650..c80483a 100644 --- a/scripts/build-windows-static-graphics.ps1 +++ b/scripts/build-windows-static-graphics.ps1 @@ -14,6 +14,7 @@ $Rid = if ($env:RID) { $env:RID } else { "win-$TargetCpu" } $OutputDir = if ($env:OUTPUT_DIR) { $env:OUTPUT_DIR } else { Join-Path $RootDir "External\NativeStatic\$Rid" } $BuildJobs = if ($env:BUILD_JOBS) { $env:BUILD_JOBS } else { [Environment]::ProcessorCount } $AnglePatchDir = if ($env:ANGLE_PATCH_DIR) { $env:ANGLE_PATCH_DIR } else { Join-Path $RootDir "External\NativeStatic\patches" } +$SkiaDepsRetries = if ($env:SKIA_DEPS_RETRIES) { [int]$env:SKIA_DEPS_RETRIES } else { 3 } function Require-Command($Name) { if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) { @@ -61,13 +62,39 @@ function Sync-SkiaSharp { return $src } +function Prepare-SkiaGitSyncDeps($SkiaDir) { + $syncDeps = Join-Path $SkiaDir "tools\git-sync-deps" + $text = Get-Content -Path $syncDeps -Raw + $old = " multithread(git_checkout_to_directory, list_of_arg_lists)" + $new = " for args in list_of_arg_lists:`n git_checkout_to_directory(*args)" + if ($text.Contains($old)) { + Set-Content -Path $syncDeps -Value $text.Replace($old, $new) -NoNewline -Encoding UTF8 + } +} + +function Invoke-SkiaGitSyncDeps($SkiaDir) { + Prepare-SkiaGitSyncDeps $SkiaDir + + for ($attempt = 1; $attempt -le $SkiaDepsRetries; $attempt++) { + python (Join-Path $SkiaDir "tools\git-sync-deps") + if ($LASTEXITCODE -eq 0) { + return + } + if ($attempt -eq $SkiaDepsRetries) { + throw "git-sync-deps failed after $SkiaDepsRetries attempts" + } + Write-Warning "git-sync-deps failed; retrying ($attempt/$SkiaDepsRetries)..." + Start-Sleep -Seconds 10 + } +} + function Build-Skia { Ensure-Tools Ensure-DepotTools $src = Sync-SkiaSharp $skiaDir = Join-Path $src "externals\skia" if (-not (Test-Path (Join-Path $skiaDir "bin\gn.exe"))) { - python (Join-Path $skiaDir "tools\git-sync-deps") + Invoke-SkiaGitSyncDeps $skiaDir } $outDir = Join-Path $skiaDir "out\win-static-$TargetCpu"