App-Ariza.git | t/golden/ | launcher-windows-x86_64.ps1
# Example App 9.9.9 — self-contained bundle launcher.
#
# Generated by ariza for windows-x86_64. Everything this script needs is
# inside the directory above it; nothing outside the bundle is read, and
# nothing is installed.
$ErrorActionPreference = 'Stop'
$ArizaDisplay = 'Example App'
# $PSScriptRoot is already the resolved directory of this script, so
# there is no symlink chasing to do — the POSIX twin's job here is done
# for us by PowerShell.
$BundleRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$ArizaRaku = Join-Path $BundleRoot 'rakudo\bin\raku.exe'
if (-not (Test-Path -LiteralPath $ArizaRaku)) {
[Console]::Error.WriteLine("${ArizaDisplay}: this bundle is incomplete - no interpreter at $ArizaRaku")
[Console]::Error.WriteLine(' Unpack the whole archive and run this script from inside it.')
exit 1
}
# The bundle is the only module repository; anything the user has set
# would put modules compiled against a different Rakudo ahead of ours.
# It is the bundled runtime's own vendor repository, which is what makes
# the shipped bytecode usable from here rather than only where it was
# built.
$env:RAKULIB = 'inst#' + (Join-Path $BundleRoot 'rakudo\share\perl6\vendor')
Remove-Item Env:\PERL6LIB -ErrorAction SilentlyContinue
# Notcurses::Native finds its prebuilt libraries here and sets
# TERMINFO_DIRS from the same place.
$env:NOTCURSES_NATIVE_DATA_DIR = Join-Path $BundleRoot 'native'
# Each assignment prepends, so lower-priority SQLCipher is applied first.
# The final PATH starts with Notcurses, then SQLCipher, then the inherited PATH.
$SqlcipherDir = Join-Path $BundleRoot 'native\sqlcipher'
$env:PATH = $SqlcipherDir + ';' + $env:PATH
$NotcursesDir = Join-Path $BundleRoot 'native\Notcurses-Native\binaries-notcurses-3.0.17-r11\lib'
$env:PATH = $NotcursesDir + ';' + $env:PATH
# DBIish pre-loads SQLCipher by absolute path when told where it is.
$env:DBIISH_SQLCIPHER_LIB = Join-Path $BundleRoot 'native\sqlcipher\sqlcipher.dll'
$ArizaStateRoot = $env:LOCALAPPDATA
if (-not $ArizaStateRoot) {
$ArizaStateRoot = $env:TEMP
}
$ArizaStateDir = Join-Path $ArizaStateRoot 'exampleapp'
if (-not (Test-Path -LiteralPath (Join-Path $ArizaStateDir '.first-run'))) {
[Console]::Error.WriteLine("${ArizaDisplay}: first launch can take a few seconds. Later ones are instant.")
try {
New-Item -ItemType Directory -Force -Path $ArizaStateDir | Out-Null
New-Item -ItemType File -Force -Path (Join-Path $ArizaStateDir '.first-run') | Out-Null
} catch { }
}
& $ArizaRaku (Join-Path $BundleRoot 'rakudo\share\perl6\vendor\bin\exampleapp.raku') @args
exit $LASTEXITCODE