Skip to content

Commit 2ca3fb7

Browse files
Merge pull request #55 from jscatena88/integrate-cargo-make
2 parents 3f09b9a + bbb3e85 commit 2ca3fb7

File tree

11 files changed

+263
-33
lines changed

11 files changed

+263
-33
lines changed

.github/workflows/firmware.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
name: Firmware CI Checks
1+
name: Firmware Checks
22

33
on:
4-
push
4+
push:
5+
branches:
6+
- master
7+
- dev-*
8+
paths-ignore:
9+
- '*.py'
10+
- 'inputmodule-control/**'
11+
pull_request:
12+
branches:
13+
- '*'
14+
paths-ignore:
15+
- '*.py'
16+
- 'inputmodule-control/**'
517

618
env:
719
CARGO_TERM_COLOR: always
@@ -17,22 +29,22 @@ jobs:
1729
- name: Setup Rust toolchain
1830
run: rustup show
1931

32+
- run: cargo install cargo-make
33+
2034
- run: cargo install flip-link
21-
- run: cargo build -p ledmatrix
22-
- run: cargo build -p b1display
23-
- run: cargo build -p c1minimal
24-
- run: cargo build -p ledmatrix --release
25-
- run: cargo build -p b1display --release
26-
- run: cargo build -p c1minimal --release
35+
- run: cargo make --cwd b1display
36+
- run: cargo make --cwd c1minimal
37+
- run: cargo make --cwd ledmatrix build-release
38+
- run: cargo make --cwd b1display build-release
39+
- run: cargo make --cwd c1minimal build-release
2740

2841
- name: Convert to UF2 format
2942
run: |
3043
sudo apt-get update
3144
sudo apt-get install -y libudev-dev
32-
cargo install elf2uf2-rs
33-
elf2uf2-rs target/thumbv6m-none-eabi/release/b1display b1display.uf2
34-
elf2uf2-rs target/thumbv6m-none-eabi/release/c1minimal c1minimal.uf2
35-
elf2uf2-rs target/thumbv6m-none-eabi/release/ledmatrix ledmatrix.uf2
45+
cargo make --cwd b1display uf2
46+
cargo make --cwd c1minimal uf2
47+
cargo make --cwd ledmatrix uf2
3648
3749
- name: Upload UF2 files
3850
uses: actions/upload-artifact@v3
@@ -47,9 +59,9 @@ jobs:
4759
run: |
4860
sudo apt-get update
4961
sudo apt-get install -y llvm
50-
llvm-objcopy -O binary target/thumbv6m-none-eabi/release/b1display b1display.bin
51-
llvm-objcopy -O binary target/thumbv6m-none-eabi/release/c1minimal c1minimal.bin
52-
llvm-objcopy -O binary target/thumbv6m-none-eabi/release/ledmatrix ledmatrix.bin
62+
cargo make --cwd b1display bin
63+
cargo make --cwd c1minimal bin
64+
cargo make --cwd ledmatrix bin
5365
5466
- name: Upload bin files
5567
uses: actions/upload-artifact@v3
@@ -65,8 +77,6 @@ jobs:
6577
runs-on: ubuntu-latest
6678
steps:
6779
- uses: actions/checkout@v3
68-
with:
69-
submodules: true
7080

7181
- name: Setup Rust toolchain
7282
run: rustup show
@@ -93,8 +103,6 @@ jobs:
93103
runs-on: ubuntu-latest
94104
steps:
95105
- uses: actions/checkout@v3
96-
with:
97-
submodules: true
98106

99107
- name: Setup Rust toolchain
100108
run: rustup show

.github/workflows/software.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
name: Software CI Checks
1+
name: Software Checks
2+
23
on:
34
push:
5+
branches:
6+
- master
7+
- dev-*
8+
paths-ignore:
9+
- 'b1display/**'
10+
- 'c1minimal/**'
11+
- 'fl16-inputmodules/**'
12+
- 'ledmatrix/**'
13+
pull_request:
14+
branches:
15+
- '*'
16+
paths-ignore:
17+
- 'b1display/**'
18+
- 'c1minimal/**'
19+
- 'fl16-inputmodules/**'
20+
- 'ledmatrix/**'
421

522
env:
623
CARGO_TERM_COLOR: always
@@ -43,11 +60,13 @@ jobs:
4360
- name: Setup Rust toolchain
4461
run: rustup show
4562

63+
- run: cargo install cargo-make
64+
4665
- name: Build Linux tool
47-
run: cargo build --release --target x86_64-unknown-linux-gnu -p inputmodule-control
66+
run: cargo make --cwd inputmodule-control build-release
4867

4968
- name: Check if Linux tool can start
50-
run: cargo run --release --target x86_64-unknown-linux-gnu -p inputmodule-control -- --help
69+
run: cargo make --cwd inputmodule-control run -- --help | grep 'RAW HID and VIA commandline'
5170

5271
- name: Upload Linux tool
5372
uses: actions/upload-artifact@v3
@@ -64,11 +83,13 @@ jobs:
6483
- name: Setup Rust toolchain
6584
run: rustup show
6685

86+
- run: cargo install cargo-make
87+
6788
- name: Build Windows tool
68-
run: cargo build --release --target x86_64-pc-windows-msvc -p inputmodule-control
89+
run: cargo make --cwd inputmodule-control build-release
6990

7091
- name: Check if Windows tool can start
71-
run: cargo run --release --target x86_64-pc-windows-msvc -p inputmodule-control -- --help
92+
run: cargo make --cwd inputmodule-control run -- --help | grep 'RAW HID and VIA commandline'
7293

7394
- name: Upload Windows App
7495
uses: actions/upload-artifact@v3
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Test builds without cargo-make
2+
# Not the recommended path, but should make sure it still works
3+
name: Traditional Cargo Workflow
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
- dev-*
10+
paths-ignore:
11+
- '*.py'
12+
pull_request:
13+
branches:
14+
- '*'
15+
paths-ignore:
16+
- '*.py'
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
CARGO_NET_GIT_FETCH_WITH_CLI: true
21+
22+
jobs:
23+
firmware:
24+
name: Building
25+
runs-on: [ubuntu-latest]
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- name: Setup Rust toolchain
30+
run: rustup show
31+
32+
- run: cargo install flip-link
33+
34+
- run: cargo build -p ledmatrix
35+
- run: cargo build -p b1display
36+
- run: cargo build -p c1minimal
37+
38+
linux-software:
39+
name: Build Linux
40+
runs-on: ubuntu-22.04
41+
steps:
42+
- uses: actions/checkout@v3
43+
44+
- name: Install dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y libudev-dev libasound2-dev
48+
49+
- name: Setup Rust toolchain
50+
run: rustup show
51+
52+
- name: Build tool
53+
run: cargo build --release --target x86_64-unknown-linux-gnu -p inputmodule-control
54+
55+
- name: Check if tool can start
56+
run: cargo run --release --target x86_64-unknown-linux-gnu -p inputmodule-control -- --help | grep 'RAW HID and VIA commandline'
57+
58+
windows-software:
59+
name: Build Windows
60+
runs-on: windows-2022
61+
steps:
62+
- uses: actions/checkout@v3
63+
64+
- name: Setup Rust toolchain
65+
run: rustup show
66+
67+
- run: cargo install cargo-make
68+
69+
- name: Build tool
70+
run: cargo build --release --target x86_64-pc-windows-msvc -p inputmodule-control
71+
72+
- name: Check if tool can start
73+
run: cargo run --release --target x86_64-pc-windows-msvc -p inputmodule-control -- --help | grep 'RAW HID and VIA commandline'
74+
75+
lint-format:
76+
name: Lint and format check
77+
runs-on: ubuntu-latest
78+
steps:
79+
- uses: actions/checkout@v3
80+
81+
- name: Install dependencies
82+
run: |
83+
sudo apt-get update
84+
sudo apt-get install -y libudev-dev libasound2-dev
85+
86+
- name: Setup Rust toolchain
87+
run: rustup show
88+
89+
- name: Firmware clippy
90+
run: |
91+
cargo clippy -p b1display -- --deny=warnings
92+
cargo clippy -p c1minimal -- --deny=warnings
93+
cargo clippy -p ledmatrix -- --deny=warnings
94+
95+
- name: Software clippy
96+
run: cargo clippy --target x86_64-unknown-linux-gnu -p inputmodule-control -- -D warnings
97+
98+
- name: All cargo fmt
99+
run: cargo fmt --all -- --check

Makefile.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[env]
2+
TARGET_TRIPLE = "thumbv6m-none-eabi"
3+
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
4+
FEATURES = ""
5+
6+
[tasks.build]
7+
args = [
8+
"build",
9+
"@@remove-empty(BUILD_TYPE)",
10+
"--target",
11+
"${TARGET_TRIPLE}",
12+
"--features",
13+
"${FEATURES}",
14+
]
15+
16+
[tasks.build-release]
17+
clear = true
18+
env.BUILD_TYPE = "--release"
19+
run_task = "build"
20+
21+
[tasks.test]
22+
disabled = true

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,22 @@ Prepare Rust toolchain (once):
131131
```sh
132132
rustup target install thumbv6m-none-eabi
133133
cargo install flip-link
134-
cargo install elf2uf2-rs --locked
135134
```
136135

137136
Build:
138137

139138
```sh
140-
cargo build -p ledmatrix
141-
cargo build -p b1display
142-
cargo build -p c1minimal
139+
cargo make --cwd ledmatrix
140+
cargo make --cwd b1display
141+
cargo make --cwd c1minimal
143142
```
144143

145144
Generate the UF2 update file:
146145

147146
```sh
148-
elf2uf2-rs target/thumbv6m-none-eabi/debug/ledmatrix ledmatrix.uf2
149-
elf2uf2-rs target/thumbv6m-none-eabi/debug/b1display b1dipslay.uf2
150-
elf2uf2-rs target/thumbv6m-none-eabi/debug/c1minimal c1minimal.uf2
147+
cargo make --cwd ledmatrix uf2
148+
cargo make --cwd b1display uf2
149+
cargo make --cwd c1minimal uf2
151150
```
152151

153152
## Building the Application
@@ -158,8 +157,11 @@ Currently have to specify the build target because it's not possible to specify
158157
Tracking issue: https://github.com/rust-lang/cargo/issues/9406
159158

160159
```
161-
> cargo build --target x86_64-unknown-linux-gnu -p inputmodule-control
162-
> cargo run --target x86_64-unknown-linux-gnu -p inputmodule-control
160+
# Build it
161+
> cargo make --cwd inputmodule-control
162+
163+
# Build and run it, showing the tool version
164+
> cargo make --cwd inputmodule-control run -- --version
163165
```
164166

165167
### Check the firmware version of the device

b1display/Makefile.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extend = "../Makefile.toml"
2+
3+
[tasks.uf2]
4+
command = "elf2uf2-rs"
5+
args = ["../target/thumbv6m-none-eabi/release/b1display", "../target/thumbv6m-none-eabi/release/b1display.uf2"]
6+
dependencies = ["build-release"]
7+
install_crate = "elf2uf2-rs"
8+
9+
[tasks.bin]
10+
command = "llvm-objcopy"
11+
args = ["-Obinary", "../target/thumbv6m-none-eabi/release/b1display", "../target/thumbv6m-none-eabi/release/b1display.bin"]
12+
dependencies = ["build-release"]

c1minimal/Makefile.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extend = "../Makefile.toml"
2+
3+
[tasks.uf2]
4+
command = "elf2uf2-rs"
5+
args = ["../target/thumbv6m-none-eabi/release/c1minimal", "../target/thumbv6m-none-eabi/release/c1minimal.uf2"]
6+
dependencies = ["build-release"]
7+
install_crate = "elf2uf2-rs"
8+
9+
[tasks.bin]
10+
command = "llvm-objcopy"
11+
args = ["-Obinary", "../target/thumbv6m-none-eabi/release/c1minimal", "../target/thumbv6m-none-eabi/release/c1minimal.bin"]
12+
dependencies = ["build-release"]

fl16-inputmodules/Makefile.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extend = "../Makefile.toml"
2+
3+
[tasks.build-all]
4+
run_task = { name = [
5+
"build-ledmatrix",
6+
"build-b1display",
7+
"build-c1minimal",
8+
], parallel = true }
9+
10+
11+
[tasks.build-ledmatrix]
12+
env.FEATURES = "ledmatrix"
13+
run_task = "build"
14+
15+
[tasks.build-b1display]
16+
env.FEATURES = "b1display"
17+
run_task = "build"
18+
19+
[tasks.build-c1minimal]
20+
env.FEATURES = "c1minimal"
21+
run_task = "build"

fl16-inputmodules/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#![allow(clippy::needless_range_loop)]
22
#![no_std]
33

4+
#[cfg(any(
5+
all(feature = "ledmatrix", feature = "b1display"),
6+
all(feature = "ledmatrix", feature = "c1minimal"),
7+
all(feature = "b1display", feature = "c1minimal"),
8+
))]
9+
compile_error!("Features \"ledmatrix\", \"b1display\", and \"c1minimal\" are mutually exclusive");
10+
411
#[cfg(feature = "ledmatrix")]
512
pub mod fl16;
613
#[cfg(feature = "ledmatrix")]

inputmodule-control/Makefile.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extend = "../Makefile.toml"
2+
3+
# Since it's a tool, build it for the platform we're running on
4+
[env]
5+
TARGET_TRIPLE = "${CARGO_MAKE_RUST_TARGET_TRIPLE}"
6+
7+
[tasks.run]
8+
command = "cargo"
9+
args = [
10+
"run",
11+
"--target",
12+
"${CARGO_MAKE_RUST_TARGET_TRIPLE}",
13+
"${@}",
14+
]

ledmatrix/Makefile.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extend = "../Makefile.toml"
2+
3+
[tasks.uf2]
4+
command = "elf2uf2-rs"
5+
args = ["../target/thumbv6m-none-eabi/release/ledmatrix", "../target/thumbv6m-none-eabi/release/ledmatrix.uf2"]
6+
dependencies = ["build-release"]
7+
install_crate = "elf2uf2-rs"
8+
9+
[tasks.bin]
10+
command = "llvm-objcopy"
11+
args = ["-Obinary", "../target/thumbv6m-none-eabi/release/ledmatrix", "../target/thumbv6m-none-eabi/release/ledmatrix.bin"]
12+
dependencies = ["build-release"]

0 commit comments

Comments
 (0)