Skip to content

Commit 1b1ed8c

Browse files
committed
windows: Skip cmake on MSVC
1 parent 88647e2 commit 1b1ed8c

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

docker/test/fixtures/rust/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
}
2020

2121
cc::Build::new().file("hello_c.c").compile("hello_c");
22-
if target_os == "openbsd" || target_os == "windows" && target_env == "gnu" {
22+
if target_os == "openbsd" || target_os == "windows" {
2323
} else {
2424
// Make sure that the link with libc works.
2525
println!("cargo:rustc-link-lib=c");
@@ -37,6 +37,11 @@ fn main() {
3737
);
3838
}
3939

40+
// TODO(windows-msvc):
41+
if target_os == "windows" && target_env == "msvc" {
42+
println!("cargo:rustc-cfg=no_cmake");
43+
return;
44+
}
4045
let cmake_dst = cmake::build("libhello_cmake");
4146
println!("cargo:rustc-link-search=native={}", cmake_dst.display());
4247
println!("cargo:rustc-link-lib=static=hello_cmake");

docker/test/fixtures/rust/src/main.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern "C" {
55
fn hello_c();
66
#[cfg(feature = "cpp")]
77
fn hello_cpp();
8+
#[cfg(not(no_cmake))]
89
fn hello_cmake(input: std::os::raw::c_int) -> std::os::raw::c_int;
910
}
1011

@@ -16,11 +17,14 @@ fn main() {
1617
#[cfg(feature = "cpp")]
1718
hello_cpp();
1819

19-
let input = 4;
20-
let output = hello_cmake(input);
21-
assert_eq!(output, 8);
22-
println!("Hello Cmake from Rust!");
23-
println!("{input} * 2 = {output}");
20+
#[cfg(not(no_cmake))]
21+
{
22+
let input = 4;
23+
let output = hello_cmake(input);
24+
assert_eq!(output, 8);
25+
println!("Hello Cmake from Rust!");
26+
println!("{input} * 2 = {output}");
27+
}
2428
}
2529
}
2630

@@ -36,11 +40,14 @@ mod tests {
3640
#[cfg(feature = "cpp")]
3741
hello_cpp();
3842

39-
let input = 4;
40-
let output = hello_cmake(input);
41-
assert_eq!(output, 8);
42-
println!("Hello Cmake from Rust!");
43-
println!("{input} * 2 = {output}");
43+
#[cfg(not(no_cmake))]
44+
{
45+
let input = 4;
46+
let output = hello_cmake(input);
47+
assert_eq!(output, 8);
48+
println!("Hello Cmake from Rust!");
49+
println!("{input} * 2 = {output}");
50+
}
4451
}
4552
}
4653
}

0 commit comments

Comments
 (0)