Skip to content

Commit 729c03d

Browse files
authored
Add expected CFG directives (#89)
1 parent d888120 commit 729c03d

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ jobs:
362362
alsa-lib atk clang clang-libs clang-resource-filesystem \
363363
clang-tools-extra cmake cups curl dosfstools g++ gcc git \
364364
git-lfs glibc-devel glibc-devel.i686 glibc-static \
365-
glibc-static.i686 gtk3 lld lld-devel lld-libs llvm llvm-libs \
365+
glibc-static.i686 gtk3 jq lld lld-devel lld-libs llvm llvm-libs \
366366
llvm-static make mesa-libgbm mtools ninja-build openssl \
367367
openssl-devel openssl-libs python3 python3-pip yamllint
368368
@@ -465,10 +465,21 @@ jobs:
465465
466466
- name: CT39 - Clippy Check Project
467467
run: |
468-
cargo clippy \
468+
cargo clippy > clippy.log \
469469
|| ( echo "❗ [CT39 (1/2)] Failed clippy static analysis checks" && exit 1 )
470+
cargo clippy --message-format=json 2> /dev/null | jq 'select(.reason == "compiler-message")' 2>/dev/null > clippy.json
471+
cargo clippy --message-format=json > clippy-full.json 2>&1
470472
echo "✅ [CT39 (1/2)] Passed clippy static analysis checks"
471473
474+
- name: Upload Clippy Check Results
475+
uses: actions/upload-artifact@v4
476+
with:
477+
name: clippy-json
478+
path: |
479+
clippy.json
480+
clippy-full.json
481+
clippy.log
482+
472483
- name: Test Project
473484
run: |
474485
SIMICS_TEST_CLEANUP_EACH=1 SIMICS_TEST_LOCAL_PACKAGES_ONLY=1 cargo test --no-fail-fast -r _latest || ( echo "❗ Tests failed" && exit 1 )

simics-rs/cargo-simics-build/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ clap = { version = "4.5.1", features = ["derive"] }
3030
cargo-subcommand = { version = "0.12.0", features = ["clap"] }
3131
command-ext = "0.1.2"
3232
simics-package = { version = "0.1.0", path = "../simics-package" }
33-
itertools = "0.12.1"
33+
itertools = "0.13.0"
3434
ispm-wrapper = { version = "0.1.0", path = "../ispm-wrapper" }
3535
thiserror = "1.0.57"

simics-rs/cargo-simics-build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl App {
285285
.and_then(|n| n.to_str().map(|n| (p, n.to_string())))
286286
})
287287
.sorted_by(|(_, a), (_, b)| a.cmp(b))
288-
.group_by(|(_, n)| n.clone())
288+
.chunk_by(|(_, n)| n.clone())
289289
// Get the newest one
290290
.into_iter()
291291
.filter_map(|(_, g)| {

simics-rs/simics-api-sys/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub mod common {
174174
match p.path().canonicalize() {
175175
Ok(p) => p.strip_prefix(&include_path).map_or_else(
176176
|e| {
177-
eprintln!(
177+
println!(
178178
"cargo:warning=Failed to strip prefix {} from {}: {}",
179179
include_path.as_ref().display(),
180180
p.display(),
@@ -185,7 +185,7 @@ pub mod common {
185185
|p| Some(p.to_path_buf()),
186186
),
187187
Err(e) => {
188-
eprintln!(
188+
println!(
189189
"cargo:warning=Failed to canonicalize path {}: {}",
190190
p.path().display(),
191191
e
@@ -194,15 +194,15 @@ pub mod common {
194194
}
195195
}
196196
} else {
197-
eprintln!(
197+
println!(
198198
"cargo:warning=Ignoring path {}, no '.h' extension",
199199
p.path().display()
200200
);
201201
None
202202
}
203203
}
204204
None => {
205-
eprintln!(
205+
println!(
206206
"cargo:warning=Ignoring path {}, no extension",
207207
p.path().display()
208208
);

simics-rs/simics-build-utils/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ where
3232
.ok_or_else(|| anyhow!("No sub-directories found"))
3333
}
3434

35+
/// Emit expected CFG directives for check-cfg feature tests
36+
pub fn emit_expected_cfg_directives() {
37+
println!("cargo:rustc-check-cfg=cfg(simics_version_6)");
38+
println!("cargo:rustc-check-cfg=cfg(simics_version_7)");
39+
40+
// We emit all the way up to 9.99.999 as expected CFG directives
41+
for i in 6_00_000..7_99_999 {
42+
println!(
43+
"cargo:rustc-check-cfg=cfg(simics_version_{}_{}_{})",
44+
i / 100_000,
45+
i / 1_000 % 100,
46+
i % 1_000
47+
);
48+
}
49+
}
50+
3551
/// Emit CFG directives for the version of the Simics API being compiled against. For example,
3652
/// simics_version_6_0_185 and simics_version_6. Both a full triple version and a major version
3753
/// directive is emitted.
@@ -43,6 +59,8 @@ pub fn emit_cfg_directives() -> Result<()> {
4359
// compatible with all supported SIMICS versions, based on the SIMICS version of the
4460
// low level bindings.
4561

62+
emit_expected_cfg_directives();
63+
4664
let simics_api_version = versions::Versioning::new(simics_api_sys::SIMICS_VERSION)
4765
.ok_or_else(|| anyhow!("Invalid version {}", simics_api_sys::SIMICS_VERSION))?;
4866

0 commit comments

Comments
 (0)