Skip to content

Commit 2395dd7

Browse files
committed
Fix for failing Windows build
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.
1 parent fc8ecfc commit 2395dd7

File tree

9 files changed

+39
-38
lines changed

9 files changed

+39
-38
lines changed

.github/workflows/push.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@ jobs:
2828
steps:
2929
- uses: actions/checkout@v2
3030
- uses: moonrepo/setup-rust@v1
31+
- uses: extractions/setup-just@v2
3132
- name: Install Rust toolchain
3233
run: |
3334
rustup default stable
3435
rustup update
3536
- run: cargo test
37+
- name: Run a full build
38+
run: just build-shader-template
39+
3640

37-
clippy:
41+
lints:
3842
runs-on: ubuntu-latest
3943
steps:
4044
- uses: actions/checkout@v2
4145
- uses: moonrepo/setup-rust@v1
42-
- run: cargo clippy -- --deny warnings
46+
- uses: extractions/setup-just@v2
47+
- uses: cargo-bins/cargo-binstall@main
48+
- run: just setup-lints
49+
- run: just lints

Cargo.lock

Lines changed: 0 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ log = "0.4"
2424
relative-path = "1.9.3"
2525
serde = { version = "1.0.214", features = ["derive"] }
2626
serde_json = "1.0.132"
27-
snafu = "0.8.5"
2827
toml = "0.8.19"
2928
test-log = "0.2.16"
3029

crates/cargo-gpu/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ log.workspace = true
1717
relative-path.workspace = true
1818
serde.workspace = true
1919
serde_json.workspace = true
20-
snafu.workspace = true
2120
toml.workspace = true
2221
chrono.workspace = true
2322
http.workspace = true

crates/cargo-gpu/src/build.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@ mod test {
161161
&format!("{}", output_dir.display()),
162162
];
163163
if let Cli {
164-
command: Command::Build(mut build),
164+
command: Command::Build(build),
165165
} = Cli::parse_from(args)
166166
{
167167
assert_eq!(shader_crate_path, build.install.shader_crate);
168168
assert_eq!(output_dir, build.output_dir);
169169

170-
build.run();
170+
// TODO:
171+
// For some reason running a full build (`build.run()`) inside tests fails on Windows.
172+
// The error is in the `build.rs` step of compiling `spirv-tools-sys`. It is not clear
173+
// from the logged error what the problem is. For now we'll just run a full build
174+
// outside the tests environment, see `justfile`'s `build-shader-template`.
171175
} else {
172176
panic!("was not a build command");
173177
}

crates/cargo-gpu/src/install.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ impl Install {
146146
}
147147
}
148148

149-
/// Create the `spirv-builder-cli` crate.
149+
/// Update the `Cargo.toml` file in the `spirv-builder-cli` crate so that it contains
150+
/// the correct version of `spirv-builder-cli`.
150151
fn update_cargo_toml(contents: &str, spirv_source: &SpirvSource) -> String {
151152
let updated = contents.lines().map(|line| {
152153
if line.contains("${AUTO-REPLACE-SOURCE}") {

crates/cargo-gpu/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ fn main() {
8383
}
8484
Command::Build(mut build) => {
8585
log::debug!("building with arguments: {build:#?}");
86-
build.run()
86+
build.run();
8787
}
8888
Command::Toml(toml) => {
8989
log::debug!("building by toml file with arguments: {toml:#?}");
90-
toml.run()
90+
toml.run();
9191
}
9292
Command::Show(show) => show.run(),
9393
Command::DumpUsage => dump_full_usage_for_readme(),

crates/cargo-gpu/src/spirv_source.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! We do this by calling `cargo tree` inside the shader's crate to get the defined `spirv-std`
44
//! version. Then with that we `git checkout` the `rust-gpu` repo that corresponds to that version.
55
//! From there we can look at the source code to get the required Rust toolchain.
6-
//!
7-
//! This is just a test.
86
97
/// The canonical `rust-gpu` URI
108
const RUST_GPU_REPO: &str = "https://github.com/Rust-GPU/rust-gpu";
@@ -22,8 +20,6 @@ pub enum SpirvSource {
2220
/// If the shader specifies a version like:
2321
/// `spirv-std = { git = "https://github.com..." ... }`
2422
/// then the source of `rust-gpu` is `Git`.
25-
///
26-
/// `(String, String)` is the repo source and revision hash or tag.
2723
Git {
2824
/// URL of the repository
2925
url: String,
@@ -33,8 +29,6 @@ pub enum SpirvSource {
3329
/// If the shader specifies a version like:
3430
/// `spirv-std = { path = "/path/to/rust-gpu" ... }`
3531
/// then the source of `rust-gpu` is `Path`.
36-
///
37-
/// `(String, String)` is the repo path and the version.
3832
Path((String, String)),
3933
}
4034

@@ -95,7 +89,7 @@ impl SpirvSource {
9589
crate::cache_dir().join("rust-gpu-repo").join(dir)
9690
}
9791

98-
/// Checkout the `rust-gpu` to the requested version.
92+
/// Checkout the `rust-gpu` repo to the requested version.
9993
fn checkout(&self) {
10094
log::debug!(
10195
"Checking out `rust-gpu` repo at {} to {}",

justfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[group: 'ci']
2+
build-shader-template:
3+
cargo install --path crates/cargo-gpu
4+
cargo gpu install --shader-crate crates/shader-crate-template
5+
cargo gpu build --shader-crate crates/shader-crate-template --output-dir test-shaders
6+
ls -lah test-shaders
7+
cat test-shaders/manifest.json
8+
9+
[group: 'ci']
10+
setup-lints:
11+
cargo binstall cargo-shear
12+
13+
[group: 'ci']
14+
lints:
15+
cargo clippy -- --deny warnings
16+
cargo fmt --check
17+
# Look for unused crates
18+
cargo shear
19+

0 commit comments

Comments
 (0)