-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into for-loops
- Loading branch information
Showing
12 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Build | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for the master branch | ||
push: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lit-linux-debug: | ||
name: lit tests (Linux, debug build) | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/plc-lang/rust-llvm:latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run `build.sh --lit` | ||
shell: bash | ||
run: | | ||
./scripts/build.sh --lit | ||
lit-linux-release: | ||
name: lit tests (Linux, release build) | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/plc-lang/rust-llvm:latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run `build.sh --lit --release` | ||
shell: bash | ||
run: | | ||
./scripts/build.sh --lit --release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ | |
*.a | ||
*.elf | ||
*.out | ||
|
||
# Garbage generated by llvm-lit | ||
tests/lit/**/*.txt | ||
tests/lit/**/Output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import lit.formats, os, os.path, sys, subprocess | ||
srcDir = os.path.dirname(__file__) | ||
config.test_format = lit.formats.ShTest(True) | ||
config.pipefail = False | ||
rustyRootDirectory = subprocess.check_output("dirname `cargo locate-project --message-format plain`", shell=True).decode("utf-8").strip() | ||
|
||
stdlibLocation = lit_config.params["LIB"] | ||
compilerLocation = lit_config.params["COMPILER"] | ||
|
||
# ...to make the compile command more reable we build it over multiple lines | ||
compile = f'{compilerLocation}' | ||
compile = f'{compile} -o /tmp/%basename_t.out' | ||
compile = f'{compile} -liec61131std -L{stdlibLocation}/lib -i "{stdlibLocation}/include/*.st"' | ||
compile = f'{compile} -i {rustyRootDirectory}/tests/lit/util/*.pli' | ||
compile = f'{compile} --linker=cc' | ||
print(f'Compile command: {compile}') | ||
|
||
config.substitutions.append(('%COMPILE', f'{compile}')) | ||
config.substitutions.append(('%RUN', f'LD_LIBRARY_PATH="{stdlibLocation}/lib" /tmp/%basename_t.out')) | ||
config.substitutions.append(('%CHECK', f'FileCheck-14 --check-prefixes CHECK --allow-unused-prefixes --match-full-lines')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FUNCTION main : DINT | ||
printf('%d', month_to_int(MONTH#June)); | ||
END_FUNCTION | ||
|
||
|
||
FUNCTION month_to_int : INT | ||
VAR_INPUT | ||
month_var : MONTH; | ||
END_VAR | ||
|
||
CASE month_var OF | ||
MONTH.January: month_to_int := 1; | ||
MONTH.February: month_to_int := 2; | ||
MONTH.March: month_to_int := 3; | ||
MONTH.April: month_to_int := 4; | ||
MONTH.May: month_to_int := 5; | ||
MONTH.June: month_to_int := 6; | ||
MONTH.July: month_to_int := 7; | ||
MONTH.August: month_to_int := 8; | ||
MONTH.September: month_to_int := 9; | ||
MONTH.October: month_to_int := 10; | ||
MONTH.November: month_to_int := 11; | ||
MONTH.December: month_to_int := 12; | ||
else month_to_int := 0; | ||
END_CASE; | ||
END_FUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
RUN: %COMPILE %S/month_to_int.st %S/months.dt && %RUN | %CHECK %s | ||
CHECK:6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
TYPE | ||
MONTH: (January, February, March, April, May, June, July, August, September, October, November, December); | ||
END_TYPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.suffixes = ['.test'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: (%COMPILE %s && %RUN) | %CHECK %s | ||
// CHECK: 10 | ||
FUNCTION main | ||
VAR | ||
x : DINT; | ||
y : DINT; | ||
END_VAR | ||
|
||
x := 5; | ||
y := 5; | ||
printf('%d$N', x + y); | ||
END_FUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// RUN: (%COMPILE %s && %RUN) | %CHECK %s | ||
// CHECK: 2 | ||
FUNCTION main | ||
VAR | ||
res : LREAL; | ||
END_VAR | ||
printf('%d$N', REAL_TO_DINT(SQRT(4.0))); | ||
END_FUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Declare any *.st file as a standlone test file | ||
config.suffixes = ['.st'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{external} | ||
FUNCTION printf: DINT | ||
VAR_INPUT {ref} | ||
str : STRING; | ||
END_VAR | ||
VAR_INPUT | ||
args: ...; | ||
END_VAR | ||
END_FUNCTION |