Skip to content

Commit

Permalink
Remove sysroot-abi feature flag from proc-macro-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jan 10, 2024
1 parent 5871b61 commit 4b7b602
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion crates/proc-macro-srv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ expect-test = "1.4.0"
proc-macro-test.path = "./proc-macro-test"

[features]
sysroot-abi = ["proc-macro-test/sysroot-abi"]
sysroot-abi = []
in-rust-tree = ["mbe/in-rust-tree", "sysroot-abi"]

[lints]
Expand Down
3 changes: 0 additions & 3 deletions crates/proc-macro-srv/proc-macro-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ cargo_metadata = "0.18.1"

# local deps
toolchain.workspace = true

[features]
sysroot-abi = []
28 changes: 15 additions & 13 deletions crates/proc-macro-srv/proc-macro-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@ use cargo_metadata::Message;

fn main() {
println!("cargo:rerun-if-changed=imp");
println!("cargo:rerun-if-env-changed=PROC_MACRO_TEST_TOOLCHAIN");

let has_features = env::var_os("RUSTC_BOOTSTRAP").is_some()
|| String::from_utf8(
Command::new(toolchain::cargo()).arg("--version").output().unwrap().stdout,
)
.unwrap()
.contains("nightly");

let out_dir = env::var_os("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir);

if !has_features {
println!("proc-macro-test testing only works on nightly toolchains");
let info_path = out_dir.join("proc_macro_test_location.txt");
fs::File::create(info_path).unwrap();
return;
}

let name = "proc-macro-test-impl";
let version = "0.0.0";

Expand Down Expand Up @@ -53,15 +66,7 @@ fn main() {

let target_dir = out_dir.join("target");

let mut cmd = if let Ok(toolchain) = std::env::var("PROC_MACRO_TEST_TOOLCHAIN") {
// leverage rustup to find user-specific toolchain
let mut cmd = Command::new("cargo");
cmd.arg(format!("+{toolchain}"));
cmd
} else {
Command::new(toolchain::cargo())
};

let mut cmd = Command::new(toolchain::cargo());
cmd.current_dir(&staging_dir)
.args(["build", "-p", "proc-macro-test-impl", "--message-format", "json"])
// Explicit override the target directory to avoid using the same one which the parent
Expand All @@ -70,9 +75,6 @@ fn main() {
// instance to use the same target directory.
.arg("--target-dir")
.arg(&target_dir);
if cfg!(feature = "sysroot-abi") {
cmd.args(["--features", "sysroot-abi"]);
}

if let Ok(target) = std::env::var("TARGET") {
cmd.args(["--target", &target]);
Expand Down
3 changes: 0 additions & 3 deletions crates/proc-macro-srv/proc-macro-test/imp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ proc-macro = true
# this crate should not have any dependencies, since it uses its own workspace,
# and its own `Cargo.lock`

[features]
sysroot-abi = []

[workspace]
3 changes: 0 additions & 3 deletions crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Exports a few trivial procedural macros for testing.

#![allow(unexpected_cfgs)]
#![cfg(feature = "sysroot-abi")]
#![cfg(any(feature = "sysroot-abi", rust_analyzer))]
#![warn(rust_2018_idioms, unused_lifetimes)]
#![feature(proc_macro_span, proc_macro_def_site)]

Expand Down

0 comments on commit 4b7b602

Please sign in to comment.