Skip to content

Commit e08d597

Browse files
authored
add manifest-file configuration option to BuildArgs (#51)
1 parent d1a00d8 commit e08d597

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

crates/cargo-gpu/src/build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ impl Build {
121121
.collect::<anyhow::Result<Vec<Linkage>>>()?;
122122

123123
// Write the shader manifest json file
124-
let manifest_path = self.build_args.output_dir.join("manifest.json");
124+
let manifest_path = self
125+
.build_args
126+
.output_dir
127+
.join(&self.build_args.manifest_file);
125128
// Sort the contents so the output is deterministic
126129
linkage.sort();
127130
let json = serde_json::to_string_pretty(&linkage)?;

crates/cargo-gpu/src/config.rs

+17
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,21 @@ mod test {
241241
]
242242
);
243243
}
244+
245+
#[test_log::test]
246+
fn rename_manifest_parse() {
247+
let shader_crate_path = crate::test::shader_crate_test_path();
248+
249+
let args = Config::clap_command_with_cargo_config(
250+
&shader_crate_path,
251+
vec![
252+
"gpu".to_owned(),
253+
"build".to_owned(),
254+
"--manifest-file".to_owned(),
255+
"mymanifest".to_owned(),
256+
],
257+
)
258+
.unwrap();
259+
assert_eq!(args.build_args.manifest_file, "mymanifest".to_owned());
260+
}
244261
}

crates/shader-crate-template/Cargo.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rust-gpu-shader-crate-template"
33
version = "0.1.0"
44
edition = "2021"
5-
5+
66
[lib]
77
crate-type = ["rlib", "cdylib"]
88

@@ -25,7 +25,7 @@ glam = { version = "0.29", features = ["std"] }
2525
output-dir = "./"
2626
# Set shader crate's cargo default-features
2727
no_default_features = false
28-
# Set shader crate's cargo features.
28+
# Set shader crate's cargo features.
2929
features = []
3030
# The compile target.
3131
# TODO: `cargo gpu show targets` for all available options.
@@ -51,7 +51,7 @@ spirv-metadata = "None"
5151
relax-struct-store = false
5252
# Allow allocating an object of a pointer type and returning a pointer value from a function
5353
# in logical addressing mode.
54-
relax-logical-pointer = false
54+
relax-logical-pointer = false
5555
# Enable VK_KHR_relaxed_block_layout when checking standard uniform, storage buffer, and push
5656
# constant layouts.
5757
# This is the default when targeting Vulkan 1.1 or later.
@@ -68,6 +68,9 @@ scalar-block-layout = false
6868
skip-block-layout = false
6969
# Preserve unused descriptor bindings. Useful for reflection.
7070
preserve-bindings = false
71+
# Renames the manifest.json file to the given string. Useful if you collect all your SPIR-V fragments
72+
# in one place.
73+
manifest-file = "manifest.json"
7174

7275
[package.metadata.rust-gpu.install]
7376
# Source of `spirv-builder` dependency

crates/spirv-builder-cli/src/args.rs

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ pub struct BuildArgs {
115115
/// Preserve unused descriptor bindings. Useful for reflection.
116116
#[arg(long, default_value = "false")]
117117
pub preserve_bindings: bool,
118+
119+
///Renames the manifest.json file to the given name
120+
#[clap(long, short, default_value = "manifest.json")]
121+
pub manifest_file: String,
118122
}
119123

120124
impl BuildArgs {

crates/xtask/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ fn main() {
122122
.unwrap();
123123

124124
cmd(["ls", "-lah", dir.path().to_str().unwrap()]).unwrap();
125+
//NOTE: manifest.json is the default value here, which should be valid
125126
cmd(["cat", dir.path().join("manifest.json").to_str().unwrap()]).unwrap();
126127
}
127128
}

0 commit comments

Comments
 (0)