From dacaeafc56cbe5ff44ac95baed0a1e17a6b0473e Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 4 Aug 2023 13:45:23 -0700 Subject: [PATCH 1/2] enable building for more archs --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index ebe715a9..351bb97d 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ param( [switch]$Release, - [ValidateSet('none','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc')] + [ValidateSet('none','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc','aarch64-apple-darwin','aarch64-unknown-linux-gnu','aarch64-unknown-linux-musl','x86_64-unknown-linux-gnu','x86_64-unknown-linux-musl')] $architecture = 'none', [switch]$Clippy, [switch]$Test From e7efbb1bb0ff591a0080cc459e6a162c0c45e1b8 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 4 Aug 2023 14:31:47 -0700 Subject: [PATCH 2/2] enable building for more archs --- .vscode/settings.json | 1 - build.ps1 | 27 +++++++++++++++------------ tools/add-path.ps1 | 12 ++++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 tools/add-path.ps1 diff --git a/.vscode/settings.json b/.vscode/settings.json index 69cafc5b..1411786d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,6 @@ "rust-analyzer.linkedProjects": [ "./dsc/Cargo.toml", "./dsc_lib/Cargo.toml", - "./env/Cargo.toml", "./ntreg/Cargo.toml", "./ntstatuserror/Cargo.toml", "./ntuserinfo/Cargo.toml", diff --git a/build.ps1 b/build.ps1 index 351bb97d..8968c867 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,8 +3,8 @@ param( [switch]$Release, - [ValidateSet('none','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc','aarch64-apple-darwin','aarch64-unknown-linux-gnu','aarch64-unknown-linux-musl','x86_64-unknown-linux-gnu','x86_64-unknown-linux-musl')] - $architecture = 'none', + [ValidateSet('current','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc','aarch64-apple-darwin','x86_64-apple-darwin','aarch64-unknown-linux-gnu','aarch64-unknown-linux-musl','x86_64-unknown-linux-gnu','x86_64-unknown-linux-musl')] + $architecture = 'current', [switch]$Clippy, [switch]$Test ) @@ -73,21 +73,22 @@ if ($IsWindows -and !(Get-Command 'link.exe' -ErrorAction Ignore)) { ## Create the output folder $configuration = $Release ? 'release' : 'debug' -$target = Join-Path $PSScriptRoot 'bin' $configuration -if (Test-Path $target) { - Remove-Item $target -Recurse -ErrorAction Stop -} -New-Item -ItemType Directory $target > $null - $flags = @($Release ? '-r' : $null) -if ($architecture -ne 'none') { +if ($architecture -eq 'current') { + $path = ".\target\$configuration" + $target = Join-Path $PSScriptRoot 'bin' $configuration +} +else { $flags += '--target' $flags += $architecture $path = ".\target\$architecture\$configuration" + $target = Join-Path $PSScriptRoot 'bin' $architecture $configuration } -else { - $path = ".\target\$configuration" + +if (Test-Path $target) { + Remove-Item $target -Recurse -ErrorAction Stop } +New-Item -ItemType Directory $target > $null $windows_projects = @("pal", "ntreg", "ntstatuserror", "ntuserinfo", "registry") $projects = @("dsc_lib", "dsc", "osinfo", "test_group_resource", "y2j", "powershellgroup") @@ -100,7 +101,7 @@ if ($IsWindows) { $failed = $false foreach ($project in $projects) { ## Build format_json - Write-Host -ForegroundColor Cyan "Building $project ..." + Write-Host -ForegroundColor Cyan "Building $project ... for $architecture" try { Push-Location "$PSScriptRoot/$project" -ErrorAction Stop @@ -146,6 +147,8 @@ if ($failed) { exit 1 } +Copy-Item $PSScriptRoot/tools/add-path.ps1 $target -Force -ErrorAction Ignore + $relative = Resolve-Path $target -Relative Write-Host -ForegroundColor Green "`nEXE's are copied to $target ($relative)" diff --git a/tools/add-path.ps1 b/tools/add-path.ps1 new file mode 100644 index 00000000..48b55f74 --- /dev/null +++ b/tools/add-path.ps1 @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# This script will add the current directory to the PATH environment variable +# for the current user. This is useful for development purposes. + +$pathSeparator = [System.IO.Path]::PathSeparator +$paths = $env:PATH.Split($pathSeparator) +if (-not $paths -contains $PWD) { + $env:PATH = $PWD + $pathSeparator + $env:PATH + Write-Host -ForegroundColor Green "Added $PWD to PATH" +}