Skip to content

Commit 428824b

Browse files
authored
Add option to treat warnings as errors (#683)
1 parent 22e4bf4 commit 428824b

File tree

1 file changed

+15
-1
lines changed
  • crates/spirv-builder/src

1 file changed

+15
-1
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub struct SpirvBuilder {
148148
print_metadata: MetadataPrintout,
149149
release: bool,
150150
target: String,
151+
deny_warnings: bool,
151152
bindless: bool,
152153
multimodule: bool,
153154
name_variables: bool,
@@ -170,6 +171,7 @@ impl SpirvBuilder {
170171
print_metadata: MetadataPrintout::Full,
171172
release: true,
172173
target: target.into(),
174+
deny_warnings: false,
173175
bindless: false,
174176
multimodule: false,
175177
name_variables: false,
@@ -191,6 +193,11 @@ impl SpirvBuilder {
191193
self
192194
}
193195

196+
pub fn deny_warnings(mut self, v: bool) -> Self {
197+
self.deny_warnings = v;
198+
self
199+
}
200+
194201
/// Run the compiler in bindless mode, this flag is in preparation for the full feature
195202
/// and it's expected to be the default mode going forward
196203
pub fn bindless(mut self, v: bool) -> Self {
@@ -431,12 +438,19 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
431438
format!(" -C target-feature={}", target_features.join(","))
432439
};
433440

441+
let deny_warnings = if builder.deny_warnings {
442+
" -D warnings"
443+
} else {
444+
""
445+
};
446+
434447
//FIXME: reintroduce v0 mangling, see issue #642
435448
let rustflags = format!(
436-
"-Z codegen-backend={} -Zsymbol-mangling-version=legacy{}{}",
449+
"-Z codegen-backend={} -Zsymbol-mangling-version=legacy{}{}{}",
437450
rustc_codegen_spirv.display(),
438451
feature_flag,
439452
llvm_args,
453+
deny_warnings,
440454
);
441455

442456
let mut cargo = Command::new("cargo");

0 commit comments

Comments
 (0)