Skip to content

Commit

Permalink
Modernize build scripts (#13837)
Browse files Browse the repository at this point in the history
Use the modern `cargo::KEY=VALUE` syntax that was stabilised in MSRV 1.77, rather than the deprecated `cargo:KEY=VALUE` syntax.
  • Loading branch information
AlexWaygood authored Oct 20, 2024
1 parent 72adb09 commit 02bca9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/red_knot_python_semantic/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Rebuild the crate if a test file is added or removed from
pub fn main() {
println!("cargo:rerun-if-changed=resources/mdtest");
println!("cargo::rerun-if-changed=resources/mdtest");
}
2 changes: 1 addition & 1 deletion crates/red_knot_vendored/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn zip_dir(directory_path: &str, writer: File) -> ZipResult<File> {
}

fn main() {
println!("cargo:rerun-if-changed={TYPESHED_SOURCE_DIR}");
println!("cargo::rerun-if-changed={TYPESHED_SOURCE_DIR}");
assert!(
Path::new(TYPESHED_SOURCE_DIR).is_dir(),
"Where is typeshed?"
Expand Down
16 changes: 8 additions & 8 deletions crates/ruff/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {

#[allow(clippy::disallowed_methods)]
let target = std::env::var("TARGET").unwrap();
println!("cargo:rustc-env=RUST_HOST_TARGET={target}");
println!("cargo::rustc-env=RUST_HOST_TARGET={target}");
}

fn commit_info(workspace_root: &Path) {
Expand All @@ -23,7 +23,7 @@ fn commit_info(workspace_root: &Path) {

let git_head_path = git_dir.join("HEAD");
println!(
"cargo:rerun-if-changed={}",
"cargo::rerun-if-changed={}",
git_head_path.as_path().display()
);

Expand All @@ -39,7 +39,7 @@ fn commit_info(workspace_root: &Path) {
if let Some(git_ref) = git_ref_parts.next() {
let git_ref_path = git_dir.join(git_ref);
println!(
"cargo:rerun-if-changed={}",
"cargo::rerun-if-changed={}",
git_ref_path.as_path().display()
);
}
Expand All @@ -59,21 +59,21 @@ fn commit_info(workspace_root: &Path) {
let stdout = String::from_utf8(output.stdout).unwrap();
let mut parts = stdout.split_whitespace();
let mut next = || parts.next().unwrap();
println!("cargo:rustc-env=RUFF_COMMIT_HASH={}", next());
println!("cargo:rustc-env=RUFF_COMMIT_SHORT_HASH={}", next());
println!("cargo:rustc-env=RUFF_COMMIT_DATE={}", next());
println!("cargo::rustc-env=RUFF_COMMIT_HASH={}", next());
println!("cargo::rustc-env=RUFF_COMMIT_SHORT_HASH={}", next());
println!("cargo::rustc-env=RUFF_COMMIT_DATE={}", next());

// Describe can fail for some commits
// https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emdescribeoptionsem
if let Some(describe) = parts.next() {
let mut describe_parts = describe.split('-');
println!(
"cargo:rustc-env=RUFF_LAST_TAG={}",
"cargo::rustc-env=RUFF_LAST_TAG={}",
describe_parts.next().unwrap()
);
// If this is the tagged commit, this component will be missing
println!(
"cargo:rustc-env=RUFF_LAST_TAG_DISTANCE={}",
"cargo::rustc-env=RUFF_LAST_TAG_DISTANCE={}",
describe_parts.next().unwrap_or("0")
);
}
Expand Down

0 comments on commit 02bca9a

Please sign in to comment.