From dba894774566be7fa509dcf30bcb89cca40d45a7 Mon Sep 17 00:00:00 2001 From: John Barker Date: Mon, 12 Aug 2019 22:24:27 -0600 Subject: [PATCH 1/4] Add failing test case for cross compiling in a workspace module --- tests/testsuite/workspaces.rs | 53 ++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 35ec7a52e75..88a37d3fa34 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -4,7 +4,7 @@ use std::io::{Read, Write}; use crate::support::registry::Package; use crate::support::sleep_ms; -use crate::support::{basic_lib_manifest, basic_manifest, git, project}; +use crate::support::{basic_lib_manifest, basic_manifest, cross_compile, git, project}; #[cargo_test] fn simple_explicit() { @@ -2173,3 +2173,54 @@ Caused by: ) .run(); } + +#[cargo_test] +fn simple_with_build_config() { + if cross_compile::disabled() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [workspace] + members = ["bar"] + "#, + ) + .file( + "bar/.cargo/config", + &format!( + r#" + [build] + target = "{}" + "#, + cross_compile::alternate() + ), + ) + .file("src/main.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + workspace = ".." + "#, + ) + .file("bar/src/main.rs", "fn main() {}"); + let p = p.build(); + + p.cargo("build --all").run(); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); + + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); +} From ac84c77f8aed185952dec5cad60d4dae977a7eb6 Mon Sep 17 00:00:00 2001 From: John Barker Date: Mon, 12 Aug 2019 22:24:38 -0600 Subject: [PATCH 2/4] Just use bare wasm target for now, OS X can't cross compile --- tests/testsuite/workspaces.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 88a37d3fa34..529e9c8057f 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2176,10 +2176,6 @@ Caused by: #[cargo_test] fn simple_with_build_config() { - if cross_compile::disabled() { - return; - } - let p = project() .file( "Cargo.toml", @@ -2195,13 +2191,10 @@ fn simple_with_build_config() { ) .file( "bar/.cargo/config", - &format!( - r#" - [build] - target = "{}" - "#, - cross_compile::alternate() - ), + r#" + [build] + target = "wasm32-unknown-unknown" + "#, ) .file("src/main.rs", "fn main() {}") .file( From 1057415677b2b911668a89c63dea323f1ff647a6 Mon Sep 17 00:00:00 2001 From: John Barker Date: Mon, 12 Aug 2019 22:24:44 -0600 Subject: [PATCH 3/4] Use a custom target that guarantees a .wasm file ouptut, check for .wasm --- tests/testsuite/workspaces.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 529e9c8057f..68fab37d477 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2193,9 +2193,17 @@ fn simple_with_build_config() { "bar/.cargo/config", r#" [build] - target = "wasm32-unknown-unknown" + target-file = "target.json" "#, ) + .file( + "bar/.cargo/target.json", + r#" + { + "dll-suffix": ".wasm", + } + "#, + ) .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", @@ -2212,7 +2220,7 @@ fn simple_with_build_config() { p.cargo("build --all").run(); assert!(p.bin("foo").is_file()); - assert!(p.bin("bar").is_file()); + assert!(p.target_debug_dir().join("bar.wasm").is_file()); assert!(p.root().join("Cargo.lock").is_file()); assert!(!p.root().join("bar/Cargo.lock").is_file()); From 16267a70364c79ac3922731dfa4b127d74fcc25d Mon Sep 17 00:00:00 2001 From: John Barker Date: Mon, 12 Aug 2019 22:24:50 -0600 Subject: [PATCH 4/4] Make sure module is a lib --- tests/testsuite/workspaces.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 68fab37d477..3b6e6f22b27 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2213,9 +2213,12 @@ fn simple_with_build_config() { version = "0.1.0" authors = [] workspace = ".." + + [lib] + crate-type = ["cdylib"] "#, ) - .file("bar/src/main.rs", "fn main() {}"); + .file("bar/src/lib.rs", "fn main() {}"); let p = p.build(); p.cargo("build --all").run();