From 6458ec6abebb2289a3ee42d9ffcb3713c3193b5c Mon Sep 17 00:00:00 2001 From: jamie Date: Sun, 13 Sep 2026 21:49:40 +0100 Subject: [PATCH] feat(linux): add --sysroot plumbing for bundled toolchains (#224) * feat(linux): add --sysroot plumbing for bundled toolchains * fix(linux): clear cached CMAKE_SYSROOT when --sysroot is omitted * fix(linux): reject null/empty --sysroot in install command --- Launcher/WiiCompiled.Setup.Linux/BuildRunner.cs | 7 ++++++- Launcher/WiiCompiled.Setup.Linux/Program.cs | 12 +++++++++++- Launcher/local-build.sh | 12 ++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Launcher/WiiCompiled.Setup.Linux/BuildRunner.cs b/Launcher/WiiCompiled.Setup.Linux/BuildRunner.cs index 60e1711..284310a 100644 --- a/Launcher/WiiCompiled.Setup.Linux/BuildRunner.cs +++ b/Launcher/WiiCompiled.Setup.Linux/BuildRunner.cs @@ -13,7 +13,8 @@ internal static class BuildRunner string workspace, string profile, string outputDir, string? baseOutputDir, string? retroDir, string? retroWfcOfflineDir, bool skipRetroWfcPayload, bool forceCleanBuild, string? translatorBin, string? ccBin, string? cxxBin, string? fuseLd, - string? cmakeBin, string? ninjaBin, string? nativePrebuiltDir, IInstallReporter reporter, + string? cmakeBin, string? ninjaBin, string? nativePrebuiltDir, string? sysroot, + IInstallReporter reporter, CancellationToken cancellationToken) { var script = Path.Combine(workspace, "Launcher", "local-build.sh"); @@ -77,6 +78,10 @@ internal static class BuildRunner { startInfo.ArgumentList.Add("--native-prebuilt-dir"); startInfo.ArgumentList.Add(nativePrebuiltDir); } + if (!string.IsNullOrEmpty(sysroot)) + { + startInfo.ArgumentList.Add("--sysroot"); startInfo.ArgumentList.Add(sysroot); + } using var process = new Process { StartInfo = startInfo }; var window = new BuildProgressWindow(reporter, InstallStages.Build, start: 6, end: 96); diff --git a/Launcher/WiiCompiled.Setup.Linux/Program.cs b/Launcher/WiiCompiled.Setup.Linux/Program.cs index 267bb68..9595398 100644 --- a/Launcher/WiiCompiled.Setup.Linux/Program.cs +++ b/Launcher/WiiCompiled.Setup.Linux/Program.cs @@ -143,6 +143,15 @@ internal static class Program retroWfcOfflineDir = cacheDir; } + var sysroot = flags.GetValueOrDefault("sysroot"); + // --sysroot explicitly provided (even as bare flag at end of argv, which ParseArgs + // stores as null) must carry a path; omitting --sysroot entirely is fine (local-build.sh + // adds -UCMAKE_SYSROOT to clear any stale cached value from a prior configure). + if (flags.ContainsKey("sysroot") && string.IsNullOrWhiteSpace(sysroot)) + { + throw new ArgumentException("--sysroot requires a non-empty directory path."); + } + await BuildRunner.RunAsync( workspace, profile, installDir, baseInstallDir, retroDir, @@ -156,6 +165,7 @@ internal static class Program flags.GetValueOrDefault("cmake"), flags.GetValueOrDefault("ninja"), flags.GetValueOrDefault("native-prebuilt-dir"), + sysroot, reporter, token); reporter.Progress(InstallStages.Shortcuts, "Creating shortcuts", 98); @@ -324,7 +334,7 @@ internal static class Program {--download-retro-wfc-payload | --skip-retro-wfc-payload}] [--force-clean-build] [--translator-bin PATH] [--disc-tool-bin PATH] [--cc PATH] [--cxx PATH] [--fuse-ld NAME_OR_PATH] [--cmake PATH] [--ninja PATH] - [--native-prebuilt-dir DIR] [--progress-json] [--workspace DIR] + [--native-prebuilt-dir DIR] [--sysroot PATH] [--progress-json] [--workspace DIR] uninstall launch-base launch-retro diff --git a/Launcher/local-build.sh b/Launcher/local-build.sh index 7d9989d..bdca15e 100755 --- a/Launcher/local-build.sh +++ b/Launcher/local-build.sh @@ -65,6 +65,7 @@ translator_dll_override="" translator_bin_override="" fuse_ld_override="" native_prebuilt_dir="" +sysroot="" usage() { cat <<'EOF' @@ -87,6 +88,8 @@ Usage: local-build.sh --output-dir DIR [options] --translator-bin PATH Self-contained Translator.Cli executable (skips building AND needs no dotnet at all) --native-prebuilt-dir DIR Precompiled aurora/third-party package (see Prepare-NativePrebuilt.sh); skips compiling aurora-main from source entirely + --sysroot PATH Passed to CMake as -DCMAKE_SYSROOT: where the compiler resolves + standard headers/startup files EOF } @@ -110,6 +113,7 @@ while [[ $# -gt 0 ]]; do --translator-dll) translator_dll_override=$2; shift 2 ;; --translator-bin) translator_bin_override=$2; shift 2 ;; --native-prebuilt-dir) native_prebuilt_dir=$2; shift 2 ;; + --sysroot) sysroot=$2; shift 2 ;; -h|--help) usage; exit 0 ;; *) fail "unknown argument: $1" ;; esac @@ -414,6 +418,14 @@ fi if [[ -n "$native_prebuilt_dir" ]]; then configure_args+=(-DMKW_NATIVE_PREBUILT_DIR="$native_prebuilt_dir") fi +if [[ -n "$sysroot" ]]; then + configure_args+=(-DCMAKE_SYSROOT="$sysroot") +else + # Explicitly clear any cached CMAKE_SYSROOT from a prior configure so an + # incremental build that transitions from one sysroot to none does not + # silently keep the stale cached path. + configure_args+=(-UCMAKE_SYSROOT) +fi log_step configure-native "Configuring the native toolchain" "$cmake_bin" "${configure_args[@]}"