Skip to content

Commit

Permalink
Fix for failing Windows build
Browse files Browse the repository at this point in the history
For some reason `spirv-tools-sys` only fails to build on windows when
run from inside `cargo test`. Maybe it's something to do with what gets
set in ENV?

Also added `just` so that we have a canonical way of running CI-related
tasks.
  • Loading branch information
tombh committed Dec 21, 2024
1 parent fc8ecfc commit 2395dd7
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 38 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 0 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion crates/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions crates/cargo-gpu/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
3 changes: 2 additions & 1 deletion crates/cargo-gpu/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}") {
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-gpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 1 addition & 7 deletions crates/cargo-gpu/src/spirv_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand All @@ -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)),
}

Expand Down Expand Up @@ -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 {}",
Expand Down
19 changes: 19 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2395dd7

Please sign in to comment.