Skip to content

Commit

Permalink
Port run-make --print=native-static-libs to rmake.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Apr 25, 2024
1 parent cb3752d commit e707ec7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 20 deletions.
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 @@ -221,7 +221,6 @@ run-make/pretty-print-to-file/Makefile
run-make/pretty-print-with-dep-file/Makefile
run-make/print-calling-conventions/Makefile
run-make/print-cfg/Makefile
run-make/print-native-static-libs/Makefile
run-make/print-target-list/Makefile
run-make/profile/Makefile
run-make/prune-link-args/Makefile
Expand Down
19 changes: 0 additions & 19 deletions tests/run-make/print-native-static-libs/Makefile

This file was deleted.

56 changes: 56 additions & 0 deletions tests/run-make/print-native-static-libs/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//! This checks the output of `--print=native-static-libs`

//@ ignore-cross-compile
//@ ignore-wasm

extern crate run_make_support;

use std::io::BufRead;

use run_make_support::rustc;

fn main() {
// build supporting crate
rustc()
.input("bar.rs")
.arg("--crate-type")
.arg("rlib")
.arg("-lbar_cli")
.run();

// build main crate as staticlib
let output = rustc()
.input("foo.rs")
.arg("--crate-type")
.arg("staticlib")
.arg("-lfoo_cli")
.arg("-lfoo_cli") // 2nd time
.arg("--print=native-static-libs")
.run();

let mut found_note = false;
for l in output.stderr.lines() {
let l = l.expect("utf-8 string");

let Some(args) = l.strip_prefix("note: native-static-libs:") else { continue; };
assert!(!found_note);
found_note = true;

let args: Vec<&str> = args.trim().split_ascii_whitespace().collect();

assert!(args.contains(&"-lglib-2.0")); // in bar.rs
assert!(args.contains(&"-lsystemd")); // in foo.rs
assert!(args.contains(&"-lbar_cli"));
assert!(args.contains(&"-lfoo_cli"));

// make sure that no args are consecutively present
let dedup_args: Vec<&str> = {
let mut args = args.clone();
args.dedup();
args
};
assert_eq!(args, dedup_args);
}

assert!(found_note);
}

0 comments on commit e707ec7

Please sign in to comment.