Skip to content

Commit

Permalink
generator: Demote vk-parse error-asserts to a warning message
Browse files Browse the repository at this point in the history
When `vk-parse` encounters XML parsing errors (e.g. on unknown attributes
or elements) it skips the element and emits an error in a list of errors
that are returned to the caller.  We were originally never checking
these leading to hard-to-debug issues, but eventually started asserting
on this list being empty or otherwise panicking in #930.

Since `ash`'s generator is used in Khronos' upstream CI (in a fallible
yet warning way), any new attribute would cause the generator to fail
and subsequently require updates to `vk-parse` and `ash` before their
CI is no longer flagged as "succeeded with warnings".  "Solve" this by
once again allowing errors to exist, while still at least printing them
to `stderr` for insights (that were previously missing...) to anyone
running the generator.

Note that this once again allows the generator to fail further in the
chain when expected elements are missing, in which case an update is
required either way.  If this happens often we can adjust `vk-parse` to
be more lenient in still emitting errors but continuing to parse said
element, if the new/unrecognized elements or attributes are considered
harmless to the parsing process.
  • Loading branch information
MarijnS95 committed Nov 13, 2024
1 parent bbd8288 commit 6a43adc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3079,10 +3079,9 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
use std::fs::File;
use std::io::Write;
let (spec2, errors) = vk_parse::parse_file(&vk_xml).expect("Invalid xml file");
assert!(
errors.is_empty(),
"vk_parse encountered one or more errors while parsing: {errors:?}"
);
if !errors.is_empty() {
eprintln!("vk_parse encountered one or more errors while parsing: {errors:?}")
}
let extensions: Vec<&vk_parse::Extension> = spec2
.0
.iter()
Expand Down

0 comments on commit 6a43adc

Please sign in to comment.