From d52d627113b3db730c11c2f80e5bc8eb2df9d04d Mon Sep 17 00:00:00 2001 From: Michael Mogenson Date: Tue, 12 Jan 2021 16:41:51 -0500 Subject: [PATCH] Remove cargo-xbuild dev dependency (#95) * Remove cargo-xbuild dev dependency As of Rust nightly 2020-07-15, we can set the default build target and build-std feature of cargo instead of relying on cargo-xbuild. Since the thumbv4-non-agb target is the default for all cargo commands, change the Rust snippets in Makefile.toml to cross-platform duckscript. The only uglyness we're left with is running the unit tests. We want to build and run the tests on the host archetecture. Create three platform overrides for Mac, Windows, Linux and set flags to override the default target triple and build-std option. * remove uneeded attribute From cargo: "the feature `cfg_target_vendor` has been stable since 1.33.0 and no longer requires an attribute to enable" --- .cargo/config.toml | 5 +++++ Makefile.toml | 53 ++++++++++++++++++---------------------------- src/lib.rs | 1 - 3 files changed, 26 insertions(+), 33 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..a64d5bd --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[build] +target = "thumbv4-none-agb.json" + +[unstable] +build-std = ["core"] diff --git a/Makefile.toml b/Makefile.toml index cfbbbec..db6222d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -2,14 +2,8 @@ skip_core_tasks = true [tasks.create-target-dir] -script_runner = "@rust" -script = [ -''' -fn main() { - std::fs::DirBuilder::new().recursive(true).create("./target/").unwrap(); -} -''' -] +script_runner = "@duckscript" +script = [ "mkdir ./target/" ] [tasks.assemble] dependencies = ["create-target-dir"] @@ -19,42 +13,37 @@ args = ["crt0.s", "-o", "target/crt0.o"] [tasks.build-examples-debug] dependencies = ["assemble"] command = "cargo" -args = ["xbuild", "--examples", "--target", "thumbv4-none-agb.json"] +args = ["build", "--examples"] [tasks.build-examples-release] dependencies = ["assemble"] command = "cargo" -args = ["xbuild", "--examples", "--target", "thumbv4-none-agb.json", "--release"] +args = ["build", "--examples", "--release"] [tasks.pack-roms] -script_runner = "@rust" +script_runner = "@duckscript" script = [ ''' -fn main() -> std::io::Result<()> { - for entry in std::fs::read_dir("examples/")? { - let entry = entry?; - let mut path = entry.path(); - if path.is_dir() { - continue; - } else { - path.set_extension(""); - let name = path.file_name().unwrap().to_str().unwrap(); - println!("{}", name); - std::process::Command::new("arm-none-eabi-objcopy").args( - &["-O", "binary", - &format!("target/thumbv4-none-agb/release/examples/{}",name), - &format!("target/{}.gba",name)]) - .output().expect("failed to objcopy!"); - } - } - Ok(()) -} +examples = glob_array ./examples/*.rs +for example in ${examples} + example = substring ${example} -3 + example = basename ${example} + exec arm-none-eabi-objcopy -O binary ./target/thumbv4-none-agb/release/examples/${example} ./target/${example}.gba +end ''' ] -[tasks.test] +[tasks.test.linux] command = "cargo" -args = ["test", "--lib"] +args = ["test", "--lib", "--target", "x86_64-unknown-linux-gnu", "-Z", "build-std"] + +[tasks.test.windows] +command = "cargo" +args = ["test", "--lib", "--target", "x86_64-pc-windows-msvc", "-Z", "build-std"] + +[tasks.test.mac] +command = "cargo" +args = ["test", "--lib", "--target", "x86_64-apple-darwin", "-Z", "build-std"] [tasks.justrelease] dependencies = ["build-examples-release", "pack-roms"] diff --git a/src/lib.rs b/src/lib.rs index ca17759..8589008 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(not(test), no_std)] #![feature(asm)] -#![feature(cfg_target_vendor)] #![allow(clippy::cast_lossless)] #![deny(clippy::float_arithmetic)] #![warn(missing_docs)]