rewrite raw-dylib-custom-dlltool to rmake

This commit is contained in:
Oneirical 2024-07-05 16:33:11 -04:00
parent ae144bfff0
commit b98365871f
5 changed files with 32 additions and 20 deletions

View File

@ -119,7 +119,6 @@ run-make/profile/Makefile
run-make/prune-link-args/Makefile run-make/prune-link-args/Makefile
run-make/raw-dylib-alt-calling-convention/Makefile run-make/raw-dylib-alt-calling-convention/Makefile
run-make/raw-dylib-c/Makefile run-make/raw-dylib-c/Makefile
run-make/raw-dylib-custom-dlltool/Makefile
run-make/raw-dylib-import-name-type/Makefile run-make/raw-dylib-import-name-type/Makefile
run-make/raw-dylib-link-ordinal/Makefile run-make/raw-dylib-link-ordinal/Makefile
run-make/raw-dylib-stdcall-ordinal/Makefile run-make/raw-dylib-stdcall-ordinal/Makefile

View File

@ -1,11 +0,0 @@
# Test using -Cdlltool to change where raw-dylib looks for the dlltool binary.
# only-windows
# only-gnu
# needs-dlltool
include ../tools.mk
all:
$(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs -Cdlltool=$(CURDIR)/script.cmd
$(DIFF) output.txt "$(TMPDIR)"/output.txt

View File

@ -0,0 +1,24 @@
// Instead of using the default dlltool, the rust compiler can also accept a custom
// command file with the -C dlltool flag. This test uses it to compile some rust code
// with the raw_dylib Windows-exclusive feature, and checks that the output contains
// the string passed from the custom dlltool, confirming that the default dlltool was
// successfully overridden.
// See https://github.com/rust-lang/rust/pull/109677
//@ only-windows
//@ only-gnu
//@ needs-dlltool
// Reason: this test specifically checks the custom dlltool feature, only
// available on Windows-gnu.
use run_make_support::{diff, rustc};
fn main() {
let out = rustc()
.crate_type("lib")
.crate_name("raw_dylib_test")
.input("lib.rs")
.arg("-Cdlltool=script.cmd")
.run();
diff().expected_file("output.txt").actual_file("actual.txt").normalize(r#"\r"#, "").run();
}

View File

@ -1,2 +1,2 @@
echo Called dlltool via script.cmd> %TMPDIR%\output.txt echo Called dlltool via script.cmd> actual.txt
dlltool.exe %* dlltool.exe %*

View File

@ -32,8 +32,8 @@ fn main() {
// Make sure we do find an import to the functions we expect to be imported. // Make sure we do find an import to the functions we expect to be imported.
.assert_stdout_contains("library_function"); .assert_stdout_contains("library_function");
if is_msvc() { if is_msvc() {
cc().arg("-c").out_exe("extern_1.obj").input("extern_1.c").run(); cc().arg("-c").out_exe("extern_1").input("extern_1.c").run();
cc().arg("-c").out_exe("extern_2.obj").input("extern_2.c").run(); cc().arg("-c").out_exe("extern_2").input("extern_2.c").run();
cc().input("extern_1.obj") cc().input("extern_1.obj")
.arg("-link") .arg("-link")
.arg("-dll") .arg("-dll")
@ -47,15 +47,15 @@ fn main() {
.arg("-noimplib") .arg("-noimplib")
.run(); .run();
} else { } else {
cc().arg("-v").arg("-c").out_exe("extern_1.obj").input("extern_1.c").run(); cc().arg("-v").arg("-c").out_exe("extern_1").input("extern_1.c").run();
cc().arg("-v").arg("-c").out_exe("extern_2.obj").input("extern_2.c").run(); cc().arg("-v").arg("-c").out_exe("extern_2").input("extern_2.c").run();
cc().input("extern_1.obj").out_exe("extern_1.dll").arg("-shared").run(); cc().input("extern_1").out_exe("extern_1.dll").arg("-shared").run();
cc().input("extern_2.obj").out_exe("extern_2.dll").arg("-shared").run(); cc().input("extern_2").out_exe("extern_2.dll").arg("-shared").run();
} }
let out = run("driver").stdout_utf8(); let out = run("driver").stdout_utf8();
diff() diff()
.expected_file("output.txt") .expected_file("output.txt")
.actual_text("actual_output", out) .actual_text("actual_output", out)
.normalize(r#"\\r"#, "") .normalize(r#"\r"#, "")
.run(); .run();
} }