Skip to content

Commit

Permalink
refactor: add support for rustc-check-cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 committed May 7, 2024
1 parent cf8f110 commit a6e8af9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Install Cargo Udeps
uses: taiki-e/install-action@v2
with:
tool: cargo-udeps
tool: cargo-udeps@0.1.48

- name: Run Cargo Udeps
run: cargo +nightly udeps --locked --all-targets
Expand Down
12 changes: 9 additions & 3 deletions crates/wdk-build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

//! Build script for the `wdk-build` crate.
#[rustversion::nightly]
fn main() {
println!("cargo:rustc-cfg=nightly_toolchain");
println!("cargo::rustc-check-cfg=cfg(nightly_toolchain)");
setup_nightly_cfgs();
}

// Custom attributes cannot be applied to expressions yet, so separate functions are required for nightly/non-nightly: https://github.com/rust-lang/rust/issues/15701
#[rustversion::nightly]
fn setup_nightly_cfgs() {
println!("cargo::rustc-cfg=nightly_toolchain");
}

#[rustversion::not(nightly)]
fn main() {}
const fn setup_nightly_cfgs() {}
2 changes: 1 addition & 1 deletion crates/wdk-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ impl Config {
return Err(ExportError::MissingLinksValue(var_error));
}
println!(
"cargo::{}={}",
"cargo::metadata={}={}",
Self::CARGO_CONFIG_KEY,
serde_json::to_string(self)?
);
Expand Down

0 comments on commit a6e8af9

Please sign in to comment.