Skip to content

Commit d331f37

Browse files
authored
fix: Make sure the plc json path is relative (#972)
When building a project from a given json file, make sure the json file is absolute. Refs: #971
1 parent d6e68cf commit d331f37

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

compiler/plc_driver/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ fn get_project(compile_parameters: &CompileParameters) -> Result<Project<PathBuf
272272
let config = command
273273
.get_build_configuration()
274274
.map(PathBuf::from)
275+
.map(|it| {
276+
if it.is_relative() {
277+
//Make the build path absolute
278+
current_dir.join(it)
279+
} else {
280+
it
281+
}
282+
})
275283
.or_else(|| get_config(&current_dir))
276284
.ok_or_else(|| Diagnostic::param_error("Could not find 'plc.json'"))?;
277285
Project::from_config(&config)

examples/prog/build/ProjectName.out

15.5 KB
Binary file not shown.

examples/prog/main.st

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FUNCTION main : DINT
2+
main := 10;
3+
END_FUNCTION

examples/prog/plc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "ProjectName",
3+
"files" : [
4+
"./main.st"
5+
],
6+
"compile_type" : "Static",
7+
"libraries" : [
8+
]
9+
}

0 commit comments

Comments
 (0)