diff --git a/.gitignore b/.gitignore index 1b72444a..93d91b91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /Cargo.lock +/nightly/target /target diff --git a/Cargo.toml b/Cargo.toml index 5eaaa39f..808c4349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,14 @@ edition = "2021" license = "Apache-2.0 OR MIT" name = "libtock" repository = "https://www.github.com/tock/libtock-rs" +rust-version.workspace = true version = "0.1.0" +[workspace.package] +# This must be kept in sync with rust-toolchain.toml; please see that file for +# more information. +rust-version = "1.70" + [dependencies] libtock_adc = { path = "apis/adc"} libtock_air_quality = { path = "apis/air_quality" } diff --git a/Makefile b/Makefile index 201581d1..faeafab7 100644 --- a/Makefile +++ b/Makefile @@ -45,10 +45,7 @@ endif .PHONY: setup setup: setup-qemu - rustup install stable - cargo +stable install elf2tab - cargo miri setup - rustup target add --toolchain stable thumbv7em-none-eabi + cargo install elf2tab # Sets up QEMU in the tock/ directory. We use Tock's QEMU which may contain # patches to better support boards that Tock supports. @@ -108,19 +105,8 @@ EXCLUDE_STD := --exclude libtock_unittest --exclude print_sizes \ --exclude runner --exclude syscalls_tests \ --exclude libtock_build_scripts -# Currently, all of our crates should build with a stable toolchain. This -# verifies our crates don't depend on unstable features by using cargo check. We -# specify a different target directory so this doesn't flush the cargo cache of -# the primary toolchain. -.PHONY: test-stable -test-stable: - cargo +stable check --target-dir=target/stable --workspace \ - $(EXCLUDE_RUNTIME) - LIBTOCK_PLATFORM=nrf52 cargo +stable check $(EXCLUDE_STD) \ - --target=thumbv7em-none-eabi --target-dir=target/stable --workspace - .PHONY: test -test: examples test-stable +test: examples cargo test $(EXCLUDE_RUNTIME) --workspace LIBTOCK_PLATFORM=nrf52 cargo fmt --all -- --check cargo clippy --all-targets $(EXCLUDE_RUNTIME) --workspace @@ -128,8 +114,10 @@ test: examples test-stable --target=thumbv7em-none-eabi --workspace LIBTOCK_PLATFORM=hifive1 cargo clippy $(EXCLUDE_STD) \ --target=riscv32imac-unknown-none-elf --workspace - MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \ - cargo miri test $(EXCLUDE_MIRI) --workspace + cd nightly && \ + MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \ + cargo miri test $(EXCLUDE_MIRI) --manifest-path=../Cargo.toml \ + --target-dir=target --workspace echo '[ SUCCESS ] libtock-rs tests pass' # Helper functions to define make targets to build for specific (flash, ram, diff --git a/nightly/rust-toolchain.toml b/nightly/rust-toolchain.toml new file mode 100644 index 00000000..df92ed0b --- /dev/null +++ b/nightly/rust-toolchain.toml @@ -0,0 +1,4 @@ +# This is the nightly Rust toolchain used by `make test`. +[toolchain] +channel = "nightly-2023-08-22" +components = ["miri"] diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 873e2ff6..00000000 --- a/rust-toolchain +++ /dev/null @@ -1,9 +0,0 @@ -[toolchain] -# See https://rust-lang.github.io/rustup-components-history/ for a list of -# recently nightlies and what components are available for them. -channel = "nightly-2023-08-22" -components = ["clippy", "miri", "rustfmt"] -targets = ["thumbv6m-none-eabi", - "thumbv7em-none-eabi", - "riscv32imac-unknown-none-elf", - "riscv32imc-unknown-none-elf"] diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..c4f98b3f --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,13 @@ +[toolchain] +# This is libtock-rs' Minimum Supported Rust Version (MSRV). +# +# Update policy: Update this if doing so allows you to use a Rust feature that +# you'd like to use. When you do so, update this to the first Rust version that +# includes that feature. Whenever this value is updated, the rust-version field +# in Cargo.toml must be updated as well. +channel = "1.70" +components = ["clippy", "rustfmt"] +targets = ["thumbv6m-none-eabi", + "thumbv7em-none-eabi", + "riscv32imac-unknown-none-elf", + "riscv32imc-unknown-none-elf"]