Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expected CFG directives #89

Merged
merged 8 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ jobs:
alsa-lib atk clang clang-libs clang-resource-filesystem \
clang-tools-extra cmake cups curl dosfstools g++ gcc git \
git-lfs glibc-devel glibc-devel.i686 glibc-static \
glibc-static.i686 gtk3 lld lld-devel lld-libs llvm llvm-libs \
glibc-static.i686 gtk3 jq lld lld-devel lld-libs llvm llvm-libs \
llvm-static make mesa-libgbm mtools ninja-build openssl \
openssl-devel openssl-libs python3 python3-pip yamllint

Expand Down Expand Up @@ -465,10 +465,19 @@ jobs:

- name: CT39 - Clippy Check Project
run: |
cargo clippy \
cargo clippy > clippy.log \
|| ( echo "❗ [CT39 (1/2)] Failed clippy static analysis checks" && exit 1 )
cargo clippy --message-format=json 2> /dev/null | jq 'select(.reason == "compiler-message")' 2>/dev/null > clippy.json
echo "✅ [CT39 (1/2)] Passed clippy static analysis checks"

- name: Upload Clippy Check Results
uses: actions/upload-artifact@v4
with:
name: clippy-json
path: |
clippy.json
clippy.log

- name: Test Project
run: |
SIMICS_TEST_CLEANUP_EACH=1 SIMICS_TEST_LOCAL_PACKAGES_ONLY=1 cargo test --no-fail-fast -r _latest || ( echo "❗ Tests failed" && exit 1 )
Expand Down
2 changes: 1 addition & 1 deletion simics-rs/cargo-simics-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ clap = { version = "4.5.1", features = ["derive"] }
cargo-subcommand = { version = "0.12.0", features = ["clap"] }
command-ext = "0.1.2"
simics-package = { version = "0.1.0", path = "../simics-package" }
itertools = "0.12.1"
itertools = "0.13.0"
ispm-wrapper = { version = "0.1.0", path = "../ispm-wrapper" }
thiserror = "1.0.57"
8 changes: 4 additions & 4 deletions simics-rs/simics-api-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub mod common {
match p.path().canonicalize() {
Ok(p) => p.strip_prefix(&include_path).map_or_else(
|e| {
eprintln!(
println!(
"cargo:warning=Failed to strip prefix {} from {}: {}",
include_path.as_ref().display(),
p.display(),
Expand All @@ -185,7 +185,7 @@ pub mod common {
|p| Some(p.to_path_buf()),
),
Err(e) => {
eprintln!(
println!(
"cargo:warning=Failed to canonicalize path {}: {}",
p.path().display(),
e
Expand All @@ -194,15 +194,15 @@ pub mod common {
}
}
} else {
eprintln!(
println!(
"cargo:warning=Ignoring path {}, no '.h' extension",
p.path().display()
);
None
}
}
None => {
eprintln!(
println!(
"cargo:warning=Ignoring path {}, no extension",
p.path().display()
);
Expand Down
18 changes: 18 additions & 0 deletions simics-rs/simics-build-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ where
.ok_or_else(|| anyhow!("No sub-directories found"))
}

/// Emit expected CFG directives for check-cfg feature tests
pub fn emit_expected_cfg_directives() {
println!("cargo:rustc-check-cfg=cfg(simics_version_6)");
println!("cargo:rustc-check-cfg=cfg(simics_version_7)");

// We emit all the way up to 9.99.999 as expected CFG directives
for i in 6_00_000..7_99_999 {
println!(
"cargo:rustc-check-cfg=cfg(simics_version_{}_{}_{})",
i / 100_000,
i / 1_000 % 100,
i % 1_000
);
}
}

/// Emit CFG directives for the version of the Simics API being compiled against. For example,
/// simics_version_6_0_185 and simics_version_6. Both a full triple version and a major version
/// directive is emitted.
Expand All @@ -43,6 +59,8 @@ pub fn emit_cfg_directives() -> Result<()> {
// compatible with all supported SIMICS versions, based on the SIMICS version of the
// low level bindings.

emit_expected_cfg_directives();

let simics_api_version = versions::Versioning::new(simics_api_sys::SIMICS_VERSION)
.ok_or_else(|| anyhow!("Invalid version {}", simics_api_sys::SIMICS_VERSION))?;

Expand Down