Skip to content

Commit 226aa6a

Browse files
authored
Merge pull request #143 from SteveL-MSFT/cross-build
Cross build
2 parents 4817663 + e7efbb1 commit 226aa6a

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"rust-analyzer.linkedProjects": [
33
"./dsc/Cargo.toml",
44
"./dsc_lib/Cargo.toml",
5-
"./env/Cargo.toml",
65
"./ntreg/Cargo.toml",
76
"./ntstatuserror/Cargo.toml",
87
"./ntuserinfo/Cargo.toml",

build.ps1

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
param(
55
[switch]$Release,
6-
[ValidateSet('none','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc')]
7-
$architecture = 'none',
6+
[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')]
7+
$architecture = 'current',
88
[switch]$Clippy,
99
[switch]$Test
1010
)
@@ -73,21 +73,22 @@ if ($IsWindows -and !(Get-Command 'link.exe' -ErrorAction Ignore)) {
7373

7474
## Create the output folder
7575
$configuration = $Release ? 'release' : 'debug'
76-
$target = Join-Path $PSScriptRoot 'bin' $configuration
77-
if (Test-Path $target) {
78-
Remove-Item $target -Recurse -ErrorAction Stop
79-
}
80-
New-Item -ItemType Directory $target > $null
81-
8276
$flags = @($Release ? '-r' : $null)
83-
if ($architecture -ne 'none') {
77+
if ($architecture -eq 'current') {
78+
$path = ".\target\$configuration"
79+
$target = Join-Path $PSScriptRoot 'bin' $configuration
80+
}
81+
else {
8482
$flags += '--target'
8583
$flags += $architecture
8684
$path = ".\target\$architecture\$configuration"
85+
$target = Join-Path $PSScriptRoot 'bin' $architecture $configuration
8786
}
88-
else {
89-
$path = ".\target\$configuration"
87+
88+
if (Test-Path $target) {
89+
Remove-Item $target -Recurse -ErrorAction Stop
9090
}
91+
New-Item -ItemType Directory $target > $null
9192

9293
$windows_projects = @("pal", "ntreg", "ntstatuserror", "ntuserinfo", "registry")
9394
$projects = @("dsc_lib", "dsc", "osinfo", "test_group_resource", "y2j", "powershellgroup")
@@ -100,7 +101,7 @@ if ($IsWindows) {
100101
$failed = $false
101102
foreach ($project in $projects) {
102103
## Build format_json
103-
Write-Host -ForegroundColor Cyan "Building $project ..."
104+
Write-Host -ForegroundColor Cyan "Building $project ... for $architecture"
104105
try {
105106
Push-Location "$PSScriptRoot/$project" -ErrorAction Stop
106107

@@ -146,6 +147,8 @@ if ($failed) {
146147
exit 1
147148
}
148149

150+
Copy-Item $PSScriptRoot/tools/add-path.ps1 $target -Force -ErrorAction Ignore
151+
149152
$relative = Resolve-Path $target -Relative
150153
Write-Host -ForegroundColor Green "`nEXE's are copied to $target ($relative)"
151154

tools/add-path.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
# This script will add the current directory to the PATH environment variable
5+
# for the current user. This is useful for development purposes.
6+
7+
$pathSeparator = [System.IO.Path]::PathSeparator
8+
$paths = $env:PATH.Split($pathSeparator)
9+
if (-not $paths -contains $PWD) {
10+
$env:PATH = $PWD + $pathSeparator + $env:PATH
11+
Write-Host -ForegroundColor Green "Added $PWD to PATH"
12+
}

0 commit comments

Comments
 (0)