Skip to content

Commit

Permalink
Deletes the top-level workspace and moves the examples.
Browse files Browse the repository at this point in the history
RP2350 stuff is coming, and you can't build rp2040-hal for Armv8-M and you can't build rp235x-hal for Armv6-M, and so they cannot be in the same workspace. Ergo, if the rp2350-hal is coming to this repo (and it is), we cannot have a workspace any more.

I also moved the examples into their own package, because that's much neater than having to deal with memory.x being in magically the right place, or a bunch of dev-dependencies that are not relevant to most crate users.
  • Loading branch information
thejpster committed Aug 17, 2024
1 parent 103e4fa commit b31683c
Show file tree
Hide file tree
Showing 58 changed files with 581 additions and 255 deletions.
63 changes: 43 additions & 20 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ jobs:
- name: Install cargo-hack
run: |
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Build rp2040-hal's workspace (without the examples)
run: cargo hack build --optional-deps --each-feature
- run: cargo clean
- name: Build rp2040-hal's workspace (with the examples)
run: cargo hack build --examples --optional-deps --each-feature
- name: Build rp2040-hal
run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Build rp2040-hal-macros
run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature
- name: Build on-target-tests
run: cd on-target-tests && cargo hack build --optional-deps --each-feature
- name: Build rp2040-hal-examples
run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature
- name: Build rp-binary-info
run: cd rp-binary-info && cargo hack build --optional-deps --each-feature
tests:
name: Execute host-runable tests
runs-on: ubuntu-20.04
Expand All @@ -28,16 +33,18 @@ jobs:
- name: Install cargo-hack
run: |
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Test
run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --tests --features critical-section-impl
- name: Test docs
run: cargo hack test -p rp2040-hal --target x86_64-unknown-linux-gnu --optional-deps --each-feature --doc --features critical-section-impl
- name: Test macros
run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --tests --each-feature
- name: Test macro docs
run: cargo hack test -p rp2040-hal-macros --target x86_64-unknown-linux-gnu --optional-deps --doc --each-feature
- name: Clean
run: cargo clean
- name: Test rp2040-hal
run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --tests --features critical-section-impl
- name: Test rp2040-hal docs
run: cd rp2040-hal && cargo hack test --optional-deps --each-feature --doc --features critical-section-impl
- name: Test rp2040-hal-macros
run: cd rp2040-hal-macros && cargo hack test --optional-deps --tests --each-feature
- name: Test rp2040-hal-macros docs
run: cd rp2040-hal-macros && cargo hack test --optional-deps --doc --each-feature
- name: Test rp-binary-info
run: cd rp-binary-info && cargo hack test --optional-deps --each-feature --tests
- name: Test rp-binary-info docs
run: cd rp-binary-info && cargo hack test --optional-deps --each-feature --doc
udeps:
name: Check rp2040-hal for unused dependencies
runs-on: ubuntu-20.04
Expand All @@ -53,8 +60,16 @@ jobs:
- name: Install cargo-udeps
run: |
curl -sSL https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - --strip-components=2 -C ~/.cargo/bin ./cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu/cargo-udeps
- name: Check unused deps
run: cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in rp2040-hal
run: cd rp2040-hal && cargo hack udeps --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Check unused deps in rp2040-hal-macros
run: cd rp2040-hal-macros && cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in rp2040-hal-examples
run: cd rp2040-hal-examples && cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in on-target-tests
run: cd on-target-tests && cargo hack udeps --optional-deps --each-feature
- name: Check unused deps in rp-binary-info
run: cd rp-binary-info && cargo hack udeps --optional-deps --each-feature
msrv:
name: Verify build on MSRV
runs-on: ubuntu-20.04
Expand All @@ -68,6 +83,14 @@ jobs:
run: |
curl -sSL https://github.com/taiki-e/cargo-hack/releases/download/v0.6.17/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xvzf - -C ~/.cargo/bin
- name: Use older version of regex
run: cargo update -p regex --precise 1.9.3
- name: Verify MSRV
run: cargo hack build --examples --optional-deps --each-feature
run: cd rp2040-hal-examples && cargo update -p regex --precise 1.9.3
- name: Build rp2040-hal (on MSRV)
run: cd rp2040-hal && cargo hack build --optional-deps --each-feature --target=thumbv6m-none-eabi
- name: Build rp2040-hal-macros (on MSRV)
run: cd rp2040-hal-macros && cargo hack build --optional-deps --each-feature
- name: Build on-target-tests (on MSRV)
run: cd on-target-tests && cargo hack build --optional-deps --each-feature
- name: Build rp2040-hal-examples (on MSRV)
run: cd rp2040-hal-examples && cargo hack build --optional-deps --each-feature
- name: Build rp-binary-info (on MSRV)
run: cd rp-binary-info && cargo hack build --optional-deps --each-feature
14 changes: 12 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ jobs:
with:
target: thumbv6m-none-eabi
components: clippy
- run: cargo clippy --workspace --examples
- run: cargo clippy --workspace --examples --all-features
- name: Build rp2040-hal
run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi
- name: Build rp2040-hal (with all features)
run: cd rp2040-hal && cargo clippy --target=thumbv6m-none-eabi --all-features
- name: Build rp2040-hal-macros
run: cd rp2040-hal-macros && cargo clippy
- name: Build on-target-tests
run: cd on-target-tests && cargo clippy
- name: Build rp2040-hal-examples
run: cd rp2040-hal-examples && cargo clippy
- name: Build rp-binary-info
run: cd rp-binary-info && cargo clippy
11 changes: 10 additions & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ jobs:
with:
target: thumbv6m-none-eabi
components: rustfmt
- run: cargo fmt -- --check
- name: Check format of rp2040-hal
run: cd rp2040-hal && cargo fmt -- --check
- name: Check format of rp2040-hal-macros
run: cd rp2040-hal-macros && cargo fmt -- --check
- name: Check format of on-target-tests
run: cd on-target-tests && cargo fmt -- --check
- name: Check format of rp2040-hal-examples
run: cd rp2040-hal-examples && cargo fmt -- --check
- name: Check format of rp-binary-info
run: cd rp-binary-info && cargo fmt -- --check
23 changes: 0 additions & 23 deletions Cargo.toml

This file was deleted.

6 changes: 6 additions & 0 deletions format.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rem Formats all the files in the repo

cargo fmt --manifest-path rp2040-hal\Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-macros\Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-examples\Cargo.toml -- --check
cargo fmt --manifest-path on-target-tests\Cargo.toml -- --check
8 changes: 8 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Formats all the files in the repo

cargo fmt --manifest-path rp2040-hal/Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-macros/Cargo.toml -- --check
cargo fmt --manifest-path rp2040-hal-examples/Cargo.toml -- --check
cargo fmt --manifest-path on-target-tests/Cargo.toml -- --check
File renamed without changes.
12 changes: 12 additions & 0 deletions on-target-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@ futures = { version = "0.3.30", default-features = false, features = [
] }
i2c-write-iter = { version = "1.0.0", features = ["async"] }
itertools = { version = "0.12.0", default-features = false }

[profile.dev]
codegen-units = 1
incremental = false
lto = 'fat'
opt-level = 's'

[profile.test]
codegen-units = 1
incremental = false
lto = 'fat'
opt-level = 's'
2 changes: 2 additions & 0 deletions on-target-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ Adding a test:
Running all tests:
Linux (and any other Unix-likes where probe-rs are supported):
```system
cd on-target-tests
./run_tests.sh
```
Windows
```system
cd on-target-tests
run_tests.bat
```

Expand Down
2 changes: 1 addition & 1 deletion run_tests.bat → on-target-tests/run_tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

@SET "CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER=probe-rs run"

cargo test -p on-target-tests --no-fail-fast -- --chip rp2040
cargo test --no-fail-fast -- --chip rp2040
2 changes: 1 addition & 1 deletion run_tests.sh → on-target-tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Keep running tests even if one of them fails
# We need to specify probe-rs as our runner via environment variables here
# to control build since we aren't able to override them in config.toml
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test -p on-target-tests --no-fail-fast -- --chip rp2040
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-rs run" cargo test --no-fail-fast -- --chip rp2040
37 changes: 37 additions & 0 deletions rp2040-hal-examples/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Cargo Configuration for the https://github.com/rp-rs/rp-hal.git repository.
#
# You might want to make a similar file in your own repository if you are
# writing programs for Raspberry Silicon microcontrollers.
#

[build]
# Set the default target to match the Cortex-M0+ in the RP2040
target = "thumbv6m-none-eabi"

# Target specific options
[target.thumbv6m-none-eabi]
# Pass some extra options to rustc, some of which get passed on to the linker.
#
# * linker argument --nmagic turns off page alignment of sections (which saves
# flash space)
# * linker argument -Tlink.x tells the linker to use link.x as the linker
# script. This is usually provided by the cortex-m-rt crate, and by default
# the version in that crate will include a file called `memory.x` which
# describes the particular memory layout for your specific chip.
# * no-vectorize-loops turns off the loop vectorizer (seeing as the M0+ doesn't
# have SIMD)
rustflags = [
"-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x",
"-C", "link-arg=-Tdefmt.x",
"-C", "no-vectorize-loops",
]

# This runner will make a UF2 file and then copy it to a mounted RP2040 in USB
# Bootloader mode:
runner = "elf2uf2-rs -d"

# This runner will find a supported SWD debug probe and flash your RP2040 over
# SWD:
# runner = "probe-rs run --chip RP2040"
36 changes: 36 additions & 0 deletions rp2040-hal-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "rp2040-hal-examples"
version = "0.1.0"
edition = "2021"
authors = ["The rp-rs Developers"]
homepage = "https://github.com/rp-rs/rp-hal"
description = "Examples for the rp2040-hal crate"
license = "MIT OR Apache-2.0"
rust-version = "1.77"
repository = "https://github.com/rp-rs/rp-hal"
categories = ["embedded", "hardware-support", "no-std", "no-std::no-alloc"]
keywords = ["embedded", "hal", "raspberry-pi", "rp2040", "embedded-hal"]

[dependencies]
cortex-m = "0.7.2"
cortex-m-rt = "0.7"
cortex-m-rtic = "1.1.4"
critical-section = { version = "1.0.0" }
defmt = "0.3"
defmt-rtt = "0.4.0"
dht-sensor = "0.2.1"
embedded_hal_0_2 = { package = "embedded-hal", version = "0.2.5", features = ["unproven"] }
embedded-alloc = "0.5.1"
embedded-hal = "1.0.0"
embedded-hal-async = "1.0.0"
fugit = "0.3.6"
futures = { version = "0.3.30", default-features = false, features = ["async-await"] }
hd44780-driver = "0.4.0"
nb = "1.0"
nostd_async = { version = "0.6.1", features = ["cortex_m"] }
panic-halt = "0.2.0"
panic-probe = { version = "0.3.1", features = ["print-defmt"] }
pio = "0.2.0"
pio-proc = "0.2.0"
rp2040-boot2 = "0.3.0"
rp2040-hal = { path = "../rp2040-hal", version = "0.10.0", features = ["binary-info", "critical-section-impl", "rt", "defmt"] }
Loading

0 comments on commit b31683c

Please sign in to comment.