Change naga::back::spv::DebugInfo::file_name to a &Path.

This makes it a bit easier to use in the CLI and snapshot tests.
This commit is contained in:
Jim Blandy committed 2023-09-25 07:59:41 -07:00
1 parent 7060246357
commit 0c69735f59
4 files changed
+7 -11

No files matched your search

+1 -7
View File
@@ -374,13 +374,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
.set(naga::back::spv::WriterFlags::DEBUG, true);
params.spv_out.debug_info = Some(naga::back::spv::DebugInfo {
source_code: input_text,
file_name: input_path
.file_name()
.and_then(std::ffi::OsStr::to_str)
.ok_or(CliError(
"input path for couldn't be converted to string \
for `--generate-debug-symbols",
))?,
file_name: input_path,
})
} else {
eprintln!(
+1 -1
View File
@@ -85,7 +85,7 @@ impl IdGenerator {
#[derive(Debug, Clone)]
pub struct DebugInfo<'a> {
pub source_code: &'a str,
pub file_name: &'a str,
pub file_name: &'a std::path::Path,
}
/// A SPIR-V block to which we are still adding instructions.
+4 -2
View File
@@ -1840,8 +1840,10 @@ impl Writer {
if self.flags.contains(WriterFlags::DEBUG) {
if let Some(debug_info) = debug_info.as_ref() {
let source_file_id = self.id_gen.next();
self.debugs
.push(Instruction::string(debug_info.file_name, source_file_id));
self.debugs.push(Instruction::string(
&debug_info.file_name.display().to_string(),
source_file_id,
));
debug_info_inner = Some(DebugInfoInner {
source_code: debug_info.source_code,
+1 -1
View File
@@ -159,7 +159,7 @@ fn check_targets(
let debug_info = if cfg!(feature = "span") {
source_code.map(|code| naga::back::spv::DebugInfo {
source_code: code,
file_name: name,
file_name: name.as_ref(),
})
} else {
None