Skip to content

Commit 2bff512

Browse files
committed
Small fixes
1 parent c92b3dc commit 2bff512

File tree

8 files changed

+30
-34
lines changed

8 files changed

+30
-34
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
exclude = [
1010
# This currently needs to be excluded because it depends on a version of `rust-gpu` that
1111
# uses a toolchain whose Cargo version doesn't recognise version 4 of `Cargo.lock`.
12-
"crates/shader-crate-template"
12+
"crates/shader-crate-template",
1313
]
1414

1515
resolver = "2"
@@ -38,7 +38,6 @@ tempfile = "3.22"
3838
test-log = "0.2.18"
3939
cargo_metadata = "0.21.0"
4040
cargo-util-schemas = "0.8.2"
41-
semver = "1.0.26"
4241
dunce = "1.0.5"
4342

4443
# This crate MUST NEVER be upgraded, we need this particular "first" version to support old rust-gpu builds

crates/cargo-gpu-build/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ license.workspace = true
1111
rustc_codegen_spirv-cache = { path = "../rustc_codegen_spirv-cache" }
1212
dunce.workspace = true
1313
thiserror.workspace = true
14-
semver.workspace = true
1514
log.workspace = true
1615

1716
[features]

crates/cargo-gpu-build/src/lockfile.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use std::{
1212
path::{Path, PathBuf},
1313
};
1414

15-
use rustc_codegen_spirv_cache::spirv_builder::query_rustc_version;
16-
use semver::Version;
15+
use crate::spirv_cache::{cargo_metadata::semver::Version, spirv_builder::query_rustc_version};
1716

1817
/// `Cargo.lock` manifest version 4 became the default in Rust 1.83.0. Conflicting manifest
1918
/// versions between the workspace and the shader crate, can cause problems.

crates/cargo-gpu/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ default-run = "cargo-gpu"
1212
[dependencies]
1313
cargo-gpu-build = { path = "../cargo-gpu-build", features = ["clap", "watch"] }
1414
spirv-builder = { workspace = true, features = ["clap", "watch"] }
15-
cargo_metadata.workspace = true
1615
anyhow.workspace = true
1716
thiserror.workspace = true
1817
clap.workspace = true

crates/cargo-gpu/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
#![expect(clippy::pub_use, reason = "part of public API")]
2222

23-
pub use cargo_gpu_build::spirv_cache;
23+
pub use cargo_gpu_build::{spirv_builder, spirv_cache};
2424

2525
pub use self::spirv_cache::backend::Install;
2626

@@ -64,6 +64,7 @@ pub enum Command {
6464
/// A hidden command that can be used to recursively print out all the subcommand help messages:
6565
/// `cargo gpu dump-usage`
6666
/// Useful for updating the README.
67+
#[doc(hidden)]
6768
#[clap(hide(true))]
6869
DumpUsage,
6970
}

crates/cargo-gpu/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Get config from the shader crate's `Cargo.toml` `[*.metadata.rust-gpu.*]`
22
3-
use cargo_metadata::MetadataCommand;
3+
use cargo_gpu_build::spirv_cache::cargo_metadata::{self, MetadataCommand};
44
use serde_json::Value;
55

66
/// `Metadata` refers to the `[metadata.*]` section of `Cargo.toml` that `cargo` formally

crates/rustc_codegen_spirv-cache/src/backend.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ use std::{
1919
process::Stdio,
2020
};
2121

22-
use spirv_builder::{cargo_cmd::CargoCmd, SpirvBuilder, SpirvBuilderError};
23-
2422
use crate::{
2523
cache::{cache_dir, CacheDirError},
2624
command::{execute_command, CommandExecError},
2725
metadata::{query_metadata, MetadataExt as _, MissingPackageError, QueryMetadataError},
26+
spirv_builder::{cargo_cmd::CargoCmd, SpirvBuilder, SpirvBuilderError},
2827
spirv_source::{
2928
rust_gpu_toolchain_channel, RustGpuToolchainChannelError, SpirvSource, SpirvSourceError,
3029
},
@@ -201,28 +200,7 @@ impl Install {
201200
fs::File::create(src.join("lib.rs")).map_err(InstallError::CreateDummyLibRs)?;
202201

203202
log::trace!("writing dummy Cargo.toml");
204-
205-
/// Contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate.
206-
#[expect(clippy::items_after_statements, reason = "local constant")]
207-
const DUMMY_CARGO_TOML: &str = include_str!("dummy/Cargo.toml");
208-
209-
let version_spec = match &source {
210-
SpirvSource::CratesIO(version) => format!("version = \"{version}\""),
211-
SpirvSource::Git { url, rev } => format!("git = \"{url}\"\nrev = \"{rev}\""),
212-
SpirvSource::Path {
213-
rust_gpu_repo_root,
214-
version,
215-
} => {
216-
// this branch is currently unreachable, as we just build `rustc_codegen_spirv` directly,
217-
// since we don't need the `dummy` crate to make cargo download it for us
218-
let mut new_path = rust_gpu_repo_root.to_owned();
219-
new_path.push("crates/spirv-builder");
220-
format!("path = \"{new_path}\"\nversion = \"{version}\"")
221-
}
222-
};
223-
224-
let cargo_toml = format!("{DUMMY_CARGO_TOML}{version_spec}\n");
225-
fs::write(checkout.join("Cargo.toml"), cargo_toml)
203+
fs::write(checkout.join("Cargo.toml"), dummy_cargo_toml(source))
226204
.map_err(InstallError::WriteDummyCargoToml)?;
227205

228206
Ok(())
@@ -411,7 +389,7 @@ impl<W, T, C, O, E> InstallRunParams<W, T, C, O, E> {
411389
}
412390

413391
/// [`Default`] parameters for [`Install::run()`].
414-
type DefaultInstallRunParams = InstallRunParams<
392+
pub type DefaultInstallRunParams = InstallRunParams<
415393
io::Empty,
416394
NoopOnToolchainInstall,
417395
NoopOnComponentsInstall,
@@ -439,6 +417,28 @@ fn dylib_filename(name: impl AsRef<str>) -> String {
439417
format!("{DLL_PREFIX}{str_name}{DLL_SUFFIX}")
440418
}
441419

420+
/// Contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate
421+
/// without the version specification of the `rustc_codegen_spirv` dependency.
422+
const DUMMY_CARGO_TOML_NO_VERSION_SPEC: &str = include_str!("dummy/Cargo.toml");
423+
424+
/// Returns the contents of the `Cargo.toml` file for the local `rustc_codegen_spirv_dummy` crate.
425+
fn dummy_cargo_toml(source: &SpirvSource) -> String {
426+
let version_spec = match source {
427+
SpirvSource::CratesIO(version) => format!("version = \"{version}\""),
428+
SpirvSource::Git { url, rev } => format!("git = \"{url}\"\nrev = \"{rev}\""),
429+
SpirvSource::Path {
430+
rust_gpu_repo_root,
431+
version,
432+
} => {
433+
// this branch is currently unreachable, as we just build `rustc_codegen_spirv` directly,
434+
// since we don't need the `dummy` crate to make cargo download it for us
435+
let new_path = rust_gpu_repo_root.join("crates").join("spirv-builder");
436+
format!("path = \"{new_path}\"\nversion = \"{version}\"")
437+
}
438+
};
439+
format!("{DUMMY_CARGO_TOML_NO_VERSION_SPEC}{version_spec}\n")
440+
}
441+
442442
/// An error indicating codegen `rustc_codegen_spirv` installation failure.
443443
#[derive(Debug, thiserror::Error)]
444444
#[non_exhaustive]

0 commit comments

Comments
 (0)