Skip to content

Commit

Permalink
Auto merge of #126861 - GuillaumeGomez:migrate-run-make-invalid-libra…
Browse files Browse the repository at this point in the history
…ry, r=Kobzol

Migrate `run-make/invalid-library` to `rmake.rs`

Part of #121876.

r? `@jieyouxu`

try-job: x86_64-msvc
  • Loading branch information
bors committed Jun 27, 2024
2 parents 036b38c + 3394fe8 commit 2495953
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ dependencies = [
"backtrace",
]

[[package]]
name = "ar"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"

[[package]]
name = "ar_archive_writer"
version = "0.2.0"
Expand Down Expand Up @@ -3394,6 +3400,7 @@ dependencies = [
name = "run_make_support"
version = "0.2.0"
dependencies = [
"ar",
"gimli 0.28.1",
"object 0.34.0",
"regex",
Expand Down
1 change: 1 addition & 0 deletions src/tools/run-make-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ similar = "2.5.0"
wasmparser = "0.118.2"
regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
gimli = "0.28.1"
ar = "0.9.0"
13 changes: 13 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ pub fn target() -> String {
env_var("TARGET")
}

/// `AR`
#[track_caller]
pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
let output = fs::File::create(&output_path).expect(&format!(
"the file in path \"{}\" could not be created",
output_path.as_ref().display()
));
let mut builder = ar::Builder::new(output);
for input in inputs {
builder.append_path(input).unwrap();
}
}

/// Check if target is windows-like.
#[must_use]
pub fn is_windows() -> bool {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
run-make/interdependent-c-libraries/Makefile
run-make/intrinsic-unreachable/Makefile
run-make/invalid-library/Makefile
run-make/issue-107094/Makefile
run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-14698/Makefile
Expand Down
6 changes: 0 additions & 6 deletions tests/run-make/invalid-library/Makefile

This file was deleted.

8 changes: 8 additions & 0 deletions tests/run-make/invalid-library/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use run_make_support::fs_wrapper::create_file;
use run_make_support::{ar, rustc};

fn main() {
create_file("lib.rmeta");
ar(&["lib.rmeta"], "libfoo-ffffffff-1.0.rlib");
rustc().input("foo.rs").run_fail().assert_stderr_contains("found invalid metadata");
}

0 comments on commit 2495953

Please sign in to comment.