mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
fix(naga-cli): allow output files with --stdin-file-path
This commit is contained in:
parent
4e47ba4ac0
commit
16f012bc93
@ -40,11 +40,12 @@ Bottom level categories:
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
## New Features
|
### New Features
|
||||||
|
|
||||||
### Naga
|
#### Naga
|
||||||
|
|
||||||
- Parse `diagnostic(…)` directives, but don't implement any triggering rules yet. By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456).
|
- Parse `diagnostic(…)` directives, but don't implement any triggering rules yet. By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456).
|
||||||
|
- Fix an issue where `naga` CLI would incorrectly skip the first positional argument when `--stdin-file-path` was specified. By @ErichDonGubler in [#6480](https://github.com/gfx-rs/wgpu/pull/6480).
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
@ -451,13 +451,15 @@ fn run() -> anyhow::Result<()> {
|
|||||||
return bulk_validate(args, ¶ms);
|
return bulk_validate(args, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (input_path, input) = if let Some(path) = args.files.first() {
|
let mut files = args.files.iter();
|
||||||
let path = Path::new(path);
|
|
||||||
(path, fs::read(path)?)
|
let (input_path, input) = if let Some(path) = args.stdin_file_path.as_ref() {
|
||||||
} else if let Some(path) = &args.stdin_file_path {
|
|
||||||
let mut input = vec![];
|
let mut input = vec![];
|
||||||
std::io::stdin().lock().read_to_end(&mut input)?;
|
std::io::stdin().lock().read_to_end(&mut input)?;
|
||||||
(Path::new(path), input)
|
(Path::new(path), input)
|
||||||
|
} else if let Some(path) = files.next() {
|
||||||
|
let path = Path::new(path);
|
||||||
|
(path, fs::read(path)?)
|
||||||
} else {
|
} else {
|
||||||
return Err(CliError("Input file path is not specified").into());
|
return Err(CliError("Input file path is not specified").into());
|
||||||
};
|
};
|
||||||
@ -492,12 +494,12 @@ fn run() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let output_paths = args.files.get(1..).unwrap_or(&[]);
|
let output_paths = files;
|
||||||
|
|
||||||
// Decide which capabilities our output formats can support.
|
// Decide which capabilities our output formats can support.
|
||||||
let validation_caps =
|
let validation_caps =
|
||||||
output_paths
|
output_paths
|
||||||
.iter()
|
.clone()
|
||||||
.fold(naga::valid::Capabilities::all(), |caps, path| {
|
.fold(naga::valid::Capabilities::all(), |caps, path| {
|
||||||
use naga::valid::Capabilities as C;
|
use naga::valid::Capabilities as C;
|
||||||
let missing = match Path::new(path).extension().and_then(|ex| ex.to_str()) {
|
let missing = match Path::new(path).extension().and_then(|ex| ex.to_str()) {
|
||||||
@ -567,7 +569,7 @@ fn run() -> anyhow::Result<()> {
|
|||||||
//
|
//
|
||||||
// If the user asked for output, don't stop: some output formats (".txt",
|
// If the user asked for output, don't stop: some output formats (".txt",
|
||||||
// ".dot", ".bin") can be generated even without a `ModuleInfo`.
|
// ".dot", ".bin") can be generated even without a `ModuleInfo`.
|
||||||
if output_paths.is_empty() {
|
if output_paths.clone().next().is_none() {
|
||||||
if info.is_some() {
|
if info.is_some() {
|
||||||
println!("Validation successful");
|
println!("Validation successful");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
Loading…
Reference in New Issue
Block a user