Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/frontend-editor-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,27 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Test pinned Wave and latest Vex installer and recovery
shell: powershell
run: ./frontend/tests/install_latest_test.ps1

- name: Install the published package when the Windows installer changes
shell: powershell
run: |
$changed = git diff --name-only HEAD^ HEAD -- frontend/public/install.ps1
if ($LASTEXITCODE -ne 0) { throw 'Cannot determine installer changes.' }
if (-not $changed) { return }
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs = & $vswhere -latest -products * -property installationPath
if (-not $vs) { throw 'Visual Studio is required to run the installed compiler.' }
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'amd64' }
& "$vs\Common7\Tools\Launch-VsDevShell.ps1" -Arch $arch -HostArch $arch -SkipAutomaticLocation
$env:WAVE_INSTALL_DIR = Join-Path $env:RUNNER_TEMP 'Wave alpha/bin'
& ./frontend/public/install.ps1 -WithoutVex -NoModifyPath
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

build-and-test:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down
78 changes: 25 additions & 53 deletions frontend/public/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
[switch]$Help,
[Parameter(ValueFromRemainingArguments = $true)][string[]]$Remaining
)
# Wave installer channel policy: pinned-0.2.1-v1
# Wave installer channel policy: pinned-0.0.1-alpha-v1
$ErrorActionPreference = 'Stop'

function Write-Info($Message) { Write-Host "[info] $Message" }
function Manual-Only {
throw 'This installer installs Wave v0.2.1-pre-beta. Install older versions or Nightly manually: https://github.com/wavefnd/Wave/releases'
throw 'This installer installs Wave v0.0.1-alpha. Install older versions or Nightly manually: https://github.com/wavefnd/Wave/releases'
}
function Get-LatestRelease($Repository) {
$best = $null
Expand All @@ -35,8 +35,8 @@ function Get-LatestRelease($Repository) {
return $best
}
function Get-PinnedWaveRelease {
$release = Invoke-RestMethod -Headers @{Accept='application/vnd.github+json'} -TimeoutSec 60 -Uri 'https://api.github.com/repos/wavefnd/Wave/releases/tags/v0.2.1-pre-beta'
if ($release.tag_name -ne 'v0.2.1-pre-beta' -or $release.draft -ne $false) { throw 'Pinned Wave release metadata does not match.' }
$release = Invoke-RestMethod -Headers @{Accept='application/vnd.github+json'} -TimeoutSec 60 -Uri 'https://api.github.com/repos/wavefnd/Wave/releases/tags/v0.0.1-alpha'
if ($release.tag_name -ne 'v0.0.1-alpha' -or $release.draft -ne $false) { throw 'Pinned Wave release metadata does not match.' }
return $release
}
function Get-ReleaseAsset($Release, $Name, [bool]$Optional = $false) {
Expand Down Expand Up @@ -139,14 +139,6 @@ function Assert-SeparateInstallationPaths($InstallDirectory, $StdDirectory) {
throw 'The compiler installation and legacy std directory must not overlap.'
}
}
function Assert-ManagedStdDirectory($Directory) {
$item = Get-Item -LiteralPath $Directory -Force -ErrorAction SilentlyContinue
if ($null -eq $item) { return }
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'The legacy std directory must not be a link or junction.' }
if (-not $item.PSIsContainer -or -not (Test-Path -LiteralPath (Join-Path $Directory 'manifest.json') -PathType Leaf)) {
throw "Refusing to replace a standard library not managed by Wave: $Directory"
}
}
function Invoke-InstalledTool($Executable, [string[]]$Arguments) {
$output = & $Executable @Arguments
if ($LASTEXITCODE -ne 0) { throw "Installed tool failed ($LASTEXITCODE): $Executable $($Arguments -join ' ')" }
Expand All @@ -159,8 +151,17 @@ function Test-Installation($Directory, $Target, [bool]$InstallVex, $Work) {
$actual = ($spec | ConvertFrom-Json).triple
if ("$actual".Trim() -ne $Target) { throw "Compiler host target differs from $Target." }
$stdPath = Invoke-InstalledTool $wavec @('print', 'std-path')
$expectedStd = Resolve-InstallerPath (Get-LegacyStdRoot)
if (-not (Resolve-InstallerPath ("$stdPath".Trim())).Equals($expectedStd, [StringComparison]::OrdinalIgnoreCase)) {
$expectedStd = Resolve-InstallerPath (Join-Path $Directory 'std')
# Rust canonicalizes Windows paths using the extended drive or UNC spelling.
$reportedStd = "$stdPath".Trim()
if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) {
if ($reportedStd -match '^\\\\\?\\[A-Za-z]:\\') {
$reportedStd = $reportedStd.Substring(4)
} elseif ($reportedStd.StartsWith('\\?\UNC\', [StringComparison]::OrdinalIgnoreCase)) {
$reportedStd = '\\' + $reportedStd.Substring(8)
}
}
if (-not (Resolve-InstallerPath $reportedStd).Equals($expectedStd, [StringComparison]::OrdinalIgnoreCase)) {
throw 'Compiler default std path differs from the installed standard library.'
}
$source = Join-Path $Work 'install-smoke.wave'
Expand All @@ -182,12 +183,12 @@ fun main() -> i32 {
function Install-Wave {
if ($Help) {
Write-Host @'
Wave Toolchain Installer — Wave v0.2.1-pre-beta
Wave Toolchain Installer — Wave v0.0.1-alpha
Usage: .\install.ps1 [-Latest] [-WithVex | -WithoutVex] [-NoModifyPath]
Default: install Wave and install Vex when its latest release supports this platform.
-WithVex requires Vex; -WithoutVex installs Wave only.
WAVE_INSTALL_DIR overrides the dedicated installation directory (%LOCALAPPDATA%\Wave\bin).
The matching standard library also installs under HOME (or USERPROFILE) at .wave\lib\wave\std.
The matching std directory is installed beside wavec.exe.
Older versions and Nightly: download manually from https://github.com/wavefnd/Wave/releases
'@
return
Expand All @@ -213,7 +214,6 @@ Older versions and Nightly: download manually from https://github.com/wavefnd/Wa
throw "Refusing to replace a directory not managed by Wave: $installDir"
}
}
Assert-ManagedStdDirectory $stdDir
$wave = Get-PinnedWaveRelease
$waveName = "wave-$($wave.tag_name)-$target.zip"
$waveAsset = Get-ReleaseAsset $wave $waveName
Expand All @@ -229,26 +229,19 @@ Older versions and Nightly: download manually from https://github.com/wavefnd/Wa
}
Write-Info "Wave $($wave.tag_name) / $target"
Write-Info "Install directory: $installDir"
Write-Info "Compiler default standard library: $stdDir"
Write-Info "Compiler default standard library: $(Join-Path $installDir 'std')"
$parent = Split-Path -Parent $installDir
$stdParent = Split-Path -Parent $stdDir
$lockPath = "$installDir.install-lock"
$stdLockPath = "$stdDir.install-lock"
$lock = $null; $stdLock = $null
$lock = $null
$temp = Join-Path $parent ('.wave-install-' + [Guid]::NewGuid().ToString('N'))
$stdTemp = Join-Path $stdParent ('.wave-std-' + [Guid]::NewGuid().ToString('N'))
$stage = Join-Path $temp 'stage'; $backup = Join-Path $temp 'previous'
$stdStage = Join-Path $stdTemp 'stage'; $stdBackup = Join-Path $stdTemp 'previous'
$activated = $false; $stdActivated = $false; $committed = $false
$keepBackup = $false; $keepStdBackup = $false
$activated = $false; $committed = $false
$keepBackup = $false
try {
New-Item -ItemType Directory -Force -Path $parent, $stdParent | Out-Null
# Different custom compiler directories still share the compiler's per-user std.
New-Item -ItemType Directory -Force -Path $parent | Out-Null
$lock = [IO.File]::Open($lockPath, [IO.FileMode]::CreateNew, [IO.FileAccess]::Write, [IO.FileShare]::None)
$stdLock = [IO.File]::Open($stdLockPath, [IO.FileMode]::CreateNew, [IO.FileAccess]::Write, [IO.FileShare]::None)
Assert-SeparateInstallationPaths $installDir $stdDir
Assert-ManagedStdDirectory $stdDir
New-Item -ItemType Directory -Path $temp, $stdTemp | Out-Null
New-Item -ItemType Directory -Path $temp | Out-Null
Write-Info '[1/4] Downloading and verifying packages'
$waveZip = Join-Path $temp 'wave.zip'
Save-Download "https://github.com/wavefnd/Wave/releases/download/$($wave.tag_name)/$waveName" $waveZip
Expand All @@ -267,8 +260,6 @@ Older versions and Nightly: download manually from https://github.com/wavefnd/Wa
}
New-Item -ItemType Directory -Path $stage | Out-Null
Get-ChildItem -LiteralPath $package -Force | Copy-Item -Destination $stage -Recurse -Force
# Stage beside the legacy root, so activation and restore stay on its volume.
Copy-Item -LiteralPath (Join-Path $stage 'std') -Destination $stdStage -Recurse
if ($vexAsset) {
$vexRoot = Join-Path $temp 'vex'
Expand-Archive -LiteralPath $vexZip -DestinationPath $vexRoot
Expand All @@ -283,9 +274,6 @@ Older versions and Nightly: download manually from https://github.com/wavefnd/Wa
}
Write-Info '[3/4] Activating installation'
if (Test-Path -LiteralPath $installDir) { Move-Item -LiteralPath $installDir -Destination $backup }
if (Test-Path -LiteralPath $stdDir) { Move-Item -LiteralPath $stdDir -Destination $stdBackup }
$stdActivated = $true
Move-Item -LiteralPath $stdStage -Destination $stdDir
$activated = $true
Move-Item -LiteralPath $stage -Destination $installDir
Write-Info '[4/4] Checking compiler, default std and runtime'
Expand All @@ -298,35 +286,19 @@ Older versions and Nightly: download manually from https://github.com/wavefnd/Wa
Write-Info "Installed Wave $($wave.tag_name)."
if ($vexAsset) { Write-Info "Installed Vex $($vex.tag_name)." }
} finally {
$restoreErrors = @()
try {
if (-not $committed) {
# Attempt both restores even when one destination is inaccessible.
try {
if ($activated -and (Test-Path -LiteralPath $installDir)) { Remove-Item -LiteralPath $installDir -Recurse -Force }
if (Test-Path -LiteralPath $backup) { Move-Item -LiteralPath $backup -Destination $installDir }
} catch {
$keepBackup = Test-Path -LiteralPath $backup
$restoreErrors += "Previous compiler retained at $backup. $($_.Exception.Message)"
}
try {
if ($stdActivated -and (Test-Path -LiteralPath $stdDir)) { Remove-Item -LiteralPath $stdDir -Recurse -Force }
if (Test-Path -LiteralPath $stdBackup) { Move-Item -LiteralPath $stdBackup -Destination $stdDir }
} catch {
$keepStdBackup = Test-Path -LiteralPath $stdBackup
$restoreErrors += "Previous standard library retained at $stdBackup. $($_.Exception.Message)"
throw "Restore failed. Previous compiler retained at $backup. $($_.Exception.Message)"
}
}
if (-not $keepBackup -and (Test-Path -LiteralPath $temp)) { Remove-Item -LiteralPath $temp -Recurse -Force }
if (-not $keepStdBackup -and (Test-Path -LiteralPath $stdTemp)) { Remove-Item -LiteralPath $stdTemp -Recurse -Force }
if ($restoreErrors.Count) { throw "Restore failed. $($restoreErrors -join ' ')" }
} finally {
# A failed CreateNew never gives this invocation ownership of that lock.
try {
if ($null -ne $stdLock) {
$stdLock.Dispose()
Remove-Item -LiteralPath $stdLockPath -Force
}
if (-not $keepBackup -and (Test-Path -LiteralPath $temp)) { Remove-Item -LiteralPath $temp -Recurse -Force }
} finally {
if ($null -ne $lock) {
$lock.Dispose()
Expand Down
66 changes: 26 additions & 40 deletions frontend/public/install.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
# Wave installer channel policy: pinned-0.2.1-v1
# Wave installer channel policy: pinned-0.0.1-alpha-v1

info() { printf '[info] %s\n' "$*"; }
fail() { printf '[error] %s\n' "$*" >&2; exit 1; }
manual_only() {
fail 'This installer installs Wave v0.2.1-pre-beta. Install older versions or Nightly manually: https://github.com/wavefnd/Wave/releases'
fail 'This installer installs Wave v0.0.1-alpha. Install older versions or Nightly manually: https://github.com/wavefnd/Wave/releases'
}
usage() {
cat <<'HELP'
Wave Toolchain Installer — Wave v0.2.1-pre-beta
Wave Toolchain Installer — Wave v0.0.1-alpha
Usage: bash install.sh [latest] [--with-vex | --without-vex] [--no-modify-path]
Default: install Wave and install Vex when its latest release supports this platform.
--with-vex Require Vex; fail before installation if its package is absent.
--without-vex Install Wave only.
--no-modify-path Leave shell configuration unchanged.
WAVE_INSTALL_DIR overrides the dedicated installation directory (~/.wave/bin).
Matching std is also installed at ~/.wave/lib/wave/std for the pinned compiler.
The matching std directory is installed beside wavec.
Older versions and Nightly: download manually from https://github.com/wavefnd/Wave/releases
HELP
}
Expand Down Expand Up @@ -45,8 +45,8 @@ latest_release() {
}
pinned_wave_release() {
local release
release="$(fetch -H 'Accept: application/vnd.github+json' 'https://api.github.com/repos/wavefnd/Wave/releases/tags/v0.2.1-pre-beta')" || fail 'Cannot fetch pinned Wave release.'
jq -e '.tag_name == "v0.2.1-pre-beta" and .draft == false' >/dev/null <<< "$release" || fail 'Pinned Wave release metadata does not match.'
release="$(fetch -H 'Accept: application/vnd.github+json' 'https://api.github.com/repos/wavefnd/Wave/releases/tags/v0.0.1-alpha')" || fail 'Cannot fetch pinned Wave release.'
jq -e '.tag_name == "v0.0.1-alpha" and .draft == false' >/dev/null <<< "$release" || fail 'Pinned Wave release metadata does not match.'
printf '%s\n' "$release"
}
asset() {
Expand Down Expand Up @@ -106,10 +106,15 @@ configure_path() {
info "PATH configured in $rc. Open a new terminal to use Wave."
}
verify_installation() {
local directory="$1" target="$2" with_vex="$3" work="$4" actual
local directory="$1" target="$2" with_vex="$3" work="$4" actual std_path
"$directory/wavec" --version || return 1
actual="$("$directory/wavec" print target-spec --format=json | jq -er .triple)" || return 1
[[ "$actual" == "$target" ]] || { printf 'Expected %s; compiler reports %s\n' "$target" "$actual" >&2; return 1; }
std_path="$("$directory/wavec" print std-path)" || return 1
[[ -d "$std_path" && "$std_path" -ef "$directory/std" ]] || {
printf 'Expected bundled std at %s/std; compiler reports %s\n' "$directory" "$std_path" >&2
return 1
}
cat > "$work/install-smoke.wave" <<'WAVE'
import("std::mem::layout")::{size_of};
fun main() -> i32 {
Expand Down Expand Up @@ -161,21 +166,19 @@ main() {
fi
info "Wave $wave_version / $WAVE_TARGET"
info "Install directory: $INSTALL_DIR"
local parent std_parent std_lock compiler_compare std_compare
STD_DIR="$HOME/.wave/lib/wave/std"
[[ ! -L "$STD_DIR" ]] || fail 'The std installation directory must not be a symbolic link.'
if [[ -e "$STD_DIR" && ! -f "$STD_DIR/manifest.json" ]]; then
fail "Refusing to replace a directory not managed by Wave std: $STD_DIR"
fi
local parent legacy_std compiler_compare std_compare
parent="$(dirname "$INSTALL_DIR")"
std_parent="$(dirname "$STD_DIR")"
mkdir -p "$parent" "$std_parent"
mkdir -p "$parent"
parent="$(cd "$parent" && pwd -P)"
std_parent="$(cd "$std_parent" && pwd -P)"
INSTALL_DIR="$parent/${INSTALL_DIR##*/}"
STD_DIR="$std_parent/std"
legacy_std="$(cd "$HOME" && pwd -P)/.wave/lib/wave/std"
if [[ -d "$legacy_std" ]]; then
legacy_std="$(cd "$legacy_std" && pwd -P)"
elif [[ -d "${legacy_std%/*}" ]]; then
legacy_std="$(cd "${legacy_std%/*}" && pwd -P)/std"
fi
compiler_compare="$INSTALL_DIR/"
std_compare="$STD_DIR/"
std_compare="$legacy_std/"
# macOS volumes may ignore case, including a not-yet-created final component.
if [[ "$os" == Darwin ]]; then
compiler_compare="$(printf '%s' "$compiler_compare" | LC_ALL=C tr '[:upper:]' '[:lower:]')"
Expand All @@ -191,20 +194,15 @@ main() {
/bin|/sbin|/usr/bin|/usr/sbin|/usr/local/bin|/usr/local/sbin)
fail 'Do not replace a shared system binary directory.' ;;
esac
info "Std directory: $STD_DIR"
info "Std directory: $INSTALL_DIR/std"
LOCK_DIR="$INSTALL_DIR.install-lock"
mkdir "$LOCK_DIR" 2>/dev/null || fail "Another install may be running ($LOCK_DIR). If it was interrupted, inspect the directory before retrying."
TMP_DIR=''; STD_TMP_DIR=''; STD_LOCK_DIR=''
ACTIVATING=false; STD_ACTIVATING=false; COMMITTED=false
TMP_DIR=''
ACTIVATING=false; COMMITTED=false
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
# Different custom compiler directories still share the pinned compiler's std.
std_lock="$STD_DIR.install-lock"
mkdir "$std_lock" 2>/dev/null || fail "Another std install may be running ($std_lock). If it was interrupted, inspect the directory before retrying."
STD_LOCK_DIR="$std_lock"
TMP_DIR="$(mktemp -d "$parent/.wave-install.XXXXXX")"
STD_TMP_DIR="$(mktemp -d "$std_parent/.wave-std.XXXXXX")"
info '[1/4] Downloading and verifying packages'
fetch "https://github.com/wavefnd/Wave/releases/download/$wave_version/$wave_name" -o "$TMP_DIR/wave.tar.gz"
verify_hash "$TMP_DIR/wave.tar.gz" "$(jq -r '.digest | sub("^sha256:"; "")' <<< "$wave_asset")"
Expand All @@ -218,9 +216,6 @@ main() {
local package="$TMP_DIR/wave/${wave_name%.tar.gz}"
[[ -f "$package/wavec" && -d "$package/llvm/bin" && -f "$package/std/manifest.json" ]] || fail 'Wave package is missing compiler, LLVM or bundled std.'
cp -R "$package"/. "$TMP_DIR/stage/"
# Stage std beside its destination so activation and recovery stay on one filesystem.
mkdir "$STD_TMP_DIR/stage"
cp -R "$package/std"/. "$STD_TMP_DIR/stage/"
if [[ "$install_vex" == true ]]; then
mkdir "$TMP_DIR/vex"; tar -xzf "$TMP_DIR/vex.tar.gz" -C "$TMP_DIR/vex"
package="$TMP_DIR/vex/${vex_name%.tar.gz}"
Expand All @@ -236,9 +231,6 @@ main() {
if [[ -d "$INSTALL_DIR" ]]; then mv "$INSTALL_DIR" "$TMP_DIR/previous"; fi
ACTIVATING=true
mv "$TMP_DIR/stage" "$INSTALL_DIR"
if [[ -d "$STD_DIR" ]]; then mv "$STD_DIR" "$STD_TMP_DIR/previous"; fi
STD_ACTIVATING=true
mv "$STD_TMP_DIR/stage" "$STD_DIR"
info '[4/4] Checking compiler, default std and runtime'
verify_installation "$INSTALL_DIR" "$WAVE_TARGET" "$install_vex" "$TMP_DIR" \
|| fail 'Installation check failed; restoring the previous installation. Check system prerequisites (glibc/system libraries, Apple Command Line Tools, or a compatible FreeBSD base).'
Expand All @@ -263,21 +255,15 @@ restore_tree() {
fi
}
cleanup() {
local status=$? keep_compiler=false keep_std=false
local status=$? keep_compiler=false
trap - EXIT
if [[ "$COMMITTED" != true ]]; then
# Try both recoveries even if one fails; never discard an unrestored backup.
restore_tree "$STD_ACTIVATING" "$STD_DIR" "$STD_TMP_DIR" || keep_std=true
restore_tree "$ACTIVATING" "$INSTALL_DIR" "$TMP_DIR" || keep_compiler=true
fi
if [[ "$keep_std" == true || "$keep_compiler" == true ]]; then status=1; fi
if [[ -n "$STD_TMP_DIR" && "$keep_std" == false ]]; then
rm -rf "$STD_TMP_DIR" || status=1
fi
if [[ "$keep_compiler" == true ]]; then status=1; fi
if [[ -n "$TMP_DIR" && "$keep_compiler" == false ]]; then
rm -rf "$TMP_DIR" || status=1
fi
if [[ -n "$STD_LOCK_DIR" ]]; then rmdir "$STD_LOCK_DIR" 2>/dev/null || true; fi
rmdir "$LOCK_DIR" 2>/dev/null || true
exit "$status"
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/playground/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const WAVE_VERSION = '0.2.1-pre-beta'
export const WAVE_VERSION = '0.0.1-alpha'
export const MAX_SOURCE_BYTES = 32768

export function diagnosticText(text: string): string {
Expand Down
Loading
Loading