compiletest: move the deps helper package into the workspace. (#511)

This commit is contained in:
Eduard-Mihai Burtescu 2021-03-19 19:34:08 +02:00 committed by GitHub
parent 3bc8a8076b
commit 3315e13528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 46 deletions

8
Cargo.lock generated
View File

@ -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"

View File

@ -14,6 +14,7 @@ members = [
"crates/spirv-std",
"tests",
"tests/deps-helper",
]
# Compile build-dependencies in release mode with

View File

@ -0,0 +1,17 @@
[package]
name = "compiletests-deps-helper"
version = "0.0.0"
description = "Shared dependencies of all the compiletest tests"
authors = ["Embark <opensource@embark-studios.com>"]
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"]

View File

@ -0,0 +1 @@
#![no_std]

View File

@ -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 <opensource@embark-studios.com>"]
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,