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

Drop the rebuild feature of lfc #530

Merged
merged 21 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
27 changes: 21 additions & 6 deletions bin/lfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jarpath="${lfbase}build/libs/org.lflang.lfc-0.1.0-SNAPSHOT-all.jar"
# Report fatal error.
function fatal_error() {
1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1"
exit 1
}

pushd () {
Expand All @@ -28,8 +29,24 @@ popd () {
command popd "$@" > /dev/null
}

# Build first if no jar exists.
if [[ ! -f "$jarpath" ]]; then
# 1. Determine whether to rebuild; and
# 2. Strip rebuild flag from args.
rebuild=false
args=()
for var in "$@"; do
if [[ $var =~ "-r" ]]; then
rebuild=true
else
args+=("$var")
fi
done

# Build if no jar exists or rebuild is requested.
if [[ ! -f "$jarpath" || "$rebuild" = true ]]; then
# Throw error if no sources are available
if [[ ! -d $lfbase ]]; then
fatal_error "Unable to (re)build from source. Exiting."
fi
pushd "$base"
./gradlew buildLfc
popd
Expand All @@ -43,7 +60,6 @@ elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
_java="$JAVA_HOME/bin/java"
else
fatal_error "JRE not found."
error_exit
fi

if [[ "$_java" ]]; then
Expand All @@ -52,10 +68,9 @@ if [[ "$_java" ]]; then
#echo version "$semantic_version"
#echo version "$java_version"
if [ $java_version -lt 011000 ]; then
fatal_error "JRE $semantic_version found but 1.11 or greater is required."
error_exit
fatal_error "JRE $semantic_version found but 1.11 or greater is required."
fi
fi

"${_java}" -jar "${jarpath}" "$@";
"${_java}" -jar "${jarpath}" "${args[@]}";
exit $?
11 changes: 7 additions & 4 deletions org.lflang.lfc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ task buildLfc() {
buildLfc.finalizedBy shadowJar

task runLfc(type: JavaExec) {
// Note: when you use --args, you need to escape cli flags which start with --
// For instance --args ' --help'
// Otherwise they're parsed as arguments to the Gradle CLI, not LFC.
description = "Build and run LFC, use --args to pass arguments"
// builds and runs lfc
// The working directory will be the root directory of the lingua franca project
// CLI arguments can be passed to lfc by using --args. Note that you need
// to escape cli flags which start with --.For instance --args ' --help'.
// Otherwise they're parsed as arguments to the Gradle CLI, not lfc.
description = "Build and run lfc, use --args to pass arguments"
group = "application"
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.lflang.lfc.Main'
workingDir = '..'
}
Loading