Add option to treat warnings as errors (#683)

This commit is contained in:
Ashley Hauck 2021-06-22 15:44:51 +02:00 committed by GitHub
parent 22e4bf4022
commit 428824be94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,6 +148,7 @@ pub struct SpirvBuilder {
print_metadata: MetadataPrintout, print_metadata: MetadataPrintout,
release: bool, release: bool,
target: String, target: String,
deny_warnings: bool,
bindless: bool, bindless: bool,
multimodule: bool, multimodule: bool,
name_variables: bool, name_variables: bool,
@ -170,6 +171,7 @@ impl SpirvBuilder {
print_metadata: MetadataPrintout::Full, print_metadata: MetadataPrintout::Full,
release: true, release: true,
target: target.into(), target: target.into(),
deny_warnings: false,
bindless: false, bindless: false,
multimodule: false, multimodule: false,
name_variables: false, name_variables: false,
@ -191,6 +193,11 @@ impl SpirvBuilder {
self self
} }
pub fn deny_warnings(mut self, v: bool) -> Self {
self.deny_warnings = v;
self
}
/// Run the compiler in bindless mode, this flag is in preparation for the full feature /// Run the compiler in bindless mode, this flag is in preparation for the full feature
/// and it's expected to be the default mode going forward /// and it's expected to be the default mode going forward
pub fn bindless(mut self, v: bool) -> Self { pub fn bindless(mut self, v: bool) -> Self {
@ -431,12 +438,19 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
format!(" -C target-feature={}", target_features.join(",")) format!(" -C target-feature={}", target_features.join(","))
}; };
let deny_warnings = if builder.deny_warnings {
" -D warnings"
} else {
""
};
//FIXME: reintroduce v0 mangling, see issue #642 //FIXME: reintroduce v0 mangling, see issue #642
let rustflags = format!( let rustflags = format!(
"-Z codegen-backend={} -Zsymbol-mangling-version=legacy{}{}", "-Z codegen-backend={} -Zsymbol-mangling-version=legacy{}{}{}",
rustc_codegen_spirv.display(), rustc_codegen_spirv.display(),
feature_flag, feature_flag,
llvm_args, llvm_args,
deny_warnings,
); );
let mut cargo = Command::new("cargo"); let mut cargo = Command::new("cargo");