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
This commit is contained in:
jamie authored and GitHub committed 2026-09-13 22:49:40 +02:00
1 parent 209405dfb7
commit 6458ec6abe
3 files changed
+29 -2

No files matched your search

@@ -13,7 +13,8 @@ internal static class BuildRunner
string workspace, string profile, string outputDir, string? baseOutputDir, string workspace, string profile, string outputDir, string? baseOutputDir,
string? retroDir, string? retroWfcOfflineDir, bool skipRetroWfcPayload, string? retroDir, string? retroWfcOfflineDir, bool skipRetroWfcPayload,
bool forceCleanBuild, string? translatorBin, string? ccBin, string? cxxBin, string? fuseLd, 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) CancellationToken cancellationToken)
{ {
var script = Path.Combine(workspace, "Launcher", "local-build.sh"); 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); 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 }; using var process = new Process { StartInfo = startInfo };
var window = new BuildProgressWindow(reporter, InstallStages.Build, start: 6, end: 96); var window = new BuildProgressWindow(reporter, InstallStages.Build, start: 6, end: 96);
+11 -1
View File
@@ -143,6 +143,15 @@ internal static class Program
retroWfcOfflineDir = cacheDir; 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( await BuildRunner.RunAsync(
workspace, profile, installDir, baseInstallDir, workspace, profile, installDir, baseInstallDir,
retroDir, retroDir,
@@ -156,6 +165,7 @@ internal static class Program
flags.GetValueOrDefault("cmake"), flags.GetValueOrDefault("cmake"),
flags.GetValueOrDefault("ninja"), flags.GetValueOrDefault("ninja"),
flags.GetValueOrDefault("native-prebuilt-dir"), flags.GetValueOrDefault("native-prebuilt-dir"),
sysroot,
reporter, token); reporter, token);
reporter.Progress(InstallStages.Shortcuts, "Creating shortcuts", 98); reporter.Progress(InstallStages.Shortcuts, "Creating shortcuts", 98);
@@ -324,7 +334,7 @@ internal static class Program
{--download-retro-wfc-payload | --skip-retro-wfc-payload}] {--download-retro-wfc-payload | --skip-retro-wfc-payload}]
[--force-clean-build] [--translator-bin PATH] [--disc-tool-bin PATH] [--force-clean-build] [--translator-bin PATH] [--disc-tool-bin PATH]
[--cc PATH] [--cxx PATH] [--fuse-ld NAME_OR_PATH] [--cmake PATH] [--ninja 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 uninstall
launch-base launch-base
launch-retro launch-retro
+12
View File
@@ -65,6 +65,7 @@ translator_dll_override=""
translator_bin_override="" translator_bin_override=""
fuse_ld_override="" fuse_ld_override=""
native_prebuilt_dir="" native_prebuilt_dir=""
sysroot=""
usage() { usage() {
cat <<'EOF' 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) --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); --native-prebuilt-dir DIR Precompiled aurora/third-party package (see Prepare-NativePrebuilt.sh);
skips compiling aurora-main from source entirely skips compiling aurora-main from source entirely
--sysroot PATH Passed to CMake as -DCMAKE_SYSROOT: where the compiler resolves
standard headers/startup files
EOF EOF
} }
@@ -110,6 +113,7 @@ while [[ $# -gt 0 ]]; do
--translator-dll) translator_dll_override=$2; shift 2 ;; --translator-dll) translator_dll_override=$2; shift 2 ;;
--translator-bin) translator_bin_override=$2; shift 2 ;; --translator-bin) translator_bin_override=$2; shift 2 ;;
--native-prebuilt-dir) native_prebuilt_dir=$2; shift 2 ;; --native-prebuilt-dir) native_prebuilt_dir=$2; shift 2 ;;
--sysroot) sysroot=$2; shift 2 ;;
-h|--help) usage; exit 0 ;; -h|--help) usage; exit 0 ;;
*) fail "unknown argument: $1" ;; *) fail "unknown argument: $1" ;;
esac esac
@@ -414,6 +418,14 @@ fi
if [[ -n "$native_prebuilt_dir" ]]; then if [[ -n "$native_prebuilt_dir" ]]; then
configure_args+=(-DMKW_NATIVE_PREBUILT_DIR="$native_prebuilt_dir") configure_args+=(-DMKW_NATIVE_PREBUILT_DIR="$native_prebuilt_dir")
fi 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" log_step configure-native "Configuring the native toolchain"
"$cmake_bin" "${configure_args[@]}" "$cmake_bin" "${configure_args[@]}"