From bc4215d7d71a88326c5eac65bf97010a89c609ce Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 11:55:27 +0100 Subject: [PATCH 1/8] Fix word in comment --- tools/cross-compiler/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index 1f1dffebb..35dea4be1 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -1,7 +1,7 @@ //! Cross-compiler for the Fornjot build //! //! This tools cross-compiles the Fornjot crates that support that to the -//! targets they support. This is less resource-intense then using a `matrix` in +//! targets they support. This is less resource-intense than using a `matrix` in //! GitHub Actions (which would start one build job per crate and target), and //! allows for the cross-compilation code to be re-used in `justfile`. From 9de2a88a6788adaa95777585dc1a72841735d136 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 11:57:16 +0100 Subject: [PATCH 2/8] Add list of cross-compile targets --- tools/cross-compiler/src/main.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index 35dea4be1..433e8a1f8 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -10,6 +10,7 @@ use std::process::Command; use anyhow::anyhow; fn main() -> anyhow::Result<()> { + let targets = ["wasm32-unknown-unknown"]; let crates = [ "fj", "fj-export", @@ -21,20 +22,22 @@ fn main() -> anyhow::Result<()> { "fj-viewer", ]; - for crate_ in crates { - let mut command = Command::new("cargo"); - command - .arg("build") - .arg("--all-features") - .args(["--target", "wasm32-unknown-unknown"]) - .args(["-p", crate_]) - .env("RUSTFLAGS", "-D warnings"); + for target in targets { + for crate_ in crates { + let mut command = Command::new("cargo"); + command + .arg("build") + .arg("--all-features") + .args(["--target", target]) + .args(["-p", crate_]) + .env("RUSTFLAGS", "-D warnings"); - println!("Running {command:?}"); - let status = command.status()?; + println!("Running {command:?}"); + let status = command.status()?; - if !status.success() { - return Err(anyhow!("Cargo exited with error code: {status}")); + if !status.success() { + return Err(anyhow!("Cargo exited with error code: {status}")); + } } } From 64a2b191399470f278f040296f57fde3144752ad Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 11:58:13 +0100 Subject: [PATCH 3/8] Add `Target` struct --- tools/cross-compiler/src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index 433e8a1f8..d8518e8cc 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -10,7 +10,9 @@ use std::process::Command; use anyhow::anyhow; fn main() -> anyhow::Result<()> { - let targets = ["wasm32-unknown-unknown"]; + let targets = [Target { + triple: "wasm32-unknown-unknown", + }]; let crates = [ "fj", "fj-export", @@ -28,7 +30,7 @@ fn main() -> anyhow::Result<()> { command .arg("build") .arg("--all-features") - .args(["--target", target]) + .args(["--target", target.triple]) .args(["-p", crate_]) .env("RUSTFLAGS", "-D warnings"); @@ -43,3 +45,8 @@ fn main() -> anyhow::Result<()> { Ok(()) } + +struct Target { + /// The target triple + triple: &'static str, +} From cd21ede9da203d3dbc2b1be3951f0389715c2555 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 12:18:43 +0100 Subject: [PATCH 4/8] Specify crates per target --- tools/cross-compiler/src/main.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index d8518e8cc..9acd1a3ae 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -12,20 +12,20 @@ use anyhow::anyhow; fn main() -> anyhow::Result<()> { let targets = [Target { triple: "wasm32-unknown-unknown", + crates: &[ + "fj", + "fj-export", + "fj-interop", + "fj-kernel", + "fj-math", + "fj-operations", + "fj-proc", + "fj-viewer", + ], }]; - let crates = [ - "fj", - "fj-export", - "fj-interop", - "fj-kernel", - "fj-math", - "fj-operations", - "fj-proc", - "fj-viewer", - ]; for target in targets { - for crate_ in crates { + for crate_ in target.crates { let mut command = Command::new("cargo"); command .arg("build") @@ -49,4 +49,7 @@ fn main() -> anyhow::Result<()> { struct Target { /// The target triple triple: &'static str, + + /// The crates that are supported on this target + crates: &'static [&'static str], } From 3df031869c7d0c663fe2a2c687bf5548c2b9bed7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 12:20:10 +0100 Subject: [PATCH 5/8] Add Android target to toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 621f16aee..c4d77713c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] channel = "1.66.0" components = ["rustfmt", "clippy"] -targets = ["wasm32-unknown-unknown"] +targets = ["aarch64-linux-android", "wasm32-unknown-unknown"] From 44e919f0408873d3358d4d7125b30a054e86e735 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 12:20:20 +0100 Subject: [PATCH 6/8] Cross-compile to Android --- tools/cross-compiler/src/main.rs | 40 +++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index 9acd1a3ae..fe0deff49 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -10,19 +10,33 @@ use std::process::Command; use anyhow::anyhow; fn main() -> anyhow::Result<()> { - let targets = [Target { - triple: "wasm32-unknown-unknown", - crates: &[ - "fj", - "fj-export", - "fj-interop", - "fj-kernel", - "fj-math", - "fj-operations", - "fj-proc", - "fj-viewer", - ], - }]; + let targets = [ + Target { + triple: "aarch64-linux-android", + crates: &[ + "fj", + "fj-export", + "fj-interop", + "fj-kernel", + "fj-math", + "fj-operations", + "fj-proc", + ], + }, + Target { + triple: "wasm32-unknown-unknown", + crates: &[ + "fj", + "fj-export", + "fj-interop", + "fj-kernel", + "fj-math", + "fj-operations", + "fj-proc", + "fj-viewer", + ], + }, + ]; for target in targets { for crate_ in target.crates { From a4c5588497a0656c8f8915b910ef45967809992d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 12:22:07 +0100 Subject: [PATCH 7/8] Add iOS target to toolchain --- rust-toolchain.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c4d77713c..5f80075c9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,8 @@ [toolchain] channel = "1.66.0" components = ["rustfmt", "clippy"] -targets = ["aarch64-linux-android", "wasm32-unknown-unknown"] +targets = [ + "aarch64-apple-ios", + "aarch64-linux-android", + "wasm32-unknown-unknown", +] From 14401bcbf39e95554462fa3a12ce21d388d5c565 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 21 Dec 2022 12:24:35 +0100 Subject: [PATCH 8/8] Cross-compile to iOS --- tools/cross-compiler/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/cross-compiler/src/main.rs b/tools/cross-compiler/src/main.rs index fe0deff49..6e0b0d431 100644 --- a/tools/cross-compiler/src/main.rs +++ b/tools/cross-compiler/src/main.rs @@ -11,6 +11,18 @@ use anyhow::anyhow; fn main() -> anyhow::Result<()> { let targets = [ + Target { + triple: "aarch64-apple-ios", + crates: &[ + "fj", + "fj-export", + "fj-interop", + "fj-kernel", + "fj-math", + "fj-operations", + "fj-proc", + ], + }, Target { triple: "aarch64-linux-android", crates: &[