Fri, 19 Dec 2025 23:02:38 +0100
add powershell build script template
# ------------------------- # Utility functions # ------------------------- function Is-Platform { param([string]$Name) return $PLATFORM -contains $Name } function Not-IsPlatform { param([string]$Name) return -not ($PLATFORM -contains $Name) } # ------------------------- # Platform (fixed) # ------------------------- Write-Host "detect platform... windows" $PLATFORM = @('windows') $PLATFORM_NAME = 'windows' # ------------------------- # Result directories # ------------------------- New-Item -ItemType Directory -Force -Path result | Out-Null $result_dir = (Resolve-Path result).Path $configure_log = "configure.log" $compile_log = "compile.log" $check_log = "check.log" $result_file = Join-Path $result_dir "result.json" "[" | Out-File -FilePath $result_file -Encoding utf8 # ------------------------- # Source directory # ------------------------- Set-Location src {{ $nbuild := len .Build }} {{ range $i, $build := .Build}} # Build isplatform="{{ .IsPlatform }}" not="{{ .NotPlatform }}" while ($true) { $log_dir = Join-Path $result_dir "build{{$i}}" New-Item -ItemType Directory -Force -Path $log_dir | Out-Null if (-not $?) { Write-Error "failed to create log dir $log_dir" exit 1 } {{- if .IsPlatform}} if (Not-IsPlatform "{{ $build.IsPlatform }}") { break } {{- end}} {{- range $build.NotList}} if (Is-Platform "{{.}}") { break } {{- end}} # ------------------------- # configure # ------------------------- $configure = $null {{- if $build.Configure}} @" {{ $build.Configure }} "@ | Out-File uwbuild-configure.ps1 -Encoding utf8 .\uwbuild-configure.ps1 *> (Join-Path $log_dir $configure_log) $configure = $LASTEXITCODE {{- end}} # ------------------------- # compile # ------------------------- $compile = $null {{- if $build.Compile}} @" {{ $build.Compile }} "@ | Out-File uwbuild-compile.ps1 -Encoding utf8 .\uwbuild-compile.ps1 *> (Join-Path $log_dir $compile_log) $compile = $LASTEXITCODE {{- end}} # ------------------------- # check # ------------------------- $check = $null {{- if $build.Check}} @" {{ $build.Check }} "@ | Out-File uwbuild-check.ps1 -Encoding utf8 .\uwbuild-check.ps1 *> (Join-Path $log_dir $check_log) $check = $LASTEXITCODE {{- end}} # ------------------------- # write result # ------------------------- Add-Content $result_file "{ `"build`": `"{{$i}}`"," {{- if $build.Name}} Add-Content $result_file " `"name`": `"{{$build.Name}}`"," {{- end}} if ($null -ne $configure) { Add-Content $result_file " `"configure`": `"$configure`"," } if ($null -ne $compile) { Add-Content $result_file " `"compile`": `"$compile`"," } if ($null -ne $check) { Add-Content $result_file " `"check`": `"$check`"" } {{- if eq $i (sub $nbuild 1)}} Add-Content $result_file "}" {{ else }} Add-Content $result_file "}," {{- end}} break } # End Build {{ end}} "]" | Add-Content $result_file