diff --git a/Cargo.lock b/Cargo.lock index 6fd0114b00..7ad37e5015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,6 +371,14 @@ dependencies = [ "rustc_codegen_spirv", ] +[[package]] +name = "compiletests-deps-helper" +version = "0.0.0" +dependencies = [ + "glam", + "spirv-std", +] + [[package]] name = "compute-shader" version = "0.4.0-alpha.0" diff --git a/Cargo.toml b/Cargo.toml index d2b4a26a33..7f91fe2c7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "crates/spirv-std", "tests", + "tests/deps-helper", ] # Compile build-dependencies in release mode with diff --git a/tests/deps-helper/Cargo.toml b/tests/deps-helper/Cargo.toml new file mode 100644 index 0000000000..87fdffcd85 --- /dev/null +++ b/tests/deps-helper/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "compiletests-deps-helper" +version = "0.0.0" +description = "Shared dependencies of all the compiletest tests" +authors = ["Embark "] +edition = "2018" +license = "MIT OR Apache-2.0" +publish = false + +[dependencies] +spirv-std = { path = "../../crates/spirv-std", features = ["const-generics"] } + +[dependencies.glam] +git = "https://github.com/bitshifter/glam-rs.git" +rev = "b3e94fb" +default-features = false +features = ["libm", "scalar-math"] diff --git a/tests/deps-helper/src/lib.rs b/tests/deps-helper/src/lib.rs new file mode 100644 index 0000000000..0c9ac1ac8e --- /dev/null +++ b/tests/deps-helper/src/lib.rs @@ -0,0 +1 @@ +#![no_std] diff --git a/tests/src/main.rs b/tests/src/main.rs index f5995e99d5..21939301d6 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -6,34 +6,9 @@ use std::{ const TARGET: &str = "spirv-unknown-unknown"; const TARGET_DIR: &str = "target/compiletest"; -const TEST_DEPS_PATH: &str = "target/compiletest/test-deps"; -const TEST_DEPS_TOML_PATH: &str = "target/compiletest/test-deps/Cargo.toml"; const SPIRV_STD_TARGET: &str = "target/compiletest/spirv-std"; const SPIRV_STD_HOST_DEPS: &str = "target/compiletest/spirv-std/debug/deps"; const SPIRV_STD_TARGET_DEPS: &str = "target/compiletest/spirv-std/spirv-unknown-unknown/debug/deps"; -const CARGO_TOML: &str = r#"[package] -name = "test-deps" -version = "0.1.0" -description = "Shared dependencies of all the tests" -authors = ["Embark "] -edition = "2018" - -[dependencies] -spirv-std = { path = "../../../crates/spirv-std", features=["const-generics"] } - -[dependencies.glam] -git = "https://github.com/bitshifter/glam-rs.git" -rev="b3e94fb" -default-features=false -features = ["libm", "scalar-math"] - -# Patch glam's dependency on spirv-std with our local version. -[patch.crates-io] -spirv-std-macros = { path = "../../../crates/spirv-std-macros" } -spirv-std = { path = "../../../crates/spirv-std" } - -[workspace] -"#; fn main() { let manifest_dir = PathBuf::from("./"); @@ -104,30 +79,12 @@ fn run_mode(mode: &'static str, codegen_backend_path: &Path, libs: &TestDeps) { fn build_spirv_std(manifest_dir: &Path, codegen_backend_path: &Path) -> TestDeps { let target_dir = format!("--target-dir={}", SPIRV_STD_TARGET); - // Create a new test-deps project. - if std::fs::metadata(TEST_DEPS_PATH).is_err() { - std::process::Command::new("cargo") - .args(&["new", "-q", "--lib", TEST_DEPS_PATH]) - .current_dir(manifest_dir) - .stderr(std::process::Stdio::inherit()) - .stdout(std::process::Stdio::inherit()) - .status() - .and_then(map_status_to_result) - .unwrap(); - - std::fs::write(TEST_DEPS_TOML_PATH, CARGO_TOML.as_bytes()).unwrap(); - std::fs::write( - PathBuf::from(TEST_DEPS_PATH).join("src/lib.rs"), - "#![no_std]", - ) - .unwrap(); - } - - // Build test-deps + // Build compiletests-deps-helper std::process::Command::new("cargo") .args(&[ "build", - &*format!("--manifest-path={}", TEST_DEPS_TOML_PATH), + "-p", + "compiletests-deps-helper", "-Zbuild-std=core", &*format!("--target={}", TARGET), &*target_dir,