Skip to content

Commit 782c74c

Browse files
committed
Merge branch 'master' into fbinit
2 parents 4617d1a + 1e543cd commit 782c74c

File tree

409 files changed

+1240
-16663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+1240
-16663
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
run: |
5050
echo "Build command : ./scripts/build.sh --build --release"
5151
./scripts/build.sh --build --release --package \
52-
--target x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
52+
--target x86_64-linux-gnu,aarch64-linux-gnu, \
53+
x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
5354
5455
- uses: actions/upload-artifact@master
5556
with:

compiler/plc_ast/src/ast.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ impl Debug for Pou {
269269
.field("variable_blocks", &self.variable_blocks)
270270
.field("pou_type", &self.kind)
271271
.field("return_type", &self.return_type)
272-
.field("interfaces", &self.interfaces);
272+
.field("interfaces", &self.interfaces)
273+
.field("properties", &self.properties);
274+
273275
if !self.generics.is_empty() {
274276
str.field("generics", &self.generics);
275277
}

compiler/plc_driver/src/cli.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ pub struct CompileParameters {
2727
global = true,
2828
help = "Emit AST (Abstract Syntax Tree) as output"
2929
)]
30-
pub output_ast: bool,
30+
pub print_ast: bool,
31+
32+
#[clap(
33+
long = "ast-lowered",
34+
group = "format",
35+
global = true,
36+
help = "Emit lowered AST (Abstract Syntax Tree) as output"
37+
)]
38+
pub print_ast_lowered: bool,
3139

3240
#[clap(long = "version", group = "format", global = true)]
3341
pub build_info: bool,
@@ -673,7 +681,8 @@ mod cli_tests {
673681
fn valid_output_formats() {
674682
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--ir")).unwrap();
675683
assert!(parameters.output_ir);
676-
assert!(!parameters.output_ast);
684+
assert!(!parameters.print_ast);
685+
assert!(!parameters.print_ast_lowered);
677686
assert!(!parameters.output_bit_code);
678687
assert!(!parameters.output_obj_code);
679688
assert!(!parameters.output_pic_obj);
@@ -682,7 +691,18 @@ mod cli_tests {
682691

683692
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--ast")).unwrap();
684693
assert!(!parameters.output_ir);
685-
assert!(parameters.output_ast);
694+
assert!(parameters.print_ast);
695+
assert!(!parameters.print_ast_lowered);
696+
assert!(!parameters.output_bit_code);
697+
assert!(!parameters.output_obj_code);
698+
assert!(!parameters.output_pic_obj);
699+
assert!(!parameters.output_shared_obj);
700+
assert!(!parameters.output_reloc_code);
701+
702+
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--ast-lowered")).unwrap();
703+
assert!(!parameters.output_ir);
704+
assert!(!parameters.print_ast);
705+
assert!(parameters.print_ast_lowered);
686706
assert!(!parameters.output_bit_code);
687707
assert!(!parameters.output_obj_code);
688708
assert!(!parameters.output_pic_obj);
@@ -691,7 +711,8 @@ mod cli_tests {
691711

692712
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--bc")).unwrap();
693713
assert!(!parameters.output_ir);
694-
assert!(!parameters.output_ast);
714+
assert!(!parameters.print_ast);
715+
assert!(!parameters.print_ast_lowered);
695716
assert!(parameters.output_bit_code);
696717
assert!(!parameters.output_obj_code);
697718
assert!(!parameters.output_pic_obj);
@@ -700,7 +721,8 @@ mod cli_tests {
700721

701722
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--static")).unwrap();
702723
assert!(!parameters.output_ir);
703-
assert!(!parameters.output_ast);
724+
assert!(!parameters.print_ast);
725+
assert!(!parameters.print_ast_lowered);
704726
assert!(!parameters.output_bit_code);
705727
assert!(parameters.output_obj_code);
706728
assert!(!parameters.output_pic_obj);
@@ -709,7 +731,8 @@ mod cli_tests {
709731

710732
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--pic")).unwrap();
711733
assert!(!parameters.output_ir);
712-
assert!(!parameters.output_ast);
734+
assert!(!parameters.print_ast);
735+
assert!(!parameters.print_ast_lowered);
713736
assert!(!parameters.output_bit_code);
714737
assert!(!parameters.output_obj_code);
715738
assert!(parameters.output_pic_obj);
@@ -718,7 +741,8 @@ mod cli_tests {
718741

719742
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--shared")).unwrap();
720743
assert!(!parameters.output_ir);
721-
assert!(!parameters.output_ast);
744+
assert!(!parameters.print_ast);
745+
assert!(!parameters.print_ast_lowered);
722746
assert!(!parameters.output_bit_code);
723747
assert!(!parameters.output_obj_code);
724748
assert!(!parameters.output_pic_obj);
@@ -727,7 +751,8 @@ mod cli_tests {
727751

728752
let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--relocatable")).unwrap();
729753
assert!(!parameters.output_ir);
730-
assert!(!parameters.output_ast);
754+
assert!(!parameters.print_ast);
755+
assert!(!parameters.print_ast_lowered);
731756
assert!(!parameters.output_bit_code);
732757
assert!(!parameters.output_obj_code);
733758
assert!(!parameters.output_pic_obj);
@@ -736,7 +761,8 @@ mod cli_tests {
736761

737762
let parameters = CompileParameters::parse(vec_of_strings!("input.st")).unwrap();
738763
assert!(!parameters.output_ir);
739-
assert!(!parameters.output_ast);
764+
assert!(!parameters.print_ast);
765+
assert!(!parameters.print_ast_lowered);
740766
assert!(!parameters.output_bit_code);
741767
assert!(!parameters.output_obj_code);
742768
assert!(!parameters.output_pic_obj);

compiler/plc_driver/src/pipelines.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,26 @@ impl<T: SourceContainer> Pipeline for BuildPipeline<T> {
299299

300300
self.initialize_thread_pool();
301301

302+
// 1. Parse
302303
let parsed_project = self.parse()?;
304+
305+
if self.compile_parameters.as_ref().is_some_and(|opt| opt.print_ast) {
306+
println!("{:#?}", parsed_project.units);
307+
return Ok(());
308+
}
309+
310+
// 2. Index
303311
let indexed_project = self.index(parsed_project)?;
312+
313+
// 3. Resolve
304314
let annotated_project = self.annotate(indexed_project)?;
305315

306-
//TODO : this is post lowering, we might want to control this
307-
if let Some(CompileParameters { output_ast: true, .. }) = self.compile_parameters {
316+
if self.compile_parameters.as_ref().is_some_and(|opt| opt.print_ast_lowered) {
308317
println!("{:#?}", annotated_project.units);
309318
return Ok(());
310319
}
311320

312-
// 5. Validate
313-
//TODO: this goes into a participant
321+
// 4. Validate
314322
annotated_project.validate(&self.context, &mut self.diagnostician)?;
315323

316324
//TODO: probably not needed, should be a participant anyway
@@ -323,13 +331,12 @@ impl<T: SourceContainer> Pipeline for BuildPipeline<T> {
323331
annotated_project.generate_hardware_information(format, location)?;
324332
}
325333

326-
// 5 : Codegen
327-
if !self.compile_parameters.as_ref().map(CompileParameters::is_check).unwrap_or_default() {
328-
let context = CodegenContext::create();
329-
self.generate(&context, annotated_project)?;
334+
// 5. Codegen
335+
if self.compile_parameters.as_ref().is_some_and(CompileParameters::is_check) {
336+
return Ok(());
330337
}
331338

332-
Ok(())
339+
self.generate(&CodegenContext::create(), annotated_project)
333340
}
334341

335342
fn parse(&mut self) -> Result<ParsedProject, Diagnostic> {

compiler/plc_lowering/src/inheritance.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ mod units_tests {
295295
pou_type: FunctionBlock,
296296
return_type: None,
297297
interfaces: [],
298+
properties: [],
298299
}
299300
"###);
300301
}
@@ -2085,6 +2086,7 @@ mod units_tests {
20852086
pou_type: FunctionBlock,
20862087
return_type: None,
20872088
interfaces: [],
2089+
properties: [],
20882090
}
20892091
"###);
20902092
}
@@ -2115,7 +2117,7 @@ mod units_tests {
21152117

21162118
let (_, project) = parse_and_annotate("test", vec![src]).unwrap();
21172119
let unit = &project.units[0].get_unit().pous[3];
2118-
assert_debug_snapshot!(unit, @r#"
2120+
assert_debug_snapshot!(unit, @r###"
21192121
POU {
21202122
name: "child.foo",
21212123
variable_blocks: [
@@ -2166,8 +2168,9 @@ mod units_tests {
21662168
},
21672169
return_type: None,
21682170
interfaces: [],
2171+
properties: [],
21692172
}
2170-
"#);
2173+
"###);
21712174
}
21722175

21732176
#[test]

compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__jump_and_label_converted_to_ast.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CompilationUnit {
2929
pou_type: Program,
3030
return_type: None,
3131
interfaces: [],
32+
properties: [],
3233
},
3334
],
3435
implementations: [

compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__negated_jump_ast.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CompilationUnit {
2929
pou_type: Program,
3030
return_type: None,
3131
interfaces: [],
32+
properties: [],
3233
},
3334
],
3435
implementations: [

compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unconnected_jump_generated_as_empty_statement.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CompilationUnit {
2929
pou_type: Program,
3030
return_type: None,
3131
interfaces: [],
32+
properties: [],
3233
},
3334
],
3435
implementations: [

compiler/plc_xml/src/xml_parser/snapshots/plc_xml__xml_parser__control__tests__unnamed_controls.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CompilationUnit {
1212
pou_type: Program,
1313
return_type: None,
1414
interfaces: [],
15+
properties: [],
1516
},
1617
],
1718
implementations: [

scripts/build.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ function run_std_build() {
9191
if [[ ! -z $target ]]; then
9292
for val in ${target//,/ }
9393
do
94+
# if the target ends with -linux-gnu but does not have unknown, add unknown
95+
if [[ $val == *"-linux-gnu" && $val != *"unknown-linux-gnu" ]]; then
96+
val="${val/-linux-gnu/-unknown-linux-gnu}"
97+
fi
9498
new_cmd="$cmd --target=$val"
9599
log "Running $new_cmd"
96100
eval "$new_cmd"
@@ -129,7 +133,7 @@ function run_doc() {
129133
log "Building book"
130134
log "Building preprocessor for the book"
131135
cargo build --release -p errorcode_book_generator
132-
cd book && mdbook build
136+
cd book && mdbook build
133137
# test is disabled because not all files in the book exist. The pre-processor for error codes adds new files
134138
# mdbook test
135139
}
@@ -163,7 +167,7 @@ function run_test() {
163167
rm -rf "$project_location/test_results"
164168
make_dir "$project_location/test_results"
165169
# JUnit test should run via cargo-nextest
166-
log "cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci \
170+
log "cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci \
167171
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/unit_tests.xml"
168172
cargo-nextest nextest run $CARGO_OPTIONS --lib --profile ci
169173
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/unit_tests.xml
@@ -176,11 +180,11 @@ function run_test() {
176180
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/integration_tests.xml
177181

178182
# Run the std integration
179-
log "cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*' \
183+
log "cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*' \
180184
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/std_integration_tests.xml"
181185
cargo-nextest nextest run $CARGO_OPTIONS --profile ci -p iec61131std --test '*'
182186
mv "$project_location"/target/nextest/ci/junit.xml "$project_location"/test_results/std_integration_tests.xml
183-
187+
184188
else
185189
cargo test $CARGO_OPTIONS --workspace
186190
fi
@@ -222,7 +226,14 @@ function run_package_std() {
222226
do
223227
lib_dir=$OUTPUT_DIR/$val/lib
224228
make_dir $lib_dir
225-
rel_dir="$target_dir/$val"
229+
230+
# if the target ends with -linux-gnu but does not have unknown, add unknown
231+
if [[ $val == *"-linux-gnu" && $val != *"unknown-linux-gnu" ]]; then
232+
rustc_target="${val/-linux-gnu/-unknown-linux-gnu}"
233+
else
234+
rustc_target=$val
235+
fi
236+
rel_dir="$target_dir/$rustc_target"
226237
if [[ $release -ne 0 ]]; then
227238
rel_dir="$rel_dir/release"
228239
else

0 commit comments

Comments
 (0)