diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 4eb468e..26dca5b 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -28,15 +28,22 @@ jobs: steps: - uses: actions/checkout@v2 - uses: moonrepo/setup-rust@v1 + - uses: extractions/setup-just@v2 - name: Install Rust toolchain run: | rustup default stable rustup update - run: cargo test + - name: Run a full build + run: just build-shader-template + - clippy: + lints: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: moonrepo/setup-rust@v1 - - run: cargo clippy -- --deny warnings + - uses: extractions/setup-just@v2 + - uses: cargo-bins/cargo-binstall@main + - run: just setup-lints + - run: just lints diff --git a/Cargo.lock b/Cargo.lock index d11c416..88ba813 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,7 +91,6 @@ dependencies = [ "relative-path", "serde", "serde_json", - "snafu", "spirv-builder-cli", "test-log", "toml", @@ -531,27 +530,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "snafu" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019" -dependencies = [ - "snafu-derive", -] - -[[package]] -name = "snafu-derive" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "spirv-builder-cli" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 283e9ef..f8122de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ log = "0.4" relative-path = "1.9.3" serde = { version = "1.0.214", features = ["derive"] } serde_json = "1.0.132" -snafu = "0.8.5" toml = "0.8.19" test-log = "0.2.16" diff --git a/crates/cargo-gpu/Cargo.toml b/crates/cargo-gpu/Cargo.toml index 67df799..e6043d1 100644 --- a/crates/cargo-gpu/Cargo.toml +++ b/crates/cargo-gpu/Cargo.toml @@ -17,7 +17,6 @@ log.workspace = true relative-path.workspace = true serde.workspace = true serde_json.workspace = true -snafu.workspace = true toml.workspace = true chrono.workspace = true http.workspace = true diff --git a/crates/cargo-gpu/src/build.rs b/crates/cargo-gpu/src/build.rs index d6c9016..d26718a 100644 --- a/crates/cargo-gpu/src/build.rs +++ b/crates/cargo-gpu/src/build.rs @@ -161,13 +161,17 @@ mod test { &format!("{}", output_dir.display()), ]; if let Cli { - command: Command::Build(mut build), + command: Command::Build(build), } = Cli::parse_from(args) { assert_eq!(shader_crate_path, build.install.shader_crate); assert_eq!(output_dir, build.output_dir); - build.run(); + // TODO: + // For some reason running a full build (`build.run()`) inside tests fails on Windows. + // The error is in the `build.rs` step of compiling `spirv-tools-sys`. It is not clear + // from the logged error what the problem is. For now we'll just run a full build + // outside the tests environment, see `justfile`'s `build-shader-template`. } else { panic!("was not a build command"); } diff --git a/crates/cargo-gpu/src/install.rs b/crates/cargo-gpu/src/install.rs index 7e79533..ca73728 100644 --- a/crates/cargo-gpu/src/install.rs +++ b/crates/cargo-gpu/src/install.rs @@ -146,7 +146,8 @@ impl Install { } } - /// Create the `spirv-builder-cli` crate. + /// Update the `Cargo.toml` file in the `spirv-builder-cli` crate so that it contains + /// the correct version of `spirv-builder-cli`. fn update_cargo_toml(contents: &str, spirv_source: &SpirvSource) -> String { let updated = contents.lines().map(|line| { if line.contains("${AUTO-REPLACE-SOURCE}") { diff --git a/crates/cargo-gpu/src/main.rs b/crates/cargo-gpu/src/main.rs index 1c80d66..364b3e1 100644 --- a/crates/cargo-gpu/src/main.rs +++ b/crates/cargo-gpu/src/main.rs @@ -83,11 +83,11 @@ fn main() { } Command::Build(mut build) => { log::debug!("building with arguments: {build:#?}"); - build.run() + build.run(); } Command::Toml(toml) => { log::debug!("building by toml file with arguments: {toml:#?}"); - toml.run() + toml.run(); } Command::Show(show) => show.run(), Command::DumpUsage => dump_full_usage_for_readme(), diff --git a/crates/cargo-gpu/src/spirv_source.rs b/crates/cargo-gpu/src/spirv_source.rs index 95fcb93..bd2f200 100644 --- a/crates/cargo-gpu/src/spirv_source.rs +++ b/crates/cargo-gpu/src/spirv_source.rs @@ -3,8 +3,6 @@ //! We do this by calling `cargo tree` inside the shader's crate to get the defined `spirv-std` //! version. Then with that we `git checkout` the `rust-gpu` repo that corresponds to that version. //! From there we can look at the source code to get the required Rust toolchain. -//! -//! This is just a test. /// The canonical `rust-gpu` URI const RUST_GPU_REPO: &str = "https://github.com/Rust-GPU/rust-gpu"; @@ -22,8 +20,6 @@ pub enum SpirvSource { /// If the shader specifies a version like: /// `spirv-std = { git = "https://github.com..." ... }` /// then the source of `rust-gpu` is `Git`. - /// - /// `(String, String)` is the repo source and revision hash or tag. Git { /// URL of the repository url: String, @@ -33,8 +29,6 @@ pub enum SpirvSource { /// If the shader specifies a version like: /// `spirv-std = { path = "/path/to/rust-gpu" ... }` /// then the source of `rust-gpu` is `Path`. - /// - /// `(String, String)` is the repo path and the version. Path((String, String)), } @@ -95,7 +89,7 @@ impl SpirvSource { crate::cache_dir().join("rust-gpu-repo").join(dir) } - /// Checkout the `rust-gpu` to the requested version. + /// Checkout the `rust-gpu` repo to the requested version. fn checkout(&self) { log::debug!( "Checking out `rust-gpu` repo at {} to {}", diff --git a/justfile b/justfile new file mode 100644 index 0000000..1f53c29 --- /dev/null +++ b/justfile @@ -0,0 +1,19 @@ +[group: 'ci'] +build-shader-template: + cargo install --path crates/cargo-gpu + cargo gpu install --shader-crate crates/shader-crate-template + cargo gpu build --shader-crate crates/shader-crate-template --output-dir test-shaders + ls -lah test-shaders + cat test-shaders/manifest.json + +[group: 'ci'] +setup-lints: + cargo binstall cargo-shear + +[group: 'ci'] +lints: + cargo clippy -- --deny warnings + cargo fmt --check + # Look for unused crates + cargo shear +