From ad6a6796ff9db9af6700f7a03e145fa57a486c37 Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Fri, 28 Jul 2023 09:42:30 -0400 Subject: [PATCH] Add new powershell script to run the entire install This can be used locally or on the build server, for easier testing. Right now, it's just building cairo. --- build-cairo.ps1 | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 build-cairo.ps1 diff --git a/build-cairo.ps1 b/build-cairo.ps1 new file mode 100644 index 0000000..a0ccc32 --- /dev/null +++ b/build-cairo.ps1 @@ -0,0 +1,139 @@ +param ( + [switch]$ShowDebug +) + +function ShowFileContent { + param ( + [string]$FilePath + ) + + Write-Host "Getting contents of `"$FilePath`"" + $fileContent = "" + try { + $fileContent = Get-Content -Path $FilePath -ErrorAction Stop + Write-Host ">> Success" + } catch { + Write-Host ">> Error: $_.Exception.Message" + } + + Write-Host "" + Write-Host "Contents of `"$FilePath`"" with original line endings + Write-Host "--START-----------------------------------------------------" + Write-Host $fileContent + Write-Host "--END-------------------------------------------------------" + + Write-Host "" + Write-Host "Contents of `"$FilePath`"" with normalized line endings + Write-Host "--START-----------------------------------------------------" + Write-Output $fileContent + Write-Host "--END-------------------------------------------------------" +} + +# Built-in IsWindows variable not working on Windows agent +$IsWindowsOS = $false +if ($env:OS -like '*Windows*') { + Write-Host "Running on a Windows OS" + $IsWindowsOS = $true +} else { + Write-Host "Running on a non-Windows OS" +} + +Write-Host "" +Write-Host "============================================================" +Write-Host "Debugging info" +Write-Host "============================================================" +Write-Host "IsWindows: $IsWindowsOS" + +Write-Host "" +Write-Host "============================================================" +Write-Host "Set git configuration" +Write-Host "============================================================" +Write-Host "Turning off git core.autocrlf" +git config --global core.autocrlf false + +Write-Host "" +Write-Host "============================================================" +Write-Host "Remove vcpkg cache on the system" +Write-Host "============================================================" +$vcpkgCacheDir = "" +if ($IsWindowsOS) { + $vcpkgCacheDir = "$env:LocalAppData\vcpkg\archives" +} else { + $vcpkgCacheDir = "$HOME/.cache/vcpkg/archives" +} +Write-Host "Deleting user-specific vcpkg cache directory: $vcpkgCacheDir" +if (Test-Path -Path $vcpkgCacheDir -PathType Container) { + Write-Host ">> Deleting..." + Remove-Item -Path $vcpkgCacheDir -Recurse -Force +} else { + Write-Host ">> Path not found: $vcpkgCacheDir" +} + +Write-Host "" +Write-Host "============================================================" +Write-Host "Remove vcpkg subdir (if exists)" +Write-Host "============================================================" +$vcpkgDir = "./vcpkg" +if (Test-Path -Path $vcpkgDir -PathType Container) { + Write-Host ">> Deleting dir: $vcpkgDir" + Remove-Item -Path $vcpkgDir -Recurse -Force +} else { + Write-Host ">> Directory not found: $vcpkgDir" +} + +Write-Host "" +Write-Host "============================================================" +Write-Host "Clone our copy of vcpkg & bootstrap it" +Write-Host "============================================================" +$VcpkgRepo = "https://github.com/TechSmith/vcpkg.git" +Write-Host "Cloning $VcpkgRepo" +git clone $VcpkgRepo + +Write-Host "Bootstrapping VCPKG" +Push-Location "vcpkg" +$bootstrapScript = "" +if ($IsWindowsOS) { + $bootstrapScript = "./bootstrap-vcpkg.bat" +} +else { + $bootstrapScript = "./bootstrap-vcpkg.sh" +} +Invoke-Expression "$bootstrapScript" +Pop-Location + +Write-Host "" +Write-Host "============================================================" +Write-Host "Install cairo" +Write-Host "============================================================" +Write-Host "Installing cairo" +$vcpkgExe = "" +$triplet = "" +if ($IsWindowsOS) { + $vcpkgExe = "./vcpkg/vcpkg.exe" + $triplet = "x64-windows-release" +} else { + $vcpkgExe = "./vcpkg/vcpkg" + $triplet = "x64-osx-dynamic-release" +} +$pkgToInstall = "cairo:$triplet" +Write-Host "Installing $pkgToInstall" +Invoke-Expression "$vcpkgExe install `"$pkgToInstall`" --overlay-triplets=`"triplets`" --overlay-ports=`"custom-ports`"" + +if($ShowDebug) +{ + Write-Host "" + Write-Host "============================================================" + Write-Host "Show debugging info" + Write-Host "============================================================" + if($IsWindowsOS) { + # Show Windows debugging info + ShowFileContent -FilePath "custom-ports/cairo/cairo_static_fix.patch" + } + else { + # Show Mac debugging info + ShowFileContent -FilePath "vcpkg/buildtrees/cairo/package-x64-osx-dynamic-release-rel-out.log" + } +} + +# Done +Write-Host "`n`nDone."