From 60e0f15cf7d4a559485b09190433ac9c6278376b Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 7 Jan 2024 13:02:42 +0100 Subject: [PATCH] cross-arch windows compile now works on linux --- .gitignore | 4 ++++ build.py | 6 ++++-- docs/Building.md | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 36771adcb..aabee8220 100644 --- a/.gitignore +++ b/.gitignore @@ -385,3 +385,7 @@ Output/ # Rust Android Compilation Rust/MelonBootstrap/jniLibs/ + +# cargo-xwin SDK cache dirs. cargo-xwin is a tool for cross-compiling Rust projects for Windows on Linux. +# it (stupdily) uses the same cache location for each architecture. The build script will store this in .cache +.cache/ \ No newline at end of file diff --git a/build.py b/build.py index 06817369f..295a11daf 100644 --- a/build.py +++ b/build.py @@ -87,14 +87,16 @@ def build(target: str): os.system(DotnetCommand) # fully construct Cargo Command - xwin = IsLinux and target == "win64" + xwin = IsLinux and target == "win64" or target == "win32" command = CargoCommand command = command.replace("--target=", "--target={}".format(targets[target])) if xwin: + os.environ["XWIN_CACHE_DIR"] = os.path.join(".cache", "x64") command = command.replace("cargo", "cargo xwin") if target == "win32": os.environ["XWIN_ARCH"] = "x86" - os.environ["XWIN_VERSION"] = "17" + os.environ["XWIN_CACHE_DIR"] = os.path.join(".cache", "x86") + print(command) diff --git a/docs/Building.md b/docs/Building.md index 7270a35d6..db021e4b8 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -34,8 +34,8 @@ to build the rust parts, you can simply type `cargo build`, with the optional `- The available architectures are: -* 64bit Windows: `--target=x86_64-pc-windows-msvc` (Bootstrap) & `--target=x86_64-pc-windows-gnu` (Proxy) -* 32bit Windows: `--target=i686-pc-windows-msvc` (Bootstrap) & `--target=i686-pc-windows-gnu` (Proxy) +* 64bit Windows: `--target=x86_64-pc-windows-msvc` (Bootstrap) +* 32bit Windows: `--target=i686-pc-windows-msvc` (Bootstrap) * 64bit Linux: `--target=x86_64-unknown-linux-gnu` * 64bit MacOS (not yet): `--target=x86_64-apple-darwin`