Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lfc.ps1 to work in both dev and release setups #643

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions bin/lfc.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#==========================================================
# Description: Run the lfc compiler.
# Authors: Christian Menardn
# Authors: Christian Menard
# Usage: Usage: lfc [options] files...
#==========================================================

$base="$PSScriptRoot\.."
$lfbase="$base\org.lflang.lfc"
$jarpath="$lfbase\build\libs\org.lflang.lfc-0.1.0-SNAPSHOT-all.jar"
$java_home = "$Env:JAVA_HOME"
$java_cmd = "$java_home\bin\java.exe"
$jarpath_dev="$base\org.lflang.lfc\build\libs\org.lflang.lfc-?.?.?-SNAPSHOT-all.jar"
$jarpath_release="$base\lib\org.lflang.lfc-?.?.?-SNAPSHOT-all.jar"

# if there is no jar file, then build it first
if (-not (Test-Path $jarpath -PathType leaf)) {
$old_pwd = $pwd
cd $base
./gradlew buildLfc
cd $old_pwd
function Test-Dev {
Test-Path "$base\org.lflang.lfc" -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
}

$java_home = "$Env:JAVA_HOME"
$java_cmd = "$java_home\bin\java.exe"
# check if we can find java executable in $java_home
if (-not (Test-Path $java_cmd)) {
# otherwise, try to run java directly
Expand All @@ -34,4 +47,4 @@ if ([version]$java_version -lt [version]"11.0") {
}

# invoke lfc
& $java_cmd -jar $jarpath $args
& $java_cmd -jar $(Get-JarPath) $args
2 changes: 1 addition & 1 deletion lib/scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ fi
# Make sure the correct JRE is available.
check_jre_version

# Lunch the compiler.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

# Launch the compiler.
run_jar_with_args "$@"