mirror of
https://github.com/patchzyy/wiicompiled
synced 2026-09-27 15:21:35 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7caee02c74 |
@@ -103,7 +103,7 @@ function Write-MkwBuildStep([string]$StepId, [string]$Message) {
|
|||||||
function Reset-LocalDirectory([string]$Path) {
|
function Reset-LocalDirectory([string]$Path) {
|
||||||
$full = [IO.Path]::GetFullPath($Path)
|
$full = [IO.Path]::GetFullPath($Path)
|
||||||
$root = [IO.Path]::GetFullPath($Workspace).TrimEnd('\') + '\'
|
$root = [IO.Path]::GetFullPath($Workspace).TrimEnd('\') + '\'
|
||||||
$installRoot = [IO.Path]::GetFullPath((Split-Path -Parent $Workspace)).TrimEnd('\') + '\'
|
$installRoot = [IO.Path]::GetFullPath((Split-Path -Parent $realWorkspace)).TrimEnd('\') + '\'
|
||||||
# The caller-supplied output destinations are legitimate reset targets by
|
# The caller-supplied output destinations are legitimate reset targets by
|
||||||
# definition, wherever the caller placed them: a fresh install's operation
|
# definition, wherever the caller placed them: a fresh install's operation
|
||||||
# scratch lives beside the installation directory rather than inside it.
|
# scratch lives beside the installation directory rather than inside it.
|
||||||
@@ -150,8 +150,15 @@ if ($Profile -eq 'both' -and [string]::IsNullOrWhiteSpace($BaseOutputDirectory))
|
|||||||
if ($Profile -ne 'both' -and -not [string]::IsNullOrWhiteSpace($BaseOutputDirectory)) {
|
if ($Profile -ne 'both' -and -not [string]::IsNullOrWhiteSpace($BaseOutputDirectory)) {
|
||||||
throw '-BaseOutputDirectory is valid only with -Profile both.'
|
throw '-BaseOutputDirectory is valid only with -Profile both.'
|
||||||
}
|
}
|
||||||
|
$realWorkspace = $Workspace.TrimEnd('\')
|
||||||
|
$Workspace = Get-MkwBuildSafePath $realWorkspace 'workspace' 'runtime\CMakeLists.txt'
|
||||||
|
# One spelling of the workspace, so the staged Code.pul check below can't copy a file onto itself.
|
||||||
|
if (-not [string]::IsNullOrWhiteSpace($RetroRewindPackageDirectory) -and
|
||||||
|
$RetroRewindPackageDirectory.StartsWith($realWorkspace + '\', [StringComparison]::OrdinalIgnoreCase)) {
|
||||||
|
$RetroRewindPackageDirectory = $Workspace + $RetroRewindPackageDirectory.Substring($realWorkspace.Length)
|
||||||
|
}
|
||||||
$translator = Join-Path $Toolkit 'Translator\Translator.Cli.exe'
|
$translator = Join-Path $Toolkit 'Translator\Translator.Cli.exe'
|
||||||
$toolchain = Get-MkwShellSafeToolchainRoot $Toolkit
|
$toolchain = Get-MkwBuildSafePath $Toolkit 'toolchain' 'CMake\bin\cmake.exe'
|
||||||
$cmake = Join-Path $toolchain 'CMake\bin\cmake.exe'
|
$cmake = Join-Path $toolchain 'CMake\bin\cmake.exe'
|
||||||
$ninja = Join-Path $toolchain 'Ninja\ninja.exe'
|
$ninja = Join-Path $toolchain 'Ninja\ninja.exe'
|
||||||
$toolchainBin = Join-Path $toolchain 'llvm-mingw\bin'
|
$toolchainBin = Join-Path $toolchain 'llvm-mingw\bin'
|
||||||
|
|||||||
@@ -40,41 +40,48 @@ function Get-MkwToolchainPath([string]$ToolchainRoot) {
|
|||||||
) -join ';')
|
) -join ';')
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-MkwShellSafeToolchainRoot([string]$ToolchainRoot) {
|
function Get-MkwBuildSafePath([string]$Path, [string]$Kind, [string]$MarkerFile) {
|
||||||
if ([string]::IsNullOrWhiteSpace($ToolchainRoot)) { throw 'A toolchain root is required.' }
|
<#
|
||||||
$full = [IO.Path]::GetFullPath($ToolchainRoot)
|
$Path, or a junction to it whose path is plain ASCII. cmd.exe, Ninja response files and the
|
||||||
|
compiler each have their own quoting rules, so a path outside this allowlist ('&', '%', an
|
||||||
|
apostrophe, non-ASCII...) is never handed to the native build at all. $MarkerFile is a file
|
||||||
|
that must exist under a live junction.
|
||||||
|
#>
|
||||||
|
if ([string]::IsNullOrWhiteSpace($Path)) { throw "A $Kind path is required." }
|
||||||
|
$full = [IO.Path]::GetFullPath($Path)
|
||||||
# A drive root keeps its separator: "C:" is relative to the current directory on that drive.
|
# A drive root keeps its separator: "C:" is relative to the current directory on that drive.
|
||||||
if ($full -ne [IO.Path]::GetPathRoot($full)) { $full = $full.TrimEnd('\') }
|
if ($full -ne [IO.Path]::GetPathRoot($full)) { $full = $full.TrimEnd('\') }
|
||||||
if ($full -notmatch '[()&^%!]') { return $full }
|
if ($full -cmatch '^[A-Za-z0-9 ._\\:-]+$') { return $full }
|
||||||
|
|
||||||
$sha = [Security.Cryptography.SHA256]::Create()
|
$sha = [Security.Cryptography.SHA256]::Create()
|
||||||
try {
|
try {
|
||||||
$bytes = $sha.ComputeHash([Text.Encoding]::UTF8.GetBytes($full.ToLowerInvariant()))
|
$bytes = $sha.ComputeHash([Text.Encoding]::UTF8.GetBytes($full.ToLowerInvariant()))
|
||||||
} finally { $sha.Dispose() }
|
} finally { $sha.Dispose() }
|
||||||
$linkName = 'toolchain-' + ((($bytes[0..7]) | ForEach-Object { $_.ToString('x2') }) -join '')
|
$linkName = "$Kind-" + ((($bytes[0..7]) | ForEach-Object { $_.ToString('x2') }) -join '')
|
||||||
|
|
||||||
$failures = @()
|
$failures = @()
|
||||||
foreach ($base in @($env:ProgramData, $env:PUBLIC)) {
|
foreach ($base in @($env:ProgramData, $env:PUBLIC)) {
|
||||||
if ([string]::IsNullOrWhiteSpace($base) -or $base -match '[()&^%! ]') { continue }
|
if ([string]::IsNullOrWhiteSpace($base) -or $base -cnotmatch '^[A-Za-z0-9._\\:-]+$') { continue }
|
||||||
$link = Join-Path (Join-Path $base 'WiiCompiled') $linkName
|
$link = Join-Path (Join-Path $base 'WiiCompiled') $linkName
|
||||||
try {
|
try {
|
||||||
[IO.Directory]::CreateDirectory((Split-Path -Parent $link)) | Out-Null
|
[IO.Directory]::CreateDirectory((Split-Path -Parent $link)) | Out-Null
|
||||||
# The name already identifies the target, so an existing junction that still resolves is
|
# The name already identifies the target, so an existing junction that still resolves is
|
||||||
# this one; only a broken leftover is replaced. Directory.Delete removes the reparse
|
# this one; only a broken leftover is replaced. Directory.Delete removes the reparse
|
||||||
# point itself, where Remove-Item -Recurse would delete the toolchain it points at.
|
# point itself, where Remove-Item -Recurse would delete the tree it points at.
|
||||||
if (-not (Test-Path -LiteralPath (Join-Path $link 'CMake\bin\cmake.exe') -PathType Leaf)) {
|
if (-not (Test-Path -LiteralPath (Join-Path $link $MarkerFile) -PathType Leaf)) {
|
||||||
if (Test-Path -LiteralPath $link) { [IO.Directory]::Delete($link) }
|
if (Test-Path -LiteralPath $link) { [IO.Directory]::Delete($link) }
|
||||||
New-Item -ItemType Junction -Path $link -Target $full -ErrorAction Stop | Out-Null
|
New-Item -ItemType Junction -Path $link -Target $full -ErrorAction Stop | Out-Null
|
||||||
}
|
}
|
||||||
Write-Host "MKWCBUILD: Building through $link, because $full contains characters cmd.exe cannot parse"
|
Write-Host "MKWCBUILD: Building the $Kind through $link, because $full contains characters the native build cannot quote reliably"
|
||||||
return $link
|
return $link
|
||||||
} catch {
|
} catch {
|
||||||
$failures += "$link ($($_.Exception.Message))"
|
$failures += "$link ($($_.Exception.Message))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw ("The toolchain path $full contains a character (one of ( ) & ^ % !) that the compiler " +
|
Write-Host ("MKWCBUILD: Warning: no junction to $full could be created (" + ($failures -join '; ') +
|
||||||
'cannot be invoked through, and no junction to it could be created: ' + ($failures -join '; ') +
|
'); building from the original path, which may fail. Installing to a path of plain ' +
|
||||||
'. Install to a path without those characters.')
|
'letters, digits and spaces avoids this.')
|
||||||
|
return $full
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-MkwProjectPins([string]$ProjectFile) {
|
function Get-MkwProjectPins([string]$ProjectFile) {
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
|||||||
message(FATAL_ERROR "WiiCompiled only supports Release builds")
|
message(FATAL_ERROR "WiiCompiled only supports Release builds")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Ninja writes Windows-quoted response files; the GNU clang driver otherwise reads them POSIX-style.
|
||||||
|
if(CMAKE_HOST_WIN32)
|
||||||
|
foreach(_mkw_lang C CXX)
|
||||||
|
set(CMAKE_${_mkw_lang}_RESPONSE_FILE_LINK_FLAG "--rsp-quoting=windows @")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
option(MKW_BUILD_PRODUCTS "Build translated WiiCompiled product targets" ON)
|
option(MKW_BUILD_PRODUCTS "Build translated WiiCompiled product targets" ON)
|
||||||
|
|
||||||
# Preprocessor definitions that belong to this project's own code (the runtime,
|
# Preprocessor definitions that belong to this project's own code (the runtime,
|
||||||
|
|||||||
Reference in New Issue
Block a user