Skip to content

Commit

Permalink
Merge pull request #643 from lf-lang/windows-lfc
Browse files Browse the repository at this point in the history
Update lfc.ps1 to work in both dev and release setups
  • Loading branch information
petervdonovan authored Oct 20, 2021
2 parents d5a77e7 + 3f4384d commit a71eeaf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
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.
# Launch the compiler.
run_jar_with_args "$@"

0 comments on commit a71eeaf

Please sign in to comment.