-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
b06cfd4
commit ad6a679
Showing
1 changed file
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |