Skip to content

Commit b109bb2

Browse files
committed
Adapt CI to the new build system
The temporary SVD files are now generated in $OUT_DIR/svd instead of a temp directory, so that we can upload them for inspection as part of the CI output.
1 parent 0b724f9 commit b109bb2

File tree

3 files changed

+13
-41
lines changed

3 files changed

+13
-41
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,13 @@ jobs:
2121
toolchain: stable
2222

2323
# Rust Dependencies
24-
- name: Cache Cargo installed binaries
25-
uses: actions/cache@v4
26-
id: cache-cargo
27-
with:
28-
path: ~/cargo-bin
29-
key: rust-tools-20250106-001
30-
- name: Install svd2rust
31-
if: steps.cache-cargo.outputs.cache-hit != 'true'
32-
run: cargo install svd2rust --version 0.28.0 --locked
33-
- name: Install cargo-form
34-
if: steps.cache-cargo.outputs.cache-hit != 'true'
35-
run: cargo install form --version 0.8.0 --locked
36-
- name: Install atdf2svd
37-
if: steps.cache-cargo.outputs.cache-hit != 'true'
38-
run: cargo install atdf2svd --version 0.5.0 --locked
39-
- name: Install svdtools
40-
if: steps.cache-cargo.outputs.cache-hit != 'true'
41-
run: cargo install svdtools --version 0.4.0 --locked
42-
- name: Copy tools to cache directory
43-
if: steps.cache-cargo.outputs.cache-hit != 'true'
44-
run: |
45-
mkdir ~/cargo-bin
46-
cp ~/.cargo/bin/svd2rust ~/cargo-bin
47-
cp ~/.cargo/bin/form ~/cargo-bin
48-
cp ~/.cargo/bin/atdf2svd ~/cargo-bin
49-
cp ~/.cargo/bin/svdtools ~/cargo-bin
50-
- name: Put new cargo binary directory into path
51-
run: echo "$HOME/cargo-bin" >> $GITHUB_PATH
52-
5324
- name: Install Nightly Rust
5425
uses: actions-rust-lang/setup-rust-toolchain@v1
5526
with:
5627
toolchain: nightly-2023-08-08
5728
components: rustfmt
5829

5930
# Actual test run
60-
- name: Generate chip description sources
61-
run: make RUSTUP_TOOLCHAIN=nightly-2023-08-08
6231
- name: Test-compile the crate
6332
run: cargo check --all-features
6433

@@ -73,7 +42,7 @@ jobs:
7342
with:
7443
name: avr-device
7544
path: |
76-
svd/
45+
target/avr-atmega328p/debug/build/avr-device-*/out/svd/
7746
target/package/avr-device-*.crate
7847
macros/target/package/avr-device-macros-*.crate
7948
@@ -91,6 +60,4 @@ jobs:
9160
- name: Install AVR gcc, binutils, and libc
9261
run: sudo apt-get install -y avr-libc binutils-avr gcc-avr
9362
- name: Build ATmega328P example
94-
run: cd examples/atmega328p && cargo build
95-
- name: Check ATmega328P formatting
96-
run: cd examples/atmega328p && cargo fmt --check
63+
run: cargo build --example atmega328p --features atmega328p,rt

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ include = [
1919
"/src/**/*.rs",
2020
"/vendor/*.atdf",
2121
"/vendor/LICENSE",
22+
"/examples/**/src/*.rs"
2223
]
2324

2425
[package.metadata.docs.rs]

build.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ fn build_mcu_module(mcu: &str) {
7575
let patch_file = patch_dir.join(format!("{}.yaml", mcu));
7676
println!("cargo::rerun-if-changed={}", patch_file.display());
7777

78+
let out_dir = env::var("OUT_DIR").unwrap();
7879
// Get a temporary directory to work inside.
79-
let temp_dir = env::temp_dir().join(format!("avr-device-build-{}", mcu));
80-
ensure_directory(&temp_dir);
80+
let svd_dir = Path::new(&out_dir).join("svd");
81+
ensure_directory(&svd_dir);
82+
let svd_unpatched_dir = svd_dir.join("unpatched");
83+
ensure_directory(&svd_unpatched_dir);
84+
let svd_patched_dir = svd_dir.join("patched");
85+
ensure_directory(&svd_patched_dir);
8186

8287
// Apply atdf2svd.
8388
let atdf_reader = File::open(&atdf_file).unwrap();
@@ -88,7 +93,7 @@ fn build_mcu_module(mcu: &str) {
8893
panic!("Failed to parse \"{}\"!", atdf_file.display());
8994
}
9095
};
91-
let svd_file = temp_dir.join("unpatched.svd");
96+
let svd_file = svd_unpatched_dir.join(mcu).with_extension("svd");
9297
let svd_writer = File::create(&svd_file).unwrap();
9398
if let Err(what) = svd::generate(&atdf_parsed, svd_writer) {
9499
let _ = what.format(&mut io::stdout());
@@ -107,9 +112,9 @@ _include:
107112
svd_file.display(),
108113
patch_file.display()
109114
);
110-
let includer_file = temp_dir.join("patch.yaml");
115+
let includer_file = svd_dir.join("patch.yaml");
111116
fs::write(&includer_file, &includer_content).unwrap();
112-
let svd_patched_file = temp_dir.join("patched.svd");
117+
let svd_patched_file = svd_patched_dir.join(mcu).with_extension("svd");
113118
patch::process_file(
114119
&includer_file,
115120
Some(&svd_patched_file),
@@ -126,7 +131,6 @@ _include:
126131
}
127132

128133
// Apply svd2rust.
129-
let out_dir = env::var("OUT_DIR").unwrap();
130134
let pac_dir = Path::new(&out_dir).join("pac");
131135
ensure_directory(&pac_dir);
132136
let mut svd2rust_config = config::Config::default();

0 commit comments

Comments
 (0)