Skip to content

Commit e26a27d

Browse files
committed
Tolerate relative path as "layout_path"
1 parent dc84a8d commit e26a27d

File tree

1 file changed

+26
-0
lines changed
  • crates/pcb-zen-core/src/lang

1 file changed

+26
-0
lines changed

crates/pcb-zen-core/src/lang/eval.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,32 @@ impl EvalOutput {
114114
let mut result = converter.build(self.module_tree());
115115
if let Some(ref mut schematic) = result.output {
116116
schematic.package_roots = self.config.resolution.package_roots();
117+
118+
// Resolve any non-package:// layout_path attributes to stable URIs
119+
for inst in schematic.instances.values_mut() {
120+
if inst.kind != pcb_sch::InstanceKind::Module {
121+
continue;
122+
}
123+
let layout_val = inst
124+
.attributes
125+
.get(pcb_sch::ATTR_LAYOUT_PATH)
126+
.and_then(|v| v.string())
127+
.map(|s| s.to_owned());
128+
if let Some(raw) = layout_val {
129+
if !raw.starts_with(pcb_sch::PACKAGE_URI_PREFIX) {
130+
let source_dir = inst.type_ref.source_path.parent();
131+
if let Some(dir) = source_dir {
132+
let abs = dir.join(&raw);
133+
if let Some(uri) = self.config.resolution.format_package_uri(&abs) {
134+
inst.add_attribute(
135+
pcb_sch::ATTR_LAYOUT_PATH.to_string(),
136+
pcb_sch::AttributeValue::String(uri),
137+
);
138+
}
139+
}
140+
}
141+
}
142+
}
117143
}
118144
result
119145
}

0 commit comments

Comments
 (0)