Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 217388e

Browse files
committed
fix: run cargo update before building spirv-builder-cli
1 parent f3d13dc commit 217388e

5 files changed

Lines changed: 384 additions & 89 deletions

File tree

crates/cargo-gpu/src/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ impl Config {
104104
}
105105
(left, right) => {
106106
if let Some(pointer) = maybe_pointer {
107-
let default = defaults
108-
.pointer(pointer)
109-
.context(format!("Config `{pointer}` not found in defaults"))?;
107+
let default = defaults.pointer(pointer).context(format!(
108+
"Configuration option with path `{pointer}` was not found in the default configuration, \
109+
which is:\ndefaults: {defaults:#?}"
110+
))?;
110111
if &right != default {
111112
// Only overwrite if the new value differs from the defaults.
112113
*left = right;

crates/cargo-gpu/src/install.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,35 @@ impl Install {
221221
self.spirv_install.shader_crate.display()
222222
);
223223

224-
let mut command = std::process::Command::new("cargo");
225-
command
224+
// Run a `cargo update` just in case the cached Cargo.lock we copied over
225+
// is a bit behind what's in rust-gpu
226+
let mut update_command = std::process::Command::new("cargo");
227+
update_command.current_dir(&checkout).arg("update");
228+
let update_output = update_command
229+
.stdout(std::process::Stdio::inherit())
230+
.stderr(std::process::Stdio::inherit())
231+
.output()?;
232+
anyhow::ensure!(update_output.status.success(), "...cargo update error!");
233+
234+
let mut build_command = std::process::Command::new("cargo");
235+
build_command
226236
.current_dir(&checkout)
227237
.arg(format!("+{}", spirv_version.channel))
228238
.args(["build", "--release"])
229239
.args(["--no-default-features"]);
230240

231-
command.args([
241+
build_command.args([
232242
"--features",
233243
&Self::get_required_spirv_builder_version(spirv_version.date)?,
234244
]);
235245

236-
log::debug!("building artifacts with `{:?}`", command);
246+
log::debug!("building artifacts with `{:?}`", build_command);
237247

238-
let output = command
248+
let build_output = build_command
239249
.stdout(std::process::Stdio::inherit())
240250
.stderr(std::process::Stdio::inherit())
241251
.output()?;
242-
anyhow::ensure!(output.status.success(), "...build error!");
252+
anyhow::ensure!(build_output.status.success(), "...build error!");
243253

244254
if dylib_path.is_file() {
245255
log::info!("successfully built {}", dylib_path.display());

crates/cargo-gpu/src/metadata.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ impl Metadata {
4747
let mut metadata = crate::config::Config::defaults_as_json()?;
4848
crate::config::Config::json_merge(
4949
&mut metadata,
50-
Self::get_workspace_metadata(cargo_json),
50+
{
51+
log::debug!("looking for workspace metadata");
52+
let ws_meta = Self::get_workspace_metadata(cargo_json);
53+
log::trace!("workspace_metadata: {ws_meta:#?}");
54+
ws_meta
55+
},
5156
None,
5257
)?;
5358
crate::config::Config::json_merge(
5459
&mut metadata,
55-
Self::get_crate_metadata(cargo_json, path)?,
60+
{
61+
log::debug!("looking for crate metadata");
62+
let crate_meta = Self::get_crate_metadata(cargo_json, path)?;
63+
log::trace!("crate_metadata: {crate_meta:#?}");
64+
crate_meta
65+
},
5666
None,
5767
)?;
5868

@@ -118,6 +128,7 @@ impl Metadata {
118128
let manifest_path = manifest_path_dirty.replace(r"\\?\", "");
119129
log::debug!("Matching shader crate path with manifest path: {shader_crate_path} == {manifest_path}?");
120130
if manifest_path == shader_crate_path {
131+
log::debug!("...matches! Getting metadata");
121132
let mut metadata = package
122133
.pointer("/metadata/rust-gpu")
123134
.unwrap_or(&empty_json_object)

0 commit comments

Comments
 (0)