From bd12087cc3ab64baeb30b0d35ed93261c31e94d1 Mon Sep 17 00:00:00 2001 From: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:05:08 +0200 Subject: [PATCH] Fix native build path quoting (#300) --- Launcher/LocalBuild.ps1 | 3 ++- Launcher/NativeBuildFlags.ps1 | 3 ++- Launcher/local-build.sh | 4 +++- Launcher/macos/setup.command | 19 +++++++++++++++---- aurora-main/cmake/AuroraCopyRuntimeDLLs.cmake | 2 ++ runtime/CMakeLists.txt | 6 ++++++ runtime/cmake/PublicProducts.cmake | 12 ++++++------ 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Launcher/LocalBuild.ps1 b/Launcher/LocalBuild.ps1 index dbfc8db..2a36909 100644 --- a/Launcher/LocalBuild.ps1 +++ b/Launcher/LocalBuild.ps1 @@ -429,7 +429,8 @@ try { } $redist = Join-Path $Toolkit 'Redist' if (Test-Path -LiteralPath $redist -PathType Container) { - Copy-Item -Path (Join-Path $redist '*.dll') -Destination $Destination -Force + Get-ChildItem -LiteralPath $redist -Filter '*.dll' -File | + Copy-Item -Destination $Destination -Force } foreach ($name in @('config','wii_bootstrap')) { $directory = Join-Path $build $name diff --git a/Launcher/NativeBuildFlags.ps1 b/Launcher/NativeBuildFlags.ps1 index 7d88f4b..00bb12e 100644 --- a/Launcher/NativeBuildFlags.ps1 +++ b/Launcher/NativeBuildFlags.ps1 @@ -145,7 +145,8 @@ function Invoke-Checked([string]$FilePath, [string[]]$Arguments, [string]$Descri else { Write-Host "${LogPrefix}: $Description" } $quotedArguments = @($Arguments | ForEach-Object { if ($_.Contains('"')) { throw "A native build argument contains an unsupported quote: $_" } - '"' + $_ + '"' + # Backslashes directly before the closing quote would otherwise escape it. + '"' + ($_ -replace '(\\+)$', '$1$1') + '"' }) if ($WaitForProcessTree) { $process = Start-Process -FilePath $FilePath -ArgumentList $quotedArguments ` diff --git a/Launcher/local-build.sh b/Launcher/local-build.sh index cdc81eb..09b9544 100755 --- a/Launcher/local-build.sh +++ b/Launcher/local-build.sh @@ -447,7 +447,9 @@ if [[ "$cc_bin" == */* ]]; then configure_args+=(-DCMAKE_ASM_COMPILER="$cc_bin") fi if [[ -n "$fuse_ld_override" ]]; then - configure_args+=(-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=$fuse_ld_override") + # CMAKE_EXE_LINKER_FLAGS is one string that CMake pastes into the shell link command. + printf -v fuse_ld_quoted '%q' "$fuse_ld_override" + configure_args+=(-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=$fuse_ld_quoted") fi if [[ -n "$native_prebuilt_dir" ]]; then configure_args+=(-DMKW_NATIVE_PREBUILT_DIR="$native_prebuilt_dir") diff --git a/Launcher/macos/setup.command b/Launcher/macos/setup.command index b3a31d0..53dd4e2 100755 --- a/Launcher/macos/setup.command +++ b/Launcher/macos/setup.command @@ -11,7 +11,13 @@ workspace="$support_root/BuildWorkspace" products="$support_root/Products" fail() { printf 'WiiCompiled Setup: %s\n' "$*" >&2; exit 1; } -notice() { /usr/bin/osascript -e "display dialog \"${1//\"/\\\"}\" buttons {\"OK\"} default button \"OK\" with icon caution" >/dev/null; } +notice() { + /usr/bin/osascript - "$1" >/dev/null <<'APPLESCRIPT' +on run argv + display dialog (item 1 of argv) buttons {"OK"} default button "OK" with icon caution +end run +APPLESCRIPT +} usage() { cat <<'EOF' Usage: setup.command --game IMAGE [--retro-dir DIR] [--install-location {user|applications}] @@ -146,7 +152,7 @@ fi "$workspace/Launcher/local-build-macos.command" "${build_args[@]}" --profile "$profile" --cmake "$cmake_bin" --ninja "$ninja_bin" --translator-bin "$translator" config="$support_root/Config.toml" -toml_string() { printf '%s' "$1" | sed -e 's/\\\\/\\\\\\\\/g' -e 's/"/\\\\"/g'; } +toml_string() { printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'; } set_path() { local key=$1 value=$2 encoded line temporary encoded=$(toml_string "$value"); line="$key = \"$encoded\""; temporary="$config.tmp" @@ -172,8 +178,13 @@ install_app() { local app=$1 [[ -d "$products/$app" ]] || return 0 if [[ "$destination" == /Applications ]]; then - command="mkdir -p /Applications && rm -rf '/Applications/$app' && ditto '$products/$app' '/Applications/$app'" - /usr/bin/osascript -e "do shell script \"$command\" with administrator privileges" + /usr/bin/osascript - "$products/$app" "/Applications/$app" <<'APPLESCRIPT' +on run argv + set sourcePath to quoted form of (item 1 of argv) + set installedPath to quoted form of (item 2 of argv) + do shell script "mkdir -p /Applications && rm -rf " & installedPath & " && /usr/bin/ditto " & sourcePath & " " & installedPath with administrator privileges +end run +APPLESCRIPT else mkdir -p "$destination"; rm -rf "$destination/$app"; /usr/bin/ditto "$products/$app" "$destination/$app" fi diff --git a/aurora-main/cmake/AuroraCopyRuntimeDLLs.cmake b/aurora-main/cmake/AuroraCopyRuntimeDLLs.cmake index b4fa166..66710f0 100644 --- a/aurora-main/cmake/AuroraCopyRuntimeDLLs.cmake +++ b/aurora-main/cmake/AuroraCopyRuntimeDLLs.cmake @@ -15,6 +15,7 @@ function(aurora_copy_runtime_dlls target) add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS + VERBATIM ) endforeach () @@ -30,6 +31,7 @@ function(aurora_copy_runtime_dlls target) if (EXISTS "${_dawn_bin_dir}/${_dll}") add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dawn_bin_dir}/${_dll}" $ + VERBATIM ) endif () endforeach () diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 73bf4d6..ad031ba 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -42,6 +42,12 @@ else() "WiiCompiled supports 64-bit LLVM-MinGW Clang on Windows, native Linux x86_64/aarch64, or Apple Clang on macOS x86_64/arm64") endif() +if(MKW_PLATFORM_WINDOWS) + # CMake and Ninja write response files with Windows quoting, but clang tokenizes them with + # POSIX rules by default, where a bare apostrophe in a path opens a quoted span. + add_link_options(--rsp-quoting=windows) +endif() + if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") message(FATAL_ERROR "WiiCompiled only supports Release builds") endif() diff --git a/runtime/cmake/PublicProducts.cmake b/runtime/cmake/PublicProducts.cmake index 7b8b327..ea821b7 100644 --- a/runtime/cmake/PublicProducts.cmake +++ b/runtime/cmake/PublicProducts.cmake @@ -229,7 +229,7 @@ function(mkw_configure_product target) (MKW_SQLITE_TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR MKW_SQLITE_TARGET_TYPE STREQUAL "MODULE_LIBRARY")) add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ $) + $ $ VERBATIM) endif() if(MKW_PLATFORM_WINDOWS) @@ -263,7 +263,7 @@ function(mkw_configure_product target) endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${runtime_dll_path}" $) + "${runtime_dll_path}" $ VERBATIM) endforeach() endif() @@ -272,7 +272,7 @@ function(mkw_configure_product target) message(FATAL_ERROR "Missing Wii first-run bootstrap payload: ${MKW_WII_BOOTSTRAP_SOURCE_DIR}") endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - "${MKW_WII_BOOTSTRAP_SOURCE_DIR}" "$/wii_bootstrap") + "${MKW_WII_BOOTSTRAP_SOURCE_DIR}" "$/wii_bootstrap" VERBATIM) set(MKW_DSP_COEFFICIENT_ROM "${MKW_RUNTIME_SOURCE_DIR}/assets/dsp/dsp_coef.bin") if(NOT EXISTS "${MKW_DSP_COEFFICIENT_ROM}") @@ -284,7 +284,7 @@ function(mkw_configure_product target) message(FATAL_ERROR "Wii DSP coefficient ROM hash mismatch: ${MKW_DSP_COEFFICIENT_ROM_SHA256}") endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${MKW_DSP_COEFFICIENT_ROM}" "$/dsp_coef.bin") + "${MKW_DSP_COEFFICIENT_ROM}" "$/dsp_coef.bin" VERBATIM) # Aurora imports this portable recipe database into each user's writable # pipeline cache. Keep the upstream filename so its default resourcesPath @@ -296,7 +296,7 @@ function(mkw_configure_product target) endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MKW_INITIAL_PIPELINE_CACHE}" - "$/initial_pipeline_cache.db") + "$/initial_pipeline_cache.db" VERBATIM) # Non-Windows TLS (runtime/src/hle/net/network_ssl.cpp's mbed TLS path) needs a trusted root # CA bundle to verify server certificates against - Windows gets this for free from the OS via @@ -310,7 +310,7 @@ function(mkw_configure_product target) message(FATAL_ERROR "Missing TLS root CA bundle: ${MKW_CA_CERTIFICATE_BUNDLE}") endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${MKW_CA_CERTIFICATE_BUNDLE}" "$/cacert.pem") + "${MKW_CA_CERTIFICATE_BUNDLE}" "$/cacert.pem" VERBATIM) endif() endfunction()