From 7920dc86d911f622042b90235f2abcb10db19dc1 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 16 Dec 2025 14:18:37 +0100 Subject: [PATCH 1/2] Exclude development scripts from published package During a dependency review we noticed that the autocfg crate includes various development scripts. These development scripts shouldn't be there as they might, at some point become problematic. As of now they prevent any downstream user from enabling the `[bans.build.interpreted]` option of cargo deny. I opted for using an explicit include list instead of an exclude list to prevent these files from being included in the published packages to make sure that everything that's included is an conscious choice. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 75b34ea..bec1644 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ description = "Automatic cfg for Rust compiler features" readme = "README.md" keywords = ["rustc", "build", "autoconf"] categories = ["development-tools::build-utils"] -exclude = ["/.github/**"] rust-version = "1.0" +include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs"] [dependencies] From bfee0eb141b001c422420b0379d57b0c83b98599 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Wed, 4 Feb 2026 08:09:44 +0100 Subject: [PATCH 2/2] Replace test wrapper script with a rust binary Also include the tests in the published package. --- Cargo.toml | 2 +- tests/support/wrap_ignored.rs | 7 +++++++ tests/wrap_ignored | 12 ------------ tests/wrappers.rs | 15 ++++++++++++++- 4 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 tests/support/wrap_ignored.rs delete mode 100755 tests/wrap_ignored diff --git a/Cargo.toml b/Cargo.toml index bec1644..eba7271 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,6 @@ readme = "README.md" keywords = ["rustc", "build", "autoconf"] categories = ["development-tools::build-utils"] rust-version = "1.0" -include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs"] +include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs", "tests/**/*.rs"] [dependencies] diff --git a/tests/support/wrap_ignored.rs b/tests/support/wrap_ignored.rs new file mode 100644 index 0000000..80f2cf6 --- /dev/null +++ b/tests/support/wrap_ignored.rs @@ -0,0 +1,7 @@ +fn main() { + let mut args = std::env::args(); + // Add our own version so we can check that the wrapper is used for that. + if args.any(|f| f == "--version") { + println!("release: 12345.6789.0"); + } +} diff --git a/tests/wrap_ignored b/tests/wrap_ignored deleted file mode 100755 index 5e577d0..0000000 --- a/tests/wrap_ignored +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -for arg in "$@"; do - case "$arg" in - # Add our own version so we can check that the wrapper is used for that. - "--version") echo "release: 12345.6789.0" ;; - # Read all input so the writer doesn't get EPIPE when we exit. - "-") read -d "" PROBE ;; - esac -done - -exit 0 diff --git a/tests/wrappers.rs b/tests/wrappers.rs index cacca71..0fa5c49 100644 --- a/tests/wrappers.rs +++ b/tests/wrappers.rs @@ -17,6 +17,8 @@ fn test_wrappers() { } } + let original_rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); + let out = support::out_dir(); // This is used as a heuristic to detect rust-lang/cargo#9601. @@ -44,9 +46,20 @@ fn test_wrappers() { } } + // compile the wrap_ignored wrapper + let wrapper_output_path = format!("{}/wrap_ignored", out.display()); + let res = std::process::Command::new(original_rustc) + .arg("./tests/support/wrap_ignored.rs") + .arg("-o") + .arg(&wrapper_output_path) + .status() + .unwrap(); + assert!(res.success(), "Failed to compile wrapper"); + println!("{wrapper_output_path}"); + // Finally, make sure that `RUSTC_WRAPPER` is applied outermost // by using something that doesn't pass through at all. - env::set_var("RUSTC_WRAPPER", "./tests/wrap_ignored"); + env::set_var("RUSTC_WRAPPER", wrapper_output_path); env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false"); let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap(); assert!(ac.probe_type("mesize")); // anything goes!