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
25 changes: 4 additions & 21 deletions .github/workflows/windows-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,13 @@ jobs:
version: 0.5.2
- name: Validate and resolve tested compatibility
id: compat
shell: bash
working-directory: ${{ github.workspace }}
run: |
v run "checkout with spaces/scripts/compatibility.vsh" --self-test
v run "checkout with spaces/scripts/doctor.vsh" --self-test
v run "checkout with spaces/scripts/compatibility.vsh" --github-output "$GITHUB_OUTPUT"
working-directory: checkout with spaces
run: v run scripts/check_demo_release.vsh compatibility
- name: Install CI Vulkan runtime
uses: antono2/vulkan/.github/actions/setup-vulkan-ci@04620525bab9fd843ad3b9046171aaff4dfe3d3c
with:
sdk-version: ${{ steps.compat.outputs.ci_sdk }}
artifact-tag: ${{ steps.compat.outputs.ci_runtime }}
- name: Exercise the documented PowerShell bootstrap
shell: powershell
- name: Exercise the Windows bootstrap and V demo setup
working-directory: checkout with spaces
run: |
./scripts/test_windows_setup.ps1
$Cache = Join-Path $env:RUNNER_TEMP 'ImGui compiler with spaces'
./scripts/setup_windows.ps1 -Check -CacheDirectory $Cache
if (Test-Path $Cache) { throw 'Read-only check created the compiler cache' }
./scripts/setup_windows.ps1 -CacheDirectory $Cache
./scripts/setup_windows.ps1 -CacheDirectory $Cache
./scripts/setup_windows.ps1 -CacheDirectory $Cache -PrepareOnly
foreach ($File in @('v_imgui_demo.exe', 'vimgui.dll', 'glfw3.dll')) {
$Artifact = Join-Path 'build\windows-demo' $File
if (-not (Test-Path $Artifact)) { throw "Missing demo artifact: $File" }
}
./scripts/smoke_windows_demo.ps1
run: v run scripts/check_windows_setup.vsh "$env:RUNNER_TEMP\ImGui compiler with spaces"
23 changes: 17 additions & 6 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ From ordinary 64-bit PowerShell in the checkout, run:
powershell -ExecutionPolicy Bypass -File scripts\setup_windows.ps1
```

The helper discovers Visual Studio x64 tools and builds the tested upstream V
compiler in a versioned cache, so a separately installed V compiler is optional.
It prepares isolated V modules, downloads GLFW 3.4 through CMake, checks out the
tested demo and builds it. Use `-Run` to launch after building, `-Check` for
read-only prerequisite checks, or `-PrepareOnly` to prepare only the compiler.
`-CacheDirectory` chooses another compiler-cache location. Existing checkouts
The PowerShell bootstrap discovers Visual Studio x64 tools and builds the
tested upstream V compiler in a versioned cache. V then installs isolated
modules, downloads GLFW 3.4 through CMake, checks out the tested demo and
builds it.

| Option | Effect |
| --- | --- |
| `-Run` | Launch the demo after building. |
| `-Check` | Check native prerequisites without creating a compiler cache. |
| `-PrepareOnly` | Prepare the compiler without building the demo. |
| `-CacheDirectory PATH` | Select a compiler-cache location. |

Existing checkouts
with local changes or wrong revisions are rejected rather than reset. Native
GPU rendering still requires a Vulkan-capable driver and desktop session.

Expand All @@ -81,6 +88,10 @@ After building, check rendering and clean shutdown with a bounded 60-frame run:
powershell -ExecutionPolicy Bypass -File scripts\smoke_windows_demo.ps1
```

If your shell already has V, use `v run scripts/smoke_windows_demo.vsh`
directly. Run it with `--help` for the demo directory, frame count, and
timeout options. The smoke check saves stdout and stderr beside the demo.

Windows CI uses a software Vulkan driver for this smoke test; it does not
establish support for every physical GPU.

Expand Down
38 changes: 38 additions & 0 deletions scripts/check_windows_setup.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Exercise the documented bootstrap and repeat installs in a checkout with spaces.
import os
import tooling

fn bootstrap_script(script string, args []string) ! {
mut invocation := ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script]
invocation << args
tooling.command('powershell.exe', invocation)!
}

fn run(args []string) ! {
if args.len != 1 || args[0] == '' {
return error('Usage: v run scripts/check_windows_setup.vsh COMPILER_CACHE')
}
cache := os.abs_path(args[0])
os.chdir(os.dir(@DIR))!
bootstrap_script('scripts/test_windows_setup.ps1', [])!
bootstrap_script('scripts/setup_windows.ps1', ['-CacheDirectory', cache, '-Check'])!
if os.exists(cache) {
return error('Read-only check created the compiler cache: ${cache}')
}
bootstrap_script('scripts/setup_windows.ps1', ['-CacheDirectory', cache])!
bootstrap_script('scripts/setup_windows.ps1', ['-CacheDirectory', cache])!
bootstrap_script('scripts/setup_windows.ps1', ['-CacheDirectory', cache, '-PrepareOnly'])!
for name in ['v_imgui_demo.exe', 'vimgui.dll', 'glfw3.dll'] {
artifact := os.join_path('build', 'windows-demo', name)
if !os.is_file(artifact) {
return error('Missing demo artifact: ${artifact}')
}
}
// Keep testing the original entry point as well as its new V implementation.
bootstrap_script('scripts/smoke_windows_demo.ps1', [])!
}

run(os.args[1..]) or {
eprintln(err)
exit(1)
}
58 changes: 18 additions & 40 deletions scripts/setup_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,25 @@ Get-WindowsSetupCheckout 'https://github.com/vlang/v.git' $Pins.v $VDirectory
Get-WindowsSetupCheckout 'https://github.com/vlang/vc.git' $Pins.vc (Join-Path $VDirectory 'vc')
Get-WindowsSetupCheckout 'https://github.com/vlang/tccbin.git' $Pins.tcc (Join-Path $VDirectory 'thirdparty\tcc')
$VExecutable = Join-Path $VDirectory 'v.exe'
if (-not (Test-Path -LiteralPath $VExecutable)) {
Push-Location $VDirectory
# Use the pinned bootstrap compiler, regardless of unrelated Clang/GCC
# installations on PATH. The demo itself is compiled with MSVC below.
try { Invoke-WindowsSetupCommand (Join-Path $VDirectory 'makev.bat') @('-tcc', '--local') } finally { Pop-Location }
}
$env:V_BIN = $VExecutable
$env:Path = "$VDirectory;$(Join-Path $env:VULKAN_SDK 'Bin');$env:Path"
if ($PrepareOnly) {
Write-Host "Prepared upstream V compiler: $VExecutable"
return
}
# Keep VPM staging and module installs on the checkout's drive, even when the
# compiler cache or Windows TEMP is elsewhere. The user's VPM directory is retained.
$BuildDirectory = Join-Path $ProjectDirectory 'build'
$env:VMODULES = Join-Path $BuildDirectory 'windows-modules'
$env:VTMP = Join-Path (Join-Path $BuildDirectory '.vtmp') ([Guid]::NewGuid().ToString('N').Substring(0, 8))
New-Item -ItemType Directory -Force -Path $env:VMODULES, $env:VTMP | Out-Null
$ExistingCount = $env:GIT_CONFIG_COUNT
$Count = 0
if ($ExistingCount -and (-not [int]::TryParse($ExistingCount, [ref]$Count) -or $Count -lt 0)) {
throw 'GIT_CONFIG_COUNT must be a nonnegative integer.'
}
$SavedGitEnvironment = @{}
foreach ($Name in @('GIT_CONFIG_COUNT', "GIT_CONFIG_KEY_$Count", "GIT_CONFIG_VALUE_$Count")) {
$SavedGitEnvironment[$Name] = [Environment]::GetEnvironmentVariable($Name, 'Process')
}
Push-Location $ProjectDirectory
$PreviousVexe = $env:VEXE
try {
[Environment]::SetEnvironmentVariable("GIT_CONFIG_KEY_$Count", 'core.longpaths', 'Process')
[Environment]::SetEnvironmentVariable("GIT_CONFIG_VALUE_$Count", 'true', 'Process')
$env:GIT_CONFIG_COUNT = ($Count + 1).ToString()
Install-WindowsSetupModules $ProjectDirectory $env:VMODULES @{}
Invoke-WindowsSetupCommand $VExecutable @('-cc', 'msvc', 'run', 'scripts/check_installed_deps.vsh')
Invoke-WindowsSetupCommand $VExecutable @('-old-compiler', '-check-syntax', 'imgui.v')
$Options = @('-cc', 'msvc', 'run', 'scripts/run_demo.vsh')
if (-not $Run) { $Options += '--build-only' }
# A parent V script can export VEXE pointing at a different compiler and vlib.
$env:VEXE = $null
if (-not (Test-Path -LiteralPath $VExecutable)) {
Push-Location $VDirectory
# Use the pinned TCC checkout to bootstrap V before the MSVC demo build.
try { Invoke-WindowsSetupCommand (Join-Path $VDirectory 'makev.bat') @('-tcc', '--local') } finally { Pop-Location }
}
$env:VEXE = $VExecutable
$env:V_BIN = $VExecutable
$env:Path = "$VDirectory;$(Join-Path $env:VULKAN_SDK 'Bin');$env:Path"
if ($PrepareOnly) {
Write-Host "Prepared upstream V compiler: $VExecutable"
return
}
$Options = @('-cc', 'msvc', 'run', (Join-Path $PSScriptRoot 'setup_windows_demo.vsh'))
if ($Run) { $Options += '--run' }
Invoke-WindowsSetupCommand $VExecutable $Options
} finally {
Pop-Location
foreach ($Name in $SavedGitEnvironment.Keys) {
[Environment]::SetEnvironmentVariable($Name, $SavedGitEnvironment[$Name], 'Process')
}
$env:VEXE = $PreviousVexe
}
66 changes: 66 additions & 0 deletions scripts/setup_windows_demo.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Once Git, the Vulkan SDK, MSVC and V are ready, build the pinned Windows demo.
import os
import rand
import strconv
import tooling

const usage = 'Usage: v run scripts/setup_windows_demo.vsh [--run]'
// Keep the scratch component short for the Windows C compiler and linker.
const scratch_id_length = 8

fn allow_git_long_paths() ! {
configured := os.getenv('GIT_CONFIG_COUNT')
count := if configured == '' {
0
} else {
strconv.atoi(configured) or { return error('GIT_CONFIG_COUNT must be a nonnegative integer.') }
}
if count < 0 || count == max_int {
return error('GIT_CONFIG_COUNT must be a nonnegative integer.')
}
os.setenv('GIT_CONFIG_KEY_${count}', 'core.longpaths', true)
os.setenv('GIT_CONFIG_VALUE_${count}', 'true', true)
os.setenv('GIT_CONFIG_COUNT', (count + 1).str(), true)
}

fn run(args []string) ! {
if args in [['-h'], ['--help']] {
println(usage)
return
}
if args.len > 0 && args != ['--run'] {
return error(usage)
}
if os.user_os() != 'windows' {
return error('Windows demo setup requires Windows and the MSVC x64 toolchain.')
}
allow_git_long_paths()!
root := os.dir(@DIR)
build := os.join_path(root, 'build')
modules := os.join_path(build, 'windows-modules')
scratch_parent := os.join_path(build, '.vtmp')
os.mkdir_all(scratch_parent)!
scratch := os.join_path(scratch_parent, rand.uuid_v4()[..scratch_id_length])
os.mkdir(scratch)!
defer {
os.rmdir_all(scratch) or { eprintln('Could not remove the build scratch directory: ${err}') }
}
// Keep generated files on the checkout drive and leave the user's VPM cache alone.
os.setenv('VMODULES', modules, true)
os.setenv('VTMP', scratch, true)
os.chdir(root)!
tooling.prepare_pinned_modules(root, modules)!
compiler := tooling.compiler()
tooling.command(compiler, ['-cc', 'msvc', 'run', 'scripts/check_installed_deps.vsh'])!
tooling.command(compiler, ['-old-compiler', '-check-syntax', 'imgui.v'])!
mut options := ['-cc', 'msvc', 'run', 'scripts/run_demo.vsh']
if args.len == 0 {
options << '--build-only'
}
tooling.command(compiler, options)!
}

run(os.args[1..]) or {
eprintln(err)
exit(1)
}
48 changes: 22 additions & 26 deletions scripts/smoke_windows_demo.ps1
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
# Renders a bounded GLFW/Vulkan demo and checks its exit status and diagnostics.
# Compatibility entry point for the V smoke check.
[CmdletBinding()]
param(
[string]$DemoDirectory = '',
[ValidateRange(1, 10000)][int]$Frames = 60,
[ValidateRange(1, 300)][int]$TimeoutSeconds = 60
[int]$Frames,
[int]$TimeoutSeconds,
[string]$CacheDirectory = ''
)
$ErrorActionPreference = 'Stop'
if (-not $DemoDirectory) { $DemoDirectory = Join-Path (Split-Path -Parent $PSScriptRoot) 'build\windows-demo' }
$DemoDirectory = [IO.Path]::GetFullPath($DemoDirectory)
$Executable = Join-Path $DemoDirectory 'v_imgui_demo.exe'
if (-not (Test-Path -LiteralPath $Executable)) { throw "Build the demo first with scripts\setup_windows.ps1: $Executable" }
$OutputLog = Join-Path $DemoDirectory 'smoke-stdout.log'
$ErrorLog = Join-Path $DemoDirectory 'smoke-stderr.log'
$PreviousFrames = $env:VIMGUI_SMOKE_FRAMES
$Compiler = $env:V_BIN
if (-not $Compiler) {
$Installed = Get-Command v.exe -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
if ($Installed) { $Compiler = $Installed.Source }
}
if (-not $Compiler) {
& (Join-Path $PSScriptRoot 'setup_windows.ps1') -PrepareOnly -CacheDirectory $CacheDirectory
$Compiler = $env:V_BIN
}
$Arguments = @('run', (Join-Path $PSScriptRoot 'smoke_windows_demo.vsh'))
if ($DemoDirectory) { $Arguments += @('--demo-directory', $DemoDirectory) }
if ($PSBoundParameters.ContainsKey('Frames')) { $Arguments += @('--frames', $Frames.ToString()) }
if ($PSBoundParameters.ContainsKey('TimeoutSeconds')) { $Arguments += @('--timeout-seconds', $TimeoutSeconds.ToString()) }
$PreviousVexe = $env:VEXE
try {
$env:VIMGUI_SMOKE_FRAMES = $Frames.ToString()
$DemoProcess = Start-Process -FilePath $Executable -WorkingDirectory $DemoDirectory -WindowStyle Hidden -PassThru -RedirectStandardOutput $OutputLog -RedirectStandardError $ErrorLog
# Retain the process handle before exit; Windows PowerShell 5 otherwise
# sometimes loses ExitCode when Start-Process redirects output.
$null = $DemoProcess.Handle
if (-not $DemoProcess.WaitForExit($TimeoutSeconds * 1000)) {
Stop-Process -Id $DemoProcess.Id -Force
throw "Windows demo rendering timed out; inspect $OutputLog and $ErrorLog."
}
$Diagnostics = (Get-Content -LiteralPath $OutputLog, $ErrorLog -Raw) -join "`n"
if ($Diagnostics) { Write-Host $Diagnostics }
if ($DemoProcess.ExitCode -ne 0 -or $Diagnostics -match '(?i)VUID-|validation error|segmentation|assert|fatal') {
throw "Windows demo rendering failed (exit $($DemoProcess.ExitCode)); inspect the smoke logs."
}
Write-Host "Windows GLFW/Vulkan demo rendered and shut down after $Frames frames."
$env:VEXE = $Compiler
& $Compiler @Arguments
if ($LASTEXITCODE -ne 0) { throw "Demo smoke check failed with exit code $LASTEXITCODE." }
} finally {
$env:VIMGUI_SMOKE_FRAMES = $PreviousFrames
$env:VEXE = $PreviousVexe
}
Loading
Loading