Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross build #143

Merged
merged 2 commits into from
Aug 4, 2023
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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 15 additions & 12 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

param(
[switch]$Release,
[ValidateSet('none','aarch64-pc-windows-msvc','x86_64-pc-windows-msvc')]
$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
)
Expand Down Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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)"

Expand Down
12 changes: 12 additions & 0 deletions tools/add-path.ps1
Original file line number Diff line number Diff line change
@@ -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"
}