-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1422 from lf-lang/refactor-cli
New lff script and `org.lflang.cli` moved into `org.lflang` as subpackage
- Loading branch information
Showing
43 changed files
with
294 additions
and
243 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
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit 1 if any command returns with a non-zero exit code. | ||
set -euo pipefail | ||
|
||
cd $GITHUB_WORKSPACE | ||
|
||
function test_with_links() { | ||
rm -rf foo | ||
mkdir -p foo/bar/baz | ||
ln -s ../bin/${1} foo/link-foo | ||
ln -s ../link-foo foo/bar/link-bar | ||
ln -s ../link-bar foo/bar/baz/link-baz | ||
foo/bar/baz/link-baz --help | ||
} | ||
|
||
# Test the build-lf-cli executable and its flags. | ||
bin/build-lf-cli | ||
bin/build-lf-cli --help | ||
bin/build-lf-cli -h | ||
bin/build-lf-cli -c -o -s | ||
bin/build-lf-cli --clean --offline --stacktrace | ||
|
||
# Ensure that build-lf-cli is robust to symbolic links. | ||
test_with_links "build-lf-cli" |
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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit 1 if any command returns with a non-zero exit code. | ||
set -euo pipefail | ||
|
||
cd $GITHUB_WORKSPACE | ||
|
||
function test_with_links() { | ||
rm -rf foo | ||
mkdir -p foo/bar/baz | ||
ln -s ../bin/${1} foo/link-foo | ||
ln -s ../link-foo foo/bar/link-bar | ||
ln -s ../link-bar foo/bar/baz/link-${1} | ||
foo/bar/baz/link-${1} --help | ||
} | ||
|
||
# just a couple of smoke tests | ||
bin/lff --help | ||
bin/lff --version | ||
|
||
bin/lff -d test/C/src/Minimal.lf | ||
bin/lff --dry-run test/Cpp/src/Minimal.lf | ||
|
||
bin/lff -d test/C/src/Minimal.lf | ||
bin/lff --dry-run test/Cpp/src/Minimal.lf | ||
|
||
# Ensure that lff is robust to symbolic links. | ||
test_with_links "lff" |
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
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 @@ | ||
../lib/scripts/build.sh |
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 |
---|---|---|
@@ -1,50 +1,9 @@ | ||
#========================================================== | ||
# Description: Run the lfc compiler. | ||
# Authors: Christian Menard, Peter Donovan | ||
# Authors: Ruomu Xu | ||
# Usage: Usage: lfc [options] files... | ||
#========================================================== | ||
|
||
$base="$PSScriptRoot\.." | ||
$java_home = "$Env:JAVA_HOME" | ||
$java_cmd = "$java_home\bin\java.exe" | ||
$jarpath_dev="$base\org.lflang.cli\build\libs\org.lflang.cli-*-lfc.jar" | ||
$jarpath_release="$base\lib\jars\org.lflang.cli-*-lfc.jar" | ||
|
||
function Test-Dev { | ||
Test-Path "$base\org.lflang.cli" -PathType container | ||
} | ||
|
||
function Get-JarPath { | ||
if (Test-Dev) { | ||
if (Test-Path $jarpath_dev -PathType leaf) { | ||
$jarpath=$(Get-ChildItem $jarpath_dev).toString() | ||
} else { | ||
throw "Failed to find a copy of the Lingua Franca compiler matching the pattern ""$jarpath_dev"". Did you remember to build?" | ||
} | ||
} else { | ||
if (Test-Path $jarpath_release -PathType leaf) { | ||
$jarpath=$(Get-ChildItem $jarpath_release).toString() | ||
} else { | ||
throw "Failed to find a copy of the Lingua Franca compiler matching the pattern ""$jarpath_release""." | ||
} | ||
} | ||
$jarpath | ||
} | ||
|
||
# check if we can find java executable in $java_home | ||
if (-not (Test-Path $java_cmd)) { | ||
# otherwise, try to run java directly | ||
if (-not (Get-Command java -errorAction SilentlyContinue)) { | ||
throw "JRE not found" | ||
} | ||
$java_cmd = "java" | ||
} | ||
|
||
# check for correct java version | ||
$java_version = (Get-Command java | Select-Object -ExpandProperty Version).toString() | ||
if ([version]$java_version -lt [version]"17.0") { | ||
throw "JRE $java_version found but 17.0 or greater is required." | ||
} | ||
|
||
# invoke lfc | ||
& $java_cmd -jar $(Get-JarPath) $args | ||
$launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" | ||
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2 | ||
. $launchScript @args |
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 @@ | ||
../lib/scripts/launch.sh |
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 @@ | ||
#========================================================== | ||
# Description: Run the lff compiler. | ||
# Authors: Ruomu Xu | ||
# Usage: Usage: lff [options] files... | ||
#========================================================== | ||
|
||
$launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" | ||
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2 | ||
. $launchScript @args |
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
Oops, something went wrong.