Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: Add dump-before-validation option. #2468

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ struct Args {
#[argh(switch)]
version: bool,

/// dump IR before validation
#[argh(option)]
dump_before_validation: Option<String>,

/// the input and output files.
///
/// First positional argument is the input file. If not specified, the
Expand Down Expand Up @@ -331,6 +335,16 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
_ => return Err(CliError("Unknown input file extension").into()),
};

// If requested, dump the IR before validation. Note that this is
// not equivalent to the `"txt"` output, because that includes the
// `ModuleInfo` produced by validation; this obviously cannot.
if let Some(ref dump_before_validation) = args.dump_before_validation {
use std::io::Write;

let mut file = fs::File::create(dump_before_validation)?;
writeln!(file, "{module:#?}")?;
}

// Decide which capabilities our output formats can support.
let validation_caps =
output_paths
Expand Down