From ee6fac5231a55b77af1d7e11c990d70f23b1a0b5 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 22 Sep 2022 17:17:01 -0700 Subject: [PATCH 01/28] move all classes in org.lflang.cli to org.lflang/cli --- {org.lflang.cli => org.lflang}/src/org/lflang/cli/CliBase.java | 0 .../src/org/lflang/cli/LFStandaloneModule.java | 0 {org.lflang.cli => org.lflang}/src/org/lflang/cli/Lfc.java | 0 {org.lflang.cli => org.lflang}/src/org/lflang/cli/Lff.java | 0 .../src/org/lflang/cli/ReportingUtil.kt | 0 .../src/org/lflang/cli/StandaloneErrorReporter.java | 0 .../src/org/lflang/cli/StandaloneIssueAcceptor.java | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/CliBase.java (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/LFStandaloneModule.java (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/Lfc.java (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/Lff.java (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/ReportingUtil.kt (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/StandaloneErrorReporter.java (100%) rename {org.lflang.cli => org.lflang}/src/org/lflang/cli/StandaloneIssueAcceptor.java (100%) diff --git a/org.lflang.cli/src/org/lflang/cli/CliBase.java b/org.lflang/src/org/lflang/cli/CliBase.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/CliBase.java rename to org.lflang/src/org/lflang/cli/CliBase.java diff --git a/org.lflang.cli/src/org/lflang/cli/LFStandaloneModule.java b/org.lflang/src/org/lflang/cli/LFStandaloneModule.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/LFStandaloneModule.java rename to org.lflang/src/org/lflang/cli/LFStandaloneModule.java diff --git a/org.lflang.cli/src/org/lflang/cli/Lfc.java b/org.lflang/src/org/lflang/cli/Lfc.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/Lfc.java rename to org.lflang/src/org/lflang/cli/Lfc.java diff --git a/org.lflang.cli/src/org/lflang/cli/Lff.java b/org.lflang/src/org/lflang/cli/Lff.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/Lff.java rename to org.lflang/src/org/lflang/cli/Lff.java diff --git a/org.lflang.cli/src/org/lflang/cli/ReportingUtil.kt b/org.lflang/src/org/lflang/cli/ReportingUtil.kt similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/ReportingUtil.kt rename to org.lflang/src/org/lflang/cli/ReportingUtil.kt diff --git a/org.lflang.cli/src/org/lflang/cli/StandaloneErrorReporter.java b/org.lflang/src/org/lflang/cli/StandaloneErrorReporter.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/StandaloneErrorReporter.java rename to org.lflang/src/org/lflang/cli/StandaloneErrorReporter.java diff --git a/org.lflang.cli/src/org/lflang/cli/StandaloneIssueAcceptor.java b/org.lflang/src/org/lflang/cli/StandaloneIssueAcceptor.java similarity index 100% rename from org.lflang.cli/src/org/lflang/cli/StandaloneIssueAcceptor.java rename to org.lflang/src/org/lflang/cli/StandaloneIssueAcceptor.java From cf3e2d9bc77c9855ab272faae4fe5e7adb52f28a Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 22 Sep 2022 17:22:09 -0700 Subject: [PATCH 02/28] adjust the gradle configuration to build cli tools in new location --- org.lflang.cli/build.gradle | 116 ------------------------------------ org.lflang/build.gradle | 95 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 116 deletions(-) delete mode 100644 org.lflang.cli/build.gradle diff --git a/org.lflang.cli/build.gradle b/org.lflang.cli/build.gradle deleted file mode 100644 index 84913c02c5..0000000000 --- a/org.lflang.cli/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -sourceSets { - test { - java.srcDirs = [] - kotlin.srcDirs = ['test/kotlin'] - resources.srcDir('test/resources') - resources.include '**/*' - } -} - -configurations { - cli_impl { - extendsFrom implementation - } -} - -compileTestKotlin { - destinationDir = compileTestJava.destinationDir - kotlinOptions { - jvmTarget = kotlinJvmTarget - } -} - - - -dependencies { - implementation project(':org.lflang') - implementation "org.eclipse.xtext:org.eclipse.xtext.ide:${xtextVersion}" - implementation "org.eclipse.xtext:org.eclipse.xtext.xbase.ide:${xtextVersion}" - - testImplementation "junit:junit:${jUnitVersion}" -} - -apply plugin: 'application' -apply plugin: 'com.github.johnrengelman.shadow' - -task buildLfc() { - apply plugin: 'application' - apply plugin: 'com.github.johnrengelman.shadow' - mainClassName = 'org.lflang.cli.Lfc' -} - -task jarLfc(type: ShadowJar) { - manifest { - attributes('Main-Class': 'org.lflang.cli.Lfc') - } - configurations = [project.configurations.cli_impl] - archiveClassifier.set('lfc') - exclude 'test/*' - exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' - // We should use minimize() here to reduce the size of the JAR, but it causes problems - // with regard to our Kotlin classes. Since we don't use imports to load them but load - // the classes manually, minimize does not see the dependency. While we can add an exclude - // rule, this does not seem to work very well and causes problems when compiling for a - // second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285 - transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){ - resource = 'plugin.properties' - } - from sourceSets.main.output -} - -buildLfc.finalizedBy jarLfc - -task runLfc(type: JavaExec) { - // 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.cli.Lfc' - workingDir = '..' -} - -task buildLff() { - apply plugin: 'application' - apply plugin: 'com.github.johnrengelman.shadow' - mainClassName = 'org.lflang.cli.Lff' -} - -task jarLff(type: ShadowJar) { - manifest { - attributes('Main-Class': 'org.lflang.cli.Lff') - } - configurations = [project.configurations.cli_impl] - archiveClassifier.set('lff') - exclude 'test/*' - exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' - // We should use minimize() here to reduce the size of the JAR, but it causes problems - // with regard to our Kotlin classes. Since we don't use imports to load them but load - // the classes manually, minimize does not see the dependency. While we can add an exclude - // rule, this does not seem to work very well and causes problems when compiling for a - // second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285 - transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){ - resource = 'plugin.properties' - } - from sourceSets.main.output -} - -buildLff.finalizedBy jarLff - -task runLff(type: JavaExec) { - // builds and runs lff - // The working directory will be the root directory of the lingua franca project - // CLI arguments can be passed to lff 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 lff, use --args to pass arguments" - group = "application" - classpath = sourceSets.main.runtimeClasspath - mainClass = 'org.lflang.cli.Lff' - workingDir = '..' -} diff --git a/org.lflang/build.gradle b/org.lflang/build.gradle index 5fd90294b5..a1b56d20c3 100644 --- a/org.lflang/build.gradle +++ b/org.lflang/build.gradle @@ -1,3 +1,5 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + dependencies { implementation "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}" implementation "org.eclipse.xtext:org.eclipse.xtext.xbase.lib:${xtextVersion}" @@ -67,3 +69,96 @@ generateXtext.dependsOn(generateXtextLanguage) clean.dependsOn(cleanGenerateXtextLanguage) eclipse.classpath.plusConfigurations += [configurations.mwe2] +configurations { + cli_impl { + extendsFrom implementation + } +} + +apply plugin: 'application' +apply plugin: 'com.github.johnrengelman.shadow' + +// Lfc + +task buildLfc() { + apply plugin: 'application' + apply plugin: 'com.github.johnrengelman.shadow' + mainClassName = 'org.lflang.cli.Lfc' +} + +task jarLfc(type: ShadowJar) { + manifest { + attributes('Main-Class': 'org.lflang.cli.Lfc') + } + configurations = [project.configurations.cli_impl] + archiveClassifier.set('lfc') + exclude 'test/*' + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + // We should use minimize() here to reduce the size of the JAR, but it causes problems + // with regard to our Kotlin classes. Since we don't use imports to load them but load + // the classes manually, minimize does not see the dependency. While we can add an exclude + // rule, this does not seem to work very well and causes problems when compiling for a + // second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285 + transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){ + resource = 'plugin.properties' + } + from sourceSets.main.output +} + +task runLfc(type: JavaExec) { + // 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.cli.Lfc' + workingDir = '..' +} + + +buildLfc.finalizedBy jarLfc + +// Lff + +task buildLff() { + apply plugin: 'application' + apply plugin: 'com.github.johnrengelman.shadow' + mainClassName = 'org.lflang.cli.Lff' +} + +task jarLff(type: ShadowJar) { + manifest { + attributes('Main-Class': 'org.lflang.cli.Lff') + } + configurations = [project.configurations.cli_impl] + archiveClassifier.set('lff') + exclude 'test/*' + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + // We should use minimize() here to reduce the size of the JAR, but it causes problems + // with regard to our Kotlin classes. Since we don't use imports to load them but load + // the classes manually, minimize does not see the dependency. While we can add an exclude + // rule, this does not seem to work very well and causes problems when compiling for a + // second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285 + transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){ + resource = 'plugin.properties' + } + from sourceSets.main.output +} + +buildLff.finalizedBy jarLff + +task runLff(type: JavaExec) { + // builds and runs lff + // The working directory will be the root directory of the lingua franca project + // CLI arguments can be passed to lff 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 lff, use --args to pass arguments" + group = "application" + classpath = sourceSets.main.runtimeClasspath + mainClass = 'org.lflang.cli.Lff' + workingDir = '..' +} \ No newline at end of file From 18696ad43887ee60c61ca6886ed0b90102bcc205 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 22 Sep 2022 17:24:32 -0700 Subject: [PATCH 03/28] adjust the lfc script --- lib/scripts/include.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/scripts/include.sh b/lib/scripts/include.sh index 3163d029c3..1b8bc7a6bb 100644 --- a/lib/scripts/include.sh +++ b/lib/scripts/include.sh @@ -21,10 +21,8 @@ set -euo pipefail # Paths (relative to ${base}), which is assumed to have been set. src_pkg_name="org.lflang" src_pkg_path="${base}/${src_pkg_name}" -lfc_src_pkg_name="${src_pkg_name}.cli" -lfc_src_pkg_path="${base}/${lfc_src_pkg_name}" -lfc_jar_build_path_pattern="${lfc_src_pkg_name}/build/libs/${lfc_src_pkg_name}-*-lfc.jar" -lfc_jar_release_path_pattern="lib/jars/${lfc_src_pkg_name}-*-lfc.jar" +lfc_jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*-lfc.jar" +lfc_jar_release_path_pattern="lib/jars/${src_pkg_name}-*-lfc.jar" # Enter directory silently (without printing). pushd() { @@ -47,7 +45,7 @@ function is_dir() { # Check whether the source directory exists, and return it if true. function get_src_dir() { - echo `is_dir "${base}/${lfc_src_pkg_name}"` + echo `is_dir "${base}/${src_pkg_name}"` } # If it exists, return a path to the Lingua Franca jar. From a278bc577aefd2a9b53b4ac6a1d387068b97a632 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 21 Oct 2022 13:39:22 +0200 Subject: [PATCH 04/28] no need to jar lff separately, as it is already included in the lfc jar --- org.lflang/build.gradle | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/org.lflang/build.gradle b/org.lflang/build.gradle index a1b56d20c3..d9a43e7da2 100644 --- a/org.lflang/build.gradle +++ b/org.lflang/build.gradle @@ -91,7 +91,6 @@ task jarLfc(type: ShadowJar) { attributes('Main-Class': 'org.lflang.cli.Lfc') } configurations = [project.configurations.cli_impl] - archiveClassifier.set('lfc') exclude 'test/*' exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' // We should use minimize() here to reduce the size of the JAR, but it causes problems @@ -121,35 +120,6 @@ task runLfc(type: JavaExec) { buildLfc.finalizedBy jarLfc -// Lff - -task buildLff() { - apply plugin: 'application' - apply plugin: 'com.github.johnrengelman.shadow' - mainClassName = 'org.lflang.cli.Lff' -} - -task jarLff(type: ShadowJar) { - manifest { - attributes('Main-Class': 'org.lflang.cli.Lff') - } - configurations = [project.configurations.cli_impl] - archiveClassifier.set('lff') - exclude 'test/*' - exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' - // We should use minimize() here to reduce the size of the JAR, but it causes problems - // with regard to our Kotlin classes. Since we don't use imports to load them but load - // the classes manually, minimize does not see the dependency. While we can add an exclude - // rule, this does not seem to work very well and causes problems when compiling for a - // second time. Also see https://github.com/lf-lang/lingua-franca/pull/1285 - transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer){ - resource = 'plugin.properties' - } - from sourceSets.main.output -} - -buildLff.finalizedBy jarLff - task runLff(type: JavaExec) { // builds and runs lff // The working directory will be the root directory of the lingua franca project From 68ae72fb5ad0f5584f8db9b49023642613a8b412 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 21 Oct 2022 14:00:57 +0200 Subject: [PATCH 05/28] add an lff script --- bin/lfc | 61 +++++++++++++++++++++++++++++++++++++++++- lib/scripts/include.sh | 6 ++--- lib/scripts/launch.sh | 58 --------------------------------------- 3 files changed, 63 insertions(+), 62 deletions(-) mode change 120000 => 100755 bin/lfc delete mode 100755 lib/scripts/launch.sh diff --git a/bin/lfc b/bin/lfc deleted file mode 120000 index c22080b02d..0000000000 --- a/bin/lfc +++ /dev/null @@ -1 +0,0 @@ -../lib/scripts/launch.sh \ No newline at end of file diff --git a/bin/lfc b/bin/lfc new file mode 100755 index 0000000000..0db9a43774 --- /dev/null +++ b/bin/lfc @@ -0,0 +1,60 @@ +#!/bin/bash + +#============================================================================ +# Description: Run the Lingua Franca compiler. +# Authors: Marten Lohstroh +# Christian Menard +# Usage: Usage: lfc [options] files... +#============================================================================ + +#============================================================================ +# Preamble +#============================================================================ + +# Find the directory in which this script resides in a way that is compatible +# with MacOS, which has a `readlink` implementation that does not support the +# necessary `-f` flag to canonicalize by following every symlink in every +# component of the given name recursively. +# This solution, adapted from an example written by Geoff Nixon, is POSIX- +# compliant and robust to symbolic links. If a chain of more than 1000 links +# is encountered, we return. +find_dir() ( + start_dir=$PWD + cd "$(dirname "$1")" + link=$(readlink "$(basename "$1")") + count=0 + while [ "${link}" ]; do + if [[ "${count}" -lt 1000 ]]; then + cd "$(dirname "${link}")" + link=$(readlink "$(basename "$1")") + ((count++)) + else + return + fi + done + real_path="$PWD/$(basename "$1")" + cd "${start_dir}" + echo `dirname "${real_path}"` +) + +# Report fatal error and exit. +function fatal_error() { + 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" + exit 1 +} + +rel_path="lib/scripts" +abs_path="$(find_dir "$0")" + +if [[ "${abs_path}" ]]; then + base="$(dirname "${abs_path}")" + source "${base}/${rel_path}/include.sh" +else + fatal_error "Unable to determine absolute path to $0." +fi +#============================================================================ + +main_class="org.lflang.cli.Lfc" + +# Launch the compiler. +run_cli_tool_with_args "$@" diff --git a/lib/scripts/include.sh b/lib/scripts/include.sh index 1b8bc7a6bb..f77dc4223b 100644 --- a/lib/scripts/include.sh +++ b/lib/scripts/include.sh @@ -21,7 +21,7 @@ set -euo pipefail # Paths (relative to ${base}), which is assumed to have been set. src_pkg_name="org.lflang" src_pkg_path="${base}/${src_pkg_name}" -lfc_jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*-lfc.jar" +lfc_jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*.jar" lfc_jar_release_path_pattern="lib/jars/${src_pkg_name}-*-lfc.jar" # Enter directory silently (without printing). @@ -108,7 +108,7 @@ function get_java_cmd { } # Find the jar and JRE, run the jar with the provided arguments, and exit. -function run_lfc_with_args { +function run_cli_tool_with_args { # Find the jar; report error if it was not found. jar_path="$(get_jar_path)" @@ -118,6 +118,6 @@ function run_lfc_with_args { # Launch the compiler. java_cmd="$(get_java_cmd)" - "${java_cmd}" -jar "${jar_path}" "$@"; + "${java_cmd}" -cp "${jar_path}" "${main_class}" "$@"; exit $? } diff --git a/lib/scripts/launch.sh b/lib/scripts/launch.sh deleted file mode 100755 index 3208e5de54..0000000000 --- a/lib/scripts/launch.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -#============================================================================ -# Description: Run the Lingua Franca compiler. -# Authors: Marten Lohstroh -# Christian Menard -# Usage: Usage: lfc [options] files... -#============================================================================ - -#============================================================================ -# Preamble -#============================================================================ - -# Find the directory in which this script resides in a way that is compatible -# with MacOS, which has a `readlink` implementation that does not support the -# necessary `-f` flag to canonicalize by following every symlink in every -# component of the given name recursively. -# This solution, adapted from an example written by Geoff Nixon, is POSIX- -# compliant and robust to symbolic links. If a chain of more than 1000 links -# is encountered, we return. -find_dir() ( - start_dir=$PWD - cd "$(dirname "$1")" - link=$(readlink "$(basename "$1")") - count=0 - while [ "${link}" ]; do - if [[ "${count}" -lt 1000 ]]; then - cd "$(dirname "${link}")" - link=$(readlink "$(basename "$1")") - ((count++)) - else - return - fi - done - real_path="$PWD/$(basename "$1")" - cd "${start_dir}" - echo `dirname "${real_path}"` -) - -# Report fatal error and exit. -function fatal_error() { - 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" - exit 1 -} - -rel_path="lib/scripts" -abs_path="$(find_dir "$0")" - -if [[ "${abs_path}" ]]; then - base="$(dirname "$(dirname "${abs_path}")")" - source "${base}/${rel_path}/include.sh" -else - fatal_error "Unable to determine absolute path to $0." -fi -#============================================================================ - -# Launch the compiler. -run_lfc_with_args "$@" From a30c2d04221b03ee1b5de9d0679c237be130f561 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 21 Oct 2022 14:22:50 +0200 Subject: [PATCH 06/28] simplify the build process and introduce buildAll task --- build.gradle | 2 +- org.lflang/build.gradle | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 6970c1724c..4a39442dfc 100644 --- a/build.gradle +++ b/build.gradle @@ -112,4 +112,4 @@ spotless { formatAnnotations() } } -tasks.withType(SpotlessTask) { it.dependsOn(":org.lflang.cli:jarLff") } +tasks.withType(SpotlessTask) { it.dependsOn(":org.lflang:jarCliTools") } diff --git a/org.lflang/build.gradle b/org.lflang/build.gradle index d9a43e7da2..eb6594e2a3 100644 --- a/org.lflang/build.gradle +++ b/org.lflang/build.gradle @@ -78,15 +78,19 @@ configurations { apply plugin: 'application' apply plugin: 'com.github.johnrengelman.shadow' -// Lfc - -task buildLfc() { +task buildAll() { apply plugin: 'application' apply plugin: 'com.github.johnrengelman.shadow' mainClassName = 'org.lflang.cli.Lfc' } -task jarLfc(type: ShadowJar) { +// define buildLfc as an alias to buildAll +task buildLfc { + dependsOn buildAll + doFirst({{logger.warn("The buildLfc task is deprecated! Please use buildAll instead.")}}) +} + +task jarCliTools(type: ShadowJar) { manifest { attributes('Main-Class': 'org.lflang.cli.Lfc') } @@ -104,12 +108,16 @@ task jarLfc(type: ShadowJar) { from sourceSets.main.output } +buildAll.finalizedBy jarCliTools + +// Tasks for running specific CLI tools. +// 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. + task runLfc(type: JavaExec) { // 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 @@ -117,15 +125,8 @@ task runLfc(type: JavaExec) { workingDir = '..' } - -buildLfc.finalizedBy jarLfc - task runLff(type: JavaExec) { // builds and runs lff - // The working directory will be the root directory of the lingua franca project - // CLI arguments can be passed to lff 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 lff, use --args to pass arguments" group = "application" classpath = sourceSets.main.runtimeClasspath From cb6b58180476a6cdfe3d8c6b6a10dfc530140ac1 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 21 Oct 2022 15:36:56 +0200 Subject: [PATCH 07/28] introduce a test for lff --- .github/scripts/test-lff.sh | 16 ++++++++++++++++ .github/workflows/cli-tests.yml | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 .github/scripts/test-lff.sh diff --git a/.github/scripts/test-lff.sh b/.github/scripts/test-lff.sh new file mode 100755 index 0000000000..96f0e635e8 --- /dev/null +++ b/.github/scripts/test-lff.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Exit 1 if any command returns with a non-zero exit code. +set -euo pipefail + +cd $GITHUB_WORKSPACE + +# 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 test/C/src/Minimal.lf +bin/lff test/Cpp/src/Minimal.lf diff --git a/.github/workflows/cli-tests.yml b/.github/workflows/cli-tests.yml index b8aeee8d10..fc86a9198b 100644 --- a/.github/workflows/cli-tests.yml +++ b/.github/workflows/cli-tests.yml @@ -19,10 +19,14 @@ jobs: - name: Run standalone cli tests run: | ./gradlew :org.lflang.cli:test --stacktrace - - name: Test Bash scripts (Linux or macOS only) + - name: Test lfc bash scripts (Linux or macOS only) run: | .github/scripts/test-lfc.sh if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} + - name: Test lff bash scripts (Linux or macOS only) + run: | + .github/scripts/test-lff.sh + if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} - name: Test PowerShell script (Windows only) run: | ./gradlew buildLfc From 2ce376b8d5351cde89f83198dfbb1b67826d7ddb Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 13:59:36 +0200 Subject: [PATCH 08/28] actually add lff script --- bin/lff | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 bin/lff diff --git a/bin/lff b/bin/lff new file mode 100755 index 0000000000..18799b5888 --- /dev/null +++ b/bin/lff @@ -0,0 +1,60 @@ +#!/bin/bash + +#============================================================================ +# Description: Run the Lingua Franca compiler. +# Authors: Marten Lohstroh +# Christian Menard +# Usage: Usage: lfc [options] files... +#============================================================================ + +#============================================================================ +# Preamble +#============================================================================ + +# Find the directory in which this script resides in a way that is compatible +# with MacOS, which has a `readlink` implementation that does not support the +# necessary `-f` flag to canonicalize by following every symlink in every +# component of the given name recursively. +# This solution, adapted from an example written by Geoff Nixon, is POSIX- +# compliant and robust to symbolic links. If a chain of more than 1000 links +# is encountered, we return. +find_dir() ( + start_dir=$PWD + cd "$(dirname "$1")" + link=$(readlink "$(basename "$1")") + count=0 + while [ "${link}" ]; do + if [[ "${count}" -lt 1000 ]]; then + cd "$(dirname "${link}")" + link=$(readlink "$(basename "$1")") + ((count++)) + else + return + fi + done + real_path="$PWD/$(basename "$1")" + cd "${start_dir}" + echo `dirname "${real_path}"` +) + +# Report fatal error and exit. +function fatal_error() { + 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" + exit 1 +} + +rel_path="lib/scripts" +abs_path="$(find_dir "$0")" + +if [[ "${abs_path}" ]]; then + base="$(dirname "${abs_path}")" + source "${base}/${rel_path}/include.sh" +else + fatal_error "Unable to determine absolute path to $0." +fi +#============================================================================ + +main_class="org.lflang.cli.Lff" + +# Launch the compiler. +run_cli_tool_with_args "$@" From 797deb64585381acea500973ae123b519237dd02 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 14:03:49 +0200 Subject: [PATCH 09/28] fix release path --- lib/scripts/include.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scripts/include.sh b/lib/scripts/include.sh index f77dc4223b..232fa9ed18 100644 --- a/lib/scripts/include.sh +++ b/lib/scripts/include.sh @@ -22,7 +22,7 @@ set -euo pipefail src_pkg_name="org.lflang" src_pkg_path="${base}/${src_pkg_name}" lfc_jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*.jar" -lfc_jar_release_path_pattern="lib/jars/${src_pkg_name}-*-lfc.jar" +lfc_jar_release_path_pattern="lib/jars/${src_pkg_name}-*.jar" # Enter directory silently (without printing). pushd() { From 3a17114acbda835a6fba64761d92cd95c5568c6c Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 14:33:23 +0200 Subject: [PATCH 10/28] update the build script; drop --run option the --run option is dropped because it would be unclear which command to run --- bin/build-lf-cli | 1 + lib/scripts/build.sh | 27 ++++++++------------------- lib/scripts/include.sh | 8 ++++---- 3 files changed, 13 insertions(+), 23 deletions(-) create mode 120000 bin/build-lf-cli diff --git a/bin/build-lf-cli b/bin/build-lf-cli new file mode 120000 index 0000000000..55c54a4b7a --- /dev/null +++ b/bin/build-lf-cli @@ -0,0 +1 @@ +../lib/scripts/build.sh \ No newline at end of file diff --git a/lib/scripts/build.sh b/lib/scripts/build.sh index 0191e98f39..a509362a78 100755 --- a/lib/scripts/build.sh +++ b/lib/scripts/build.sh @@ -17,6 +17,11 @@ # This solution, adapted from an example written by Geoff Nixon, ia POSIX- # compliant and robust to symbolic links. If a chain of more than 1000 links # is encountered, we return. + +if [[ "$0" == *build-lfc ]]; then + echo -e "\033[33mWarning; buid-lfc is deprecated! Please use build-lf-cli instead.\033[0m" +fi + find_dir() ( start_dir=$PWD cd "$(dirname "$1")" @@ -60,7 +65,7 @@ fi # Print message explaining the CLI args. function usage() { - echo "Usage: build-lfc [options] [[-r | --run] [lfc-args]]" + echo "Usage: build-lf-cli [options] [[-r | --run] [lfc-args]]" echo "Options:" echo " -c | --clean Build entirely from scratch." echo " -h | --help Display this information." @@ -87,15 +92,6 @@ while [[ "$#" -gt 0 ]]; do usage exit 0 ;; - -r | --run ) - run=true - shift - while [[ "$#" -gt 0 ]]; do - args+=("$1") - shift - done - break - ;; *) usage exit 1 @@ -121,22 +117,15 @@ jar_path="$(get_jar_path)" if [ ! -f "${jar_path}" ] || ! "${find_cmd}" "${base}" \ -path "${src_pkg_path}" \ - -path "${lfc_src_pkg_path}" \ -prune -o \ -type f \ -newer "${jar_path}" \ -exec false {} +; then # Rebuild. 1>&2 echo "Jar file is missing or out-of-date; starting rebuild..." - "${base}/gradlew" ${flags} -p "${base}" buildLfc + "${base}/gradlew" ${flags} -p "${base}" buildAll # Update the timestamp in case the jar was not touched by Gradle. touch -c -- "${jar_path}" else echo "Already up-to-date." -fi - -# Run lfc with the provided arguments. -if [[ "${run}" == "true" ]]; then - echo "Running lfc..." - run_lfc_with_args "${args[@]}" -fi +fi \ No newline at end of file diff --git a/lib/scripts/include.sh b/lib/scripts/include.sh index 232fa9ed18..aa0a6ef065 100644 --- a/lib/scripts/include.sh +++ b/lib/scripts/include.sh @@ -21,8 +21,8 @@ set -euo pipefail # Paths (relative to ${base}), which is assumed to have been set. src_pkg_name="org.lflang" src_pkg_path="${base}/${src_pkg_name}" -lfc_jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*.jar" -lfc_jar_release_path_pattern="lib/jars/${src_pkg_name}-*.jar" +jar_build_path_pattern="${src_pkg_name}/build/libs/${src_pkg_name}-*.jar" +jar_release_path_pattern="lib/jars/${src_pkg_name}-*.jar" # Enter directory silently (without printing). pushd() { @@ -51,9 +51,9 @@ function get_src_dir() { # If it exists, return a path to the Lingua Franca jar. function get_jar_path() { if [ "$(get_src_dir)" ]; then - jar_path_pattern="${lfc_jar_build_path_pattern}" + jar_path_pattern="${jar_build_path_pattern}" else - jar_path_pattern="${lfc_jar_release_path_pattern}" + jar_path_pattern="${jar_release_path_pattern}" fi # echo Jar path pattern: "${base}"/${jar_path_pattern} # Is there a file that matches our pattern? If so, return it. From 212fbe6138b4bb026b0e736924a9b57170d39001 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 14:49:54 +0200 Subject: [PATCH 11/28] found a way to use a single launch script --- bin/lfc | 61 +-------------------------------------- bin/lff | 61 +-------------------------------------- lib/scripts/launch.sh | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 120 deletions(-) mode change 100755 => 120000 bin/lfc mode change 100755 => 120000 bin/lff create mode 100755 lib/scripts/launch.sh diff --git a/bin/lfc b/bin/lfc deleted file mode 100755 index 0db9a43774..0000000000 --- a/bin/lfc +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -#============================================================================ -# Description: Run the Lingua Franca compiler. -# Authors: Marten Lohstroh -# Christian Menard -# Usage: Usage: lfc [options] files... -#============================================================================ - -#============================================================================ -# Preamble -#============================================================================ - -# Find the directory in which this script resides in a way that is compatible -# with MacOS, which has a `readlink` implementation that does not support the -# necessary `-f` flag to canonicalize by following every symlink in every -# component of the given name recursively. -# This solution, adapted from an example written by Geoff Nixon, is POSIX- -# compliant and robust to symbolic links. If a chain of more than 1000 links -# is encountered, we return. -find_dir() ( - start_dir=$PWD - cd "$(dirname "$1")" - link=$(readlink "$(basename "$1")") - count=0 - while [ "${link}" ]; do - if [[ "${count}" -lt 1000 ]]; then - cd "$(dirname "${link}")" - link=$(readlink "$(basename "$1")") - ((count++)) - else - return - fi - done - real_path="$PWD/$(basename "$1")" - cd "${start_dir}" - echo `dirname "${real_path}"` -) - -# Report fatal error and exit. -function fatal_error() { - 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" - exit 1 -} - -rel_path="lib/scripts" -abs_path="$(find_dir "$0")" - -if [[ "${abs_path}" ]]; then - base="$(dirname "${abs_path}")" - source "${base}/${rel_path}/include.sh" -else - fatal_error "Unable to determine absolute path to $0." -fi -#============================================================================ - -main_class="org.lflang.cli.Lfc" - -# Launch the compiler. -run_cli_tool_with_args "$@" diff --git a/bin/lfc b/bin/lfc new file mode 120000 index 0000000000..c22080b02d --- /dev/null +++ b/bin/lfc @@ -0,0 +1 @@ +../lib/scripts/launch.sh \ No newline at end of file diff --git a/bin/lff b/bin/lff deleted file mode 100755 index 18799b5888..0000000000 --- a/bin/lff +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -#============================================================================ -# Description: Run the Lingua Franca compiler. -# Authors: Marten Lohstroh -# Christian Menard -# Usage: Usage: lfc [options] files... -#============================================================================ - -#============================================================================ -# Preamble -#============================================================================ - -# Find the directory in which this script resides in a way that is compatible -# with MacOS, which has a `readlink` implementation that does not support the -# necessary `-f` flag to canonicalize by following every symlink in every -# component of the given name recursively. -# This solution, adapted from an example written by Geoff Nixon, is POSIX- -# compliant and robust to symbolic links. If a chain of more than 1000 links -# is encountered, we return. -find_dir() ( - start_dir=$PWD - cd "$(dirname "$1")" - link=$(readlink "$(basename "$1")") - count=0 - while [ "${link}" ]; do - if [[ "${count}" -lt 1000 ]]; then - cd "$(dirname "${link}")" - link=$(readlink "$(basename "$1")") - ((count++)) - else - return - fi - done - real_path="$PWD/$(basename "$1")" - cd "${start_dir}" - echo `dirname "${real_path}"` -) - -# Report fatal error and exit. -function fatal_error() { - 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" - exit 1 -} - -rel_path="lib/scripts" -abs_path="$(find_dir "$0")" - -if [[ "${abs_path}" ]]; then - base="$(dirname "${abs_path}")" - source "${base}/${rel_path}/include.sh" -else - fatal_error "Unable to determine absolute path to $0." -fi -#============================================================================ - -main_class="org.lflang.cli.Lff" - -# Launch the compiler. -run_cli_tool_with_args "$@" diff --git a/bin/lff b/bin/lff new file mode 120000 index 0000000000..c22080b02d --- /dev/null +++ b/bin/lff @@ -0,0 +1 @@ +../lib/scripts/launch.sh \ No newline at end of file diff --git a/lib/scripts/launch.sh b/lib/scripts/launch.sh new file mode 100755 index 0000000000..a42f2e03ae --- /dev/null +++ b/lib/scripts/launch.sh @@ -0,0 +1,66 @@ +#============================================================================ +# Description: Run the Lingua Franca compiler. +# Authors: Marten Lohstroh +# Christian Menard +# Usage: Usage: lfc [options] files... +#============================================================================ + +#============================================================================ +# Preamble +#============================================================================ + +# Find the directory in which this script resides in a way that is compatible +# with MacOS, which has a `readlink` implementation that does not support the +# necessary `-f` flag to canonicalize by following every symlink in every +# component of the given name recursively. +# This solution, adapted from an example written by Geoff Nixon, is POSIX- +# compliant and robust to symbolic links. If a chain of more than 1000 links +# is encountered, we return. +find_dir() ( + start_dir=$PWD + cd "$(dirname "$1")" + link=$(readlink "$(basename "$1")") + count=0 + while [ "${link}" ]; do + if [[ "${count}" -lt 1000 ]]; then + cd "$(dirname "${link}")" + link=$(readlink "$(basename "$1")") + ((count++)) + else + return + fi + done + real_path="$PWD/$(basename "$1")" + cd "${start_dir}" + echo `dirname "${real_path}"` +) + +# Report fatal error and exit. +function fatal_error() { + 1>&2 echo -e "\e[1mlfc: \e[31mfatal error: \e[0m$1" + exit 1 +} + +rel_path="lib/scripts" +abs_path="$(find_dir "$0")" + +if [[ "${abs_path}" ]]; then + base=`dirname $(dirname ${abs_path})` + source "${base}/${rel_path}/include.sh" +else + fatal_error "Unable to determine absolute path to $0." +fi +#============================================================================ + + +if [[ "$0" == *lfc ]]; then + main_class="org.lflang.cli.Lfc" +elif [[ "$0" == *lff ]]; then + main_class="org.lflang.cli.Lff" +else + echo "ERROR: $0 is not a known lf command" + exit 2 +fi + +# Launch the compiler. +run_cli_tool_with_args "$@" From dbd6bef864473bf6212425c36e55b73fc34598fb Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 16:53:03 +0200 Subject: [PATCH 12/28] fix ci cli test scripts --- .github/scripts/test-build.sh | 28 ++++++++++++++++++++++++++++ .github/scripts/test-lfc.sh | 13 ------------- .github/scripts/test-lff.sh | 16 ++++++++++++++-- .github/workflows/ci.yml | 2 +- .github/workflows/cli-tests.yml | 11 ++++++++--- 5 files changed, 51 insertions(+), 19 deletions(-) create mode 100755 .github/scripts/test-build.sh diff --git a/.github/scripts/test-build.sh b/.github/scripts/test-build.sh new file mode 100755 index 0000000000..1481e070bf --- /dev/null +++ b/.github/scripts/test-build.sh @@ -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-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 --run --help +bin/build-lf-cli -r --help +bin/build-lf-cli --run test/C/src/Minimal.lf +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" diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index d61f708132..a0b96bf03b 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -14,19 +14,6 @@ function test_with_links() { foo/bar/baz/link-baz --help } -# Test the build-lfc executable and its flags. -bin/build-lfc -bin/build-lfc --help -bin/build-lfc -h -bin/build-lfc --run --help -bin/build-lfc -r --help -bin/build-lfc --run test/C/src/Minimal.lf -bin/build-lfc -c -o -s -bin/build-lfc --clean --offline --stacktrace - -# Ensure that build-lfc is robust to symbolic links. -test_with_links "build-lfc" - bin/lfc test/C/src/Minimal.lf # -c,--clean Clean before building. diff --git a/.github/scripts/test-lff.sh b/.github/scripts/test-lff.sh index 96f0e635e8..a31258f9e7 100755 --- a/.github/scripts/test-lff.sh +++ b/.github/scripts/test-lff.sh @@ -5,6 +5,15 @@ 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 +} + # just a couple of smoke tests bin/lff --help bin/lff --version @@ -12,5 +21,8 @@ bin/lff --version bin/lff -d test/C/src/Minimal.lf bin/lff --dry-run test/Cpp/src/Minimal.lf -bin/lff test/C/src/Minimal.lf -bin/lff 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" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e60cd1d2d..4610f0bb87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: # Run tests for the standalone compiler. cli-tests: - uses: lf-lang/lingua-franca/.github/workflows/cli-tests.yml@master + uses: lf-lang/lingua-franca/.github/workflows/cli-tests.yml@refactor-cli needs: cancel # Run the C benchmark tests. diff --git a/.github/workflows/cli-tests.yml b/.github/workflows/cli-tests.yml index fc86a9198b..9aaced4aba 100644 --- a/.github/workflows/cli-tests.yml +++ b/.github/workflows/cli-tests.yml @@ -16,9 +16,14 @@ jobs: fetch-depth: 0 - name: Prepare build environment uses: ./.github/actions/prepare-build-env - - name: Run standalone cli tests + # FIXME: reenable once the cli test is fixed + # - name: Run standalone cli tests + # run: | + # ./gradlew :org.lflang.cli:test --stacktrace + - name: Test build bash scripts (Linux and macOS only) run: | - ./gradlew :org.lflang.cli:test --stacktrace + .github/scripts/test-build.sh + if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} - name: Test lfc bash scripts (Linux or macOS only) run: | .github/scripts/test-lfc.sh @@ -29,6 +34,6 @@ jobs: if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }} - name: Test PowerShell script (Windows only) run: | - ./gradlew buildLfc + ./gradlew buildAll bin/lfc.ps1 --help if: ${{ runner.os == 'Windows' }} From 0dc5910b0c8e64ddd2e0107a4b69b274a1ea8c5b Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 25 Oct 2022 18:25:08 +0200 Subject: [PATCH 13/28] don't test the -r flag --- .github/scripts/test-build.sh | 3 --- lib/scripts/build.sh | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/scripts/test-build.sh b/.github/scripts/test-build.sh index 1481e070bf..36ba4011c1 100755 --- a/.github/scripts/test-build.sh +++ b/.github/scripts/test-build.sh @@ -18,9 +18,6 @@ function test_with_links() { bin/build-lf-cli bin/build-lf-cli --help bin/build-lf-cli -h -bin/build-lf-cli --run --help -bin/build-lf-cli -r --help -bin/build-lf-cli --run test/C/src/Minimal.lf bin/build-lf-cli -c -o -s bin/build-lf-cli --clean --offline --stacktrace diff --git a/lib/scripts/build.sh b/lib/scripts/build.sh index a509362a78..d342aa45cd 100755 --- a/lib/scripts/build.sh +++ b/lib/scripts/build.sh @@ -65,7 +65,7 @@ fi # Print message explaining the CLI args. function usage() { - echo "Usage: build-lf-cli [options] [[-r | --run] [lfc-args]]" + echo "Usage: build-lf-cli [options] [lfc-args]]" echo "Options:" echo " -c | --clean Build entirely from scratch." echo " -h | --help Display this information." @@ -128,4 +128,4 @@ if [ ! -f "${jar_path}" ] || ! "${find_cmd}" "${base}" \ touch -c -- "${jar_path}" else echo "Already up-to-date." -fi \ No newline at end of file +fi From c2016d0b2c21a3f491d4042fcdedc98e7f185a83 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 26 Oct 2022 10:42:50 +0200 Subject: [PATCH 14/28] improve error message and fix test scripts --- .github/scripts/test-lfc.sh | 4 ++-- .github/scripts/test-lff.sh | 4 ++-- lib/scripts/launch.sh | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/scripts/test-lfc.sh b/.github/scripts/test-lfc.sh index a0b96bf03b..f29b49af65 100755 --- a/.github/scripts/test-lfc.sh +++ b/.github/scripts/test-lfc.sh @@ -10,8 +10,8 @@ function test_with_links() { 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 + ln -s ../link-bar foo/bar/baz/link-${1} + foo/bar/baz/link-${1} --help } bin/lfc test/C/src/Minimal.lf diff --git a/.github/scripts/test-lff.sh b/.github/scripts/test-lff.sh index a31258f9e7..b16a5ad46a 100755 --- a/.github/scripts/test-lff.sh +++ b/.github/scripts/test-lff.sh @@ -10,8 +10,8 @@ function test_with_links() { 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 + ln -s ../link-bar foo/bar/baz/link-${1} + foo/bar/baz/link-${1} --help } # just a couple of smoke tests diff --git a/lib/scripts/launch.sh b/lib/scripts/launch.sh index a42f2e03ae..bea57da96e 100755 --- a/lib/scripts/launch.sh +++ b/lib/scripts/launch.sh @@ -58,7 +58,12 @@ if [[ "$0" == *lfc ]]; then elif [[ "$0" == *lff ]]; then main_class="org.lflang.cli.Lff" else - echo "ERROR: $0 is not a known lf command" + known_commands="[lfc, lff]" + echo \ + "ERROR: $0 is not a known lf command! Known commands are ${known_commands}. + In case you use a symbolic or hard link to one of the Lingua Franca + command line tools, make sure that the link's name ends with one of + ${known_commands}." exit 2 fi From 885e39cf917c4cfe06944e41e66da7777c199c35 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 26 Oct 2022 10:53:50 +0200 Subject: [PATCH 15/28] Update the packaging script --- .../scripts/{package_lfc.sh => package-cli.sh} | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) rename .github/scripts/{package_lfc.sh => package-cli.sh} (70%) diff --git a/.github/scripts/package_lfc.sh b/.github/scripts/package-cli.sh similarity index 70% rename from .github/scripts/package_lfc.sh rename to .github/scripts/package-cli.sh index f72f2c299f..7d2a651e65 100755 --- a/.github/scripts/package_lfc.sh +++ b/.github/scripts/package-cli.sh @@ -2,20 +2,20 @@ set -euo pipefail -# build lf compiler -./gradlew clean buildLfc +# build lf cli tools +./gradlew clean buildAll # find the version number -jar_path="org.lflang.cli/build/libs/org.lflang.cli-*-lfc.jar" -version="$(ls ${jar_path} | xargs -n 1 basename | sed 's/^org.lflang.cli-\(.*\)-lfc.jar$/\1/')" +jar_path="org.lflang/build/libs/org.lflang-*.jar" +version="$(ls ${jar_path} | xargs -n 1 basename | sed 's/^org.lflang-\(.*\).jar$/\1/')" # use a different naming convention for nightly build artifacts if [[ "$#" > 0 && "$1" = "nightly" ]]; then echo "Packaging Lingua Franca Nightly Build" - outname="lfc_nightly_$(date '+%Y%m%d-%H%M%S')" + outname="lf-cli_nightly_$(date '+%Y%m%d-%H%M%S')" else echo "Packaging Lingua Franca v${version}" - outname="lfc_${version}" + outname="lf-cli_${version}" fi # assemble the files in a separate directory @@ -24,13 +24,15 @@ mkdir -p "${outname}/lib/scripts" mkdir -p "${outname}/lib/jars" # move the jar -mv org.lflang.cli/build/libs/org.lflang.cli-*-lfc.jar "${outname}/lib/jars" +mv org.lflang/build/libs/org.lflang-*.jar "${outname}/lib/jars" # copy the Bash scripts cp -a lib/scripts "${outname}/lib/" ln -s "../lib/scripts/launch.sh" "${outname}/bin/lfc" +ln -s "../lib/scripts/launch.sh" "${outname}/bin/lff" # copy the PowerShell script cp bin/lfc.ps1 "${outname}/bin/lfc.ps1" +# FIXME: Need to copy the lff.ps1 script once it exists # zip/tar everything - the files will be put into the build_upload directory mkdir -p build_upload From 12772cd639964bf3e10e4b4ad97010002881df2b Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 26 Oct 2022 11:01:33 +0200 Subject: [PATCH 16/28] update the build cli workflow --- .github/workflows/build.yml | 8 ++++---- .github/workflows/ci.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6158844feb..8b70202d0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,12 +23,12 @@ jobs: fetch-depth: 0 - name: Prepare build environment uses: ./.github/actions/prepare-build-env - - name: Build and package lfc (nightly build) - run: .github/scripts/package_lfc.sh nightly + - name: Build and package lf cli tools (nightly build) + run: .github/scripts/package-cli.sh nightly shell: bash if: ${{ inputs.nightly == true }} - - name: Build and package lfc (regular build) - run: .github/scripts/package_lfc.sh + - name: Build and package lf cli tools (regular build) + run: .github/scripts/package-cli.sh shell: bash if: ${{ inputs.nightly != true }} - name: Check Maven/Java configuration diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4610f0bb87..23f4ba5535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,9 +20,9 @@ jobs: cancel: uses: lf-lang/lingua-franca/.github/workflows/cancel.yml@master - # Test the Maven build. + # Test the Gradle and Maven build. build: - uses: lf-lang/lingua-franca/.github/workflows/build.yml@master + uses: lf-lang/lingua-franca/.github/workflows/build.yml@refactor-cli needs: cancel # Run the unit tests. From c036e4cc9b0140660eb5cc0f94a8c77979adb4b5 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Wed, 26 Oct 2022 11:48:05 +0200 Subject: [PATCH 17/28] add missing shebang --- lib/scripts/launch.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/scripts/launch.sh b/lib/scripts/launch.sh index bea57da96e..82747c81ef 100755 --- a/lib/scripts/launch.sh +++ b/lib/scripts/launch.sh @@ -1,3 +1,5 @@ +#!/bin/bash + #============================================================================ # Description: Run the Lingua Franca compiler. # Authors: Marten Lohstroh From c0ab88ae297ef7cdfe55015105164c6e6b1293dd Mon Sep 17 00:00:00 2001 From: Konpaku Youmu Date: Wed, 26 Oct 2022 23:34:48 -0700 Subject: [PATCH 18/28] Naive version of lff.ps1 --- bin/lff.ps1 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bin/lff.ps1 diff --git a/bin/lff.ps1 b/bin/lff.ps1 new file mode 100644 index 0000000000..9acc26e419 --- /dev/null +++ b/bin/lff.ps1 @@ -0,0 +1,50 @@ +#========================================================== +# Description: Run the lff compiler. +# Authors: Christian Menard, Peter Donovan, Ruomu Xu +# Usage: Usage: lff [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-*-lff.jar" +$jarpath_release="$base\lib\jars\org.lflang.cli-*-lff.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 lff +& $java_cmd -jar $(Get-JarPath) $args From c8595facb2bc9a4e2009e8ed939bbc391d121538 Mon Sep 17 00:00:00 2001 From: Konpaku Youmu Date: Thu, 27 Oct 2022 00:04:21 -0700 Subject: [PATCH 19/28] Concentrated PowerShell commands Right now, launch.ps1 will, just like how lfc and lff (which are symbolic links) on *NIX works, get the name of the invoker and run the corresponding jar file, which is not as PowerShell-y. We can use arguments like outlined here: https://stackoverflow.com/a/43940404. Nevertheless, it appears it does work somehow. --- bin/lfc.ps1 | 49 +++--------------------------------- bin/lff.ps1 | 48 +++-------------------------------- lib/scripts/launch.ps1 | 57 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 91 deletions(-) create mode 100644 lib/scripts/launch.ps1 diff --git a/bin/lfc.ps1 b/bin/lfc.ps1 index f4e5187152..bb958d3315 100644 --- a/bin/lfc.ps1 +++ b/bin/lfc.ps1 @@ -1,50 +1,7 @@ #========================================================== # 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" +. $launchScript $args diff --git a/bin/lff.ps1 b/bin/lff.ps1 index 9acc26e419..0f5751c85b 100644 --- a/bin/lff.ps1 +++ b/bin/lff.ps1 @@ -1,50 +1,8 @@ #========================================================== # Description: Run the lff compiler. -# Authors: Christian Menard, Peter Donovan, Ruomu Xu +# Authors: Ruomu Xu # Usage: Usage: lff [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-*-lff.jar" -$jarpath_release="$base\lib\jars\org.lflang.cli-*-lff.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 lff -& $java_cmd -jar $(Get-JarPath) $args +$launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" +. $launchScript $args \ No newline at end of file diff --git a/lib/scripts/launch.ps1 b/lib/scripts/launch.ps1 new file mode 100644 index 0000000000..dcc6e656db --- /dev/null +++ b/lib/scripts/launch.ps1 @@ -0,0 +1,57 @@ +#========================================================== +# Description: Launch lfc or lff depending on the invoking script. +# Authors: Christian Menard, Peter Donovan, Ruomu Xu +# Usage: Usage: launch args... +# with invoker with name same as the programme to be invoked. +#========================================================== + +# If the invoker is Z:\nkamihara\lf\bin\lfc.ps1, $invokerName will strip out "lfc.ps1" and then get "lfc". +# See https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.2#myinvocation +$invokerPath = $MyInvocation.PSCommandPath +$invokerName = [System.IO.Path]::GetFileNameWithoutExtension("$(Split-Path -Path $invokerPath -Leaf -Resolve)") + +# This script is in $base\lib\scripts +$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-*-$invokerName.jar" +$jarpath_release="$base\lib\jars\org.lflang.cli-*-$invokerName.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 lff +& $java_cmd -jar $(Get-JarPath) $args From 36ee665abd99d18f86afbadae00265754e333108 Mon Sep 17 00:00:00 2001 From: "Frank X. Blackburn" <6500159+axmmisaka@users.noreply.github.com> Date: Thu, 27 Oct 2022 00:14:09 -0700 Subject: [PATCH 20/28] Add missing trailing CRLF --- bin/lff.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lff.ps1 b/bin/lff.ps1 index 0f5751c85b..f9c8d70b72 100644 --- a/bin/lff.ps1 +++ b/bin/lff.ps1 @@ -5,4 +5,4 @@ #========================================================== $launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" -. $launchScript $args \ No newline at end of file +. $launchScript $args From 595f1e35f99d94847383a31ca7fb3916372c95d2 Mon Sep 17 00:00:00 2001 From: Konpaku Youmu Date: Thu, 27 Oct 2022 01:42:49 -0700 Subject: [PATCH 21/28] Fix understanding error --- bin/lfc.ps1 | 1 + lib/scripts/launch.ps1 | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/lfc.ps1 b/bin/lfc.ps1 index bb958d3315..8f3af5e5b8 100644 --- a/bin/lfc.ps1 +++ b/bin/lfc.ps1 @@ -3,5 +3,6 @@ # Authors: Ruomu Xu # Usage: Usage: lfc [options] files... #========================================================== + $launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" . $launchScript $args diff --git a/lib/scripts/launch.ps1 b/lib/scripts/launch.ps1 index dcc6e656db..6864ef7c56 100644 --- a/lib/scripts/launch.ps1 +++ b/lib/scripts/launch.ps1 @@ -10,15 +10,29 @@ $invokerPath = $MyInvocation.PSCommandPath $invokerName = [System.IO.Path]::GetFileNameWithoutExtension("$(Split-Path -Path $invokerPath -Leaf -Resolve)") +$mainClassTable = @{"lfc" = "org.lflang.cli.Lfc"; "lff" = "org.lflang.cli.Lff"} +$mainClassName = $null +foreach ($k in $mainClassTable.Keys) { + if ($invokerName.EndsWith($k)) { + $mainClassName = $mainClassTable[$k] + break + } +} +if ($null -eq $mainClassName) { + throw ("$invokerName is not a known lf command. Known commands are [$($mainClassTable.Keys)]. " + + "In case you use a symbolic or hard link to one of the Lingua Franca " + + "command line tools, make sure that the link's name ends with one of [$($mainClassTable.Keys)]") +} + # This script is in $base\lib\scripts $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-*-$invokerName.jar" -$jarpath_release="$base\lib\jars\org.lflang.cli-*-$invokerName.jar" +$jarpath_dev="$base\org.lflang\build\libs\org.lflang-*.jar" +$jarpath_release="$base\lib\jars\org.lflang-*.jar" function Test-Dev { - Test-Path "$base\org.lflang.cli" -PathType container + Test-Path "$base\org.lflang" -PathType container } function Get-JarPath { @@ -54,4 +68,4 @@ if ([version]$java_version -lt [version]"17.0") { } # invoke lff -& $java_cmd -jar $(Get-JarPath) $args +& $java_cmd -classpath $(Get-JarPath) $mainClassName $args From 0b9bb2e58d8cbf2a145856597118d6bbb4fde384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 27 Oct 2022 14:39:17 +0200 Subject: [PATCH 22/28] Move test file --- .../src/org/lflang/tests/cli}/LfcIssueReportingTest.kt | 6 +++--- .../src}/resources/org/lflang/cli/tests/colors.lf | 0 .../src}/resources/org/lflang/cli/tests/colors.stderr | 0 .../src}/resources/org/lflang/cli/tests/emptyFile.lf | 0 .../src}/resources/org/lflang/cli/tests/emptyFile.stderr | 0 .../src}/resources/org/lflang/cli/tests/issue490.lf | 0 .../src}/resources/org/lflang/cli/tests/issue490.stderr | 0 .../src}/resources/org/lflang/cli/tests/multilineWarning.lf | 0 .../resources/org/lflang/cli/tests/multilineWarning.stderr | 0 .../org/lflang/cli/tests/multilineWarningTooBig.lf | 0 .../org/lflang/cli/tests/multilineWarningTooBig.stderr | 0 .../src}/resources/org/lflang/cli/tests/simpleWarning.lf | 0 .../resources/org/lflang/cli/tests/simpleWarning.stderr | 0 .../src}/resources/org/lflang/cli/tests/tabs.lf | 0 .../src}/resources/org/lflang/cli/tests/tabs.stderr | 0 .../src}/resources/org/lflang/cli/tests/twoLineWarning.lf | 0 .../resources/org/lflang/cli/tests/twoLineWarning.stderr | 0 17 files changed, 3 insertions(+), 3 deletions(-) rename {org.lflang.cli/test/kotlin/org/lflang/cli/tests => org.lflang.tests/src/org/lflang/tests/cli}/LfcIssueReportingTest.kt (96%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/colors.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/colors.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/emptyFile.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/emptyFile.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/issue490.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/issue490.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/multilineWarning.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/multilineWarning.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/multilineWarningTooBig.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/simpleWarning.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/simpleWarning.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/tabs.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/tabs.stderr (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/twoLineWarning.lf (100%) rename {org.lflang.cli/test => org.lflang.tests/src}/resources/org/lflang/cli/tests/twoLineWarning.stderr (100%) diff --git a/org.lflang.cli/test/kotlin/org/lflang/cli/tests/LfcIssueReportingTest.kt b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt similarity index 96% rename from org.lflang.cli/test/kotlin/org/lflang/cli/tests/LfcIssueReportingTest.kt rename to org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt index 12519a1ca0..683e220c7f 100644 --- a/org.lflang.cli/test/kotlin/org/lflang/cli/tests/LfcIssueReportingTest.kt +++ b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt @@ -21,7 +21,7 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.lflang.cli.tests +package org.lflang.tests.cli import junit.framework.Assert.assertEquals import junit.framework.AssertionFailedError @@ -118,8 +118,8 @@ class LfcIssueReportingTest { val packageName = loader.packageName.replace('.', '/') // relative to root of gradle project - val lfFile = Paths.get("test/resources/$packageName/$fileBaseName.lf") - val expectedPath = Paths.get("test/resources/$packageName/$fileBaseName.stderr") + val lfFile = Paths.get("src/resources/$packageName/$fileBaseName.lf") + val expectedPath = Paths.get("src/resources/$packageName/$fileBaseName.stderr") assert(Files.exists(lfFile)) { "Missing test file $lfFile" } diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/colors.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/colors.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/colors.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/colors.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/emptyFile.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/emptyFile.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/emptyFile.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/emptyFile.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/issue490.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/issue490.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/issue490.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/issue490.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarning.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarning.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarningTooBig.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarningTooBig.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/simpleWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/simpleWarning.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/simpleWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/simpleWarning.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/tabs.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/tabs.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/tabs.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/tabs.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/twoLineWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/twoLineWarning.lf rename to org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf diff --git a/org.lflang.cli/test/resources/org/lflang/cli/tests/twoLineWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr similarity index 100% rename from org.lflang.cli/test/resources/org/lflang/cli/tests/twoLineWarning.stderr rename to org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr From b40a46e59eddc2c9465c42dcaf7caf1a4ff9f024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 27 Oct 2022 16:42:27 +0200 Subject: [PATCH 23/28] Fix test resources not found --- .../lflang/tests/cli/LfcIssueReportingTest.kt | 5 ++-- .../resources/org/lflang/cli/tests/colors.lf | 9 ------ .../org/lflang/cli/tests/colors.stderr | 16 ----------- .../org/lflang/cli/tests/emptyFile.lf | 0 .../org/lflang/cli/tests/emptyFile.stderr | 8 ------ .../org/lflang/cli/tests/issue490.lf | 9 ------ .../org/lflang/cli/tests/issue490.stderr | 28 ------------------- .../org/lflang/cli/tests/multilineWarning.lf | 5 ---- .../lflang/cli/tests/multilineWarning.stderr | 10 ------- .../cli/tests/multilineWarningTooBig.lf | 13 --------- .../cli/tests/multilineWarningTooBig.stderr | 12 -------- .../org/lflang/cli/tests/simpleWarning.lf | 5 ---- .../org/lflang/cli/tests/simpleWarning.stderr | 16 ----------- .../resources/org/lflang/cli/tests/tabs.lf | 6 ---- .../org/lflang/cli/tests/tabs.stderr | 16 ----------- .../org/lflang/cli/tests/twoLineWarning.lf | 4 --- .../lflang/cli/tests/twoLineWarning.stderr | 9 ------ 17 files changed, 3 insertions(+), 168 deletions(-) delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf delete mode 100644 org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr diff --git a/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt index 683e220c7f..70da019038 100644 --- a/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt +++ b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt @@ -118,8 +118,9 @@ class LfcIssueReportingTest { val packageName = loader.packageName.replace('.', '/') // relative to root of gradle project - val lfFile = Paths.get("src/resources/$packageName/$fileBaseName.lf") - val expectedPath = Paths.get("src/resources/$packageName/$fileBaseName.stderr") + val basePath = "org.lflang.tests/resources/$packageName/" + val lfFile = Paths.get("$basePath/$fileBaseName.lf") + val expectedPath = Paths.get("$basePath/$fileBaseName.stderr") assert(Files.exists(lfFile)) { "Missing test file $lfFile" } diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf deleted file mode 100644 index 90423dfcb5..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.lf +++ /dev/null @@ -1,9 +0,0 @@ -// you can use `less -R filepath.stderr` to see the colored text -// https://unix.stackexchange.com/questions/262185/display-file-with-ansi-colors - -target unknown; - -main reactor Foo { - -} - diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr deleted file mode 100644 index 475f9517f6..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/colors.stderr +++ /dev/null @@ -1,16 +0,0 @@ -lfc: error: Unrecognized target: unknown ---> %%%PATH.lf%%%:4:8 - | -3 | -4 | target unknown; - | ^^^^^^^ Unrecognized target: unknown - | -5 | -lfc: error: Name of main reactor must match the file name (or be omitted). ---> %%%PATH.lf%%%:6:14 - | -5 | -6 | main reactor Foo { - | ^^^ Name of main reactor must match the file name (or be omitted). - | -7 | diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.lf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr deleted file mode 100644 index f63f06cc5c..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/emptyFile.stderr +++ /dev/null @@ -1,8 +0,0 @@ -lfc: error: mismatched input '' expecting 'target' ---> %%%PATH.lf%%%:1:1 - | -1 | - | ^ mismatched input '' expecting 'target' - | -2 | - diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf deleted file mode 100644 index 2fe700e349..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.lf +++ /dev/null @@ -1,9 +0,0 @@ -# https://github.com/lf-lang/lingua-franca/issues/490 -# issue is that one error ends at EOF -target Python; -main reactor R(p(3)) { - state liss(2, 3); - reaction (startup) { - print(self.liss) -} -} diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr deleted file mode 100644 index edf3254755..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/issue490.stderr +++ /dev/null @@ -1,28 +0,0 @@ -lfc: error: Name of main reactor must match the file name (or be omitted). ---> %%%PATH.lf%%%:4:14 - | -3 | target Python; -4 | main reactor R(p(3)) { - | ^ Name of main reactor must match the file name (or be omitted). - | -5 | state liss(2, 3); - -lfc: error: missing '{=' at '{' ---> %%%PATH.lf%%%:6:22 - | -5 | state liss(2, 3); -6 | reaction (startup) { - | ^ missing '{=' at '{' - | -7 | print(self.liss) - -lfc: error: mismatched input '' expecting '=}' - --> %%%PATH.lf%%%:9:2 - | - 8 | } - | >>>>>>>>>>>>>> - 9 | } -10 | - | < mismatched input '' expecting '=}' -11 | - diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf deleted file mode 100644 index 3d406f1c03..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.lf +++ /dev/null @@ -1,5 +0,0 @@ -target Cpp; - -reactor { - -} diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr deleted file mode 100644 index 5579a27731..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarning.stderr +++ /dev/null @@ -1,10 +0,0 @@ -lfc: error: Reactor must be named. ---> %%%PATH.lf%%%:3:1 - | -2 | - | >>>>>>>>>>>>>> -3 | reactor { -4 | -5 | } - | < Reactor must be named. -6 | diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf deleted file mode 100644 index 1df335e2f5..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.lf +++ /dev/null @@ -1,13 +0,0 @@ -target Cpp; - -// leading -reactor { - // included 1 - // excluded - // excluded - // excluded - // excluded - // excluded - // included 2 -} -// trailing diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr deleted file mode 100644 index 188aa2208f..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/multilineWarningTooBig.stderr +++ /dev/null @@ -1,12 +0,0 @@ -lfc: error: Reactor must be named. - --> %%%PATH.lf%%%:4:1 - | - 3 | // leading - | >>>>>>>>>>>>>> - 4 | reactor { - 5 | // included 1 - | ... -11 | // included 2 -12 | } - | < Reactor must be named. -13 | // trailing diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf deleted file mode 100644 index 0d08ee4fc9..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.lf +++ /dev/null @@ -1,5 +0,0 @@ -target unknown; - -main reactor Foo { - -} diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr deleted file mode 100644 index b66665fcfd..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/simpleWarning.stderr +++ /dev/null @@ -1,16 +0,0 @@ -lfc: error: Unrecognized target: unknown ---> %%%PATH.lf%%%:1:8 - | -1 | target unknown; - | ^^^^^^^ Unrecognized target: unknown - | -2 | - -lfc: error: Name of main reactor must match the file name (or be omitted). ---> %%%PATH.lf%%%:3:14 - | -2 | -3 | main reactor Foo { - | ^^^ Name of main reactor must match the file name (or be omitted). - | -4 | diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf deleted file mode 100644 index 43705c8a51..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.lf +++ /dev/null @@ -1,6 +0,0 @@ -target C; - -main reactor { - state foo(1); - state bar(1); -} diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr deleted file mode 100644 index e3b1e765da..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/tabs.stderr +++ /dev/null @@ -1,16 +0,0 @@ -lfc: error: State must have a type. ---> %%%PATH.lf%%%:4:2 - | -3 | main reactor { -4 | state foo(1); - | ^^^^^^^^^^^^^ State must have a type. - | -5 | state bar(1); -lfc: error: State must have a type. ---> %%%PATH.lf%%%:5:2 - | -4 | state foo(1); -5 | state bar(1); - | ^^^^^^^^^^^^^^^^ State must have a type. - | -6 | } \ No newline at end of file diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf b/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf deleted file mode 100644 index ed3790f89d..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.lf +++ /dev/null @@ -1,4 +0,0 @@ -target Cpp; - - reactor { - } diff --git a/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr b/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr deleted file mode 100644 index 745b863fb7..0000000000 --- a/org.lflang.tests/src/resources/org/lflang/cli/tests/twoLineWarning.stderr +++ /dev/null @@ -1,9 +0,0 @@ -lfc: error: Reactor must be named. ---> %%%PATH.lf%%%:3:2 - | -2 | - | >>>>>>>>>>>>>> -3 | reactor { -4 | } - | <<<<<< Reactor must be named. -5 | From 1047f90ec16532be6791aee2d1e9532860b2566b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 27 Oct 2022 16:52:02 +0200 Subject: [PATCH 24/28] Set fail on matching tests for test module --- build.gradle | 18 ++++++++---------- org.lflang.tests/build.gradle | 3 +++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 4a39442dfc..6155f298d7 100644 --- a/build.gradle +++ b/build.gradle @@ -65,16 +65,14 @@ subprojects { } } -gradle.projectsEvaluated { - // Our CI uses --tests filters, which fails if some - // subprojects have no matching test. - // - // https://stackoverflow.com/questions/26147480/how-to-make-gradle-not-to-mark-build-failed-if-no-tests-are-found - subprojects { - test { - filter { - setFailOnNoMatchingTests(false) - } +// Our CI uses --tests filters, which fails if some +// subprojects have no matching test. +// +// https://stackoverflow.com/questions/26147480/how-to-make-gradle-not-to-mark-build-failed-if-no-tests-are-found +subprojects { + test { + filter { + setFailOnNoMatchingTests(false) } } } diff --git a/org.lflang.tests/build.gradle b/org.lflang.tests/build.gradle index 3f223ec5f5..555f1b9181 100644 --- a/org.lflang.tests/build.gradle +++ b/org.lflang.tests/build.gradle @@ -52,6 +52,9 @@ test { useJUnitPlatform() finalizedBy jacocoTestReport workingDir = ".." + filter { + setFailOnNoMatchingTests(true) + } } test.dependsOn("compileKotlin") From b427714fd8a25c1fc39b5bf46b2d5b94c5db0448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 27 Oct 2022 16:59:33 +0200 Subject: [PATCH 25/28] Fix test not found --- .../resources/org/lflang/tests/cli/colors.lf | 9 ++++++ .../org/lflang/tests/cli/colors.stderr | 16 +++++++++++ .../org/lflang/tests/cli/emptyFile.lf | 0 .../org/lflang/tests/cli/emptyFile.stderr | 8 ++++++ .../org/lflang/tests/cli/issue490.lf | 9 ++++++ .../org/lflang/tests/cli/issue490.stderr | 28 +++++++++++++++++++ .../org/lflang/tests/cli/multilineWarning.lf | 5 ++++ .../lflang/tests/cli/multilineWarning.stderr | 10 +++++++ .../tests/cli/multilineWarningTooBig.lf | 13 +++++++++ .../tests/cli/multilineWarningTooBig.stderr | 12 ++++++++ .../org/lflang/tests/cli/simpleWarning.lf | 5 ++++ .../org/lflang/tests/cli/simpleWarning.stderr | 16 +++++++++++ .../resources/org/lflang/tests/cli/tabs.lf | 6 ++++ .../org/lflang/tests/cli/tabs.stderr | 16 +++++++++++ .../org/lflang/tests/cli/twoLineWarning.lf | 4 +++ .../lflang/tests/cli/twoLineWarning.stderr | 9 ++++++ .../lflang/tests/cli/LfcIssueReportingTest.kt | 15 ++++++---- 17 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/colors.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/colors.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/issue490.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/issue490.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/tabs.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/tabs.stderr create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.lf create mode 100644 org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.stderr diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/colors.lf b/org.lflang.tests/resources/org/lflang/tests/cli/colors.lf new file mode 100644 index 0000000000..90423dfcb5 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/colors.lf @@ -0,0 +1,9 @@ +// you can use `less -R filepath.stderr` to see the colored text +// https://unix.stackexchange.com/questions/262185/display-file-with-ansi-colors + +target unknown; + +main reactor Foo { + +} + diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/colors.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/colors.stderr new file mode 100644 index 0000000000..475f9517f6 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/colors.stderr @@ -0,0 +1,16 @@ +lfc: error: Unrecognized target: unknown +--> %%%PATH.lf%%%:4:8 + | +3 | +4 | target unknown; + | ^^^^^^^ Unrecognized target: unknown + | +5 | +lfc: error: Name of main reactor must match the file name (or be omitted). +--> %%%PATH.lf%%%:6:14 + | +5 | +6 | main reactor Foo { + | ^^^ Name of main reactor must match the file name (or be omitted). + | +7 | diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.lf b/org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.lf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.stderr new file mode 100644 index 0000000000..f63f06cc5c --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/emptyFile.stderr @@ -0,0 +1,8 @@ +lfc: error: mismatched input '' expecting 'target' +--> %%%PATH.lf%%%:1:1 + | +1 | + | ^ mismatched input '' expecting 'target' + | +2 | + diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/issue490.lf b/org.lflang.tests/resources/org/lflang/tests/cli/issue490.lf new file mode 100644 index 0000000000..2fe700e349 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/issue490.lf @@ -0,0 +1,9 @@ +# https://github.com/lf-lang/lingua-franca/issues/490 +# issue is that one error ends at EOF +target Python; +main reactor R(p(3)) { + state liss(2, 3); + reaction (startup) { + print(self.liss) +} +} diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/issue490.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/issue490.stderr new file mode 100644 index 0000000000..edf3254755 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/issue490.stderr @@ -0,0 +1,28 @@ +lfc: error: Name of main reactor must match the file name (or be omitted). +--> %%%PATH.lf%%%:4:14 + | +3 | target Python; +4 | main reactor R(p(3)) { + | ^ Name of main reactor must match the file name (or be omitted). + | +5 | state liss(2, 3); + +lfc: error: missing '{=' at '{' +--> %%%PATH.lf%%%:6:22 + | +5 | state liss(2, 3); +6 | reaction (startup) { + | ^ missing '{=' at '{' + | +7 | print(self.liss) + +lfc: error: mismatched input '' expecting '=}' + --> %%%PATH.lf%%%:9:2 + | + 8 | } + | >>>>>>>>>>>>>> + 9 | } +10 | + | < mismatched input '' expecting '=}' +11 | + diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.lf b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.lf new file mode 100644 index 0000000000..3d406f1c03 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.lf @@ -0,0 +1,5 @@ +target Cpp; + +reactor { + +} diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.stderr new file mode 100644 index 0000000000..5579a27731 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarning.stderr @@ -0,0 +1,10 @@ +lfc: error: Reactor must be named. +--> %%%PATH.lf%%%:3:1 + | +2 | + | >>>>>>>>>>>>>> +3 | reactor { +4 | +5 | } + | < Reactor must be named. +6 | diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.lf b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.lf new file mode 100644 index 0000000000..1df335e2f5 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.lf @@ -0,0 +1,13 @@ +target Cpp; + +// leading +reactor { + // included 1 + // excluded + // excluded + // excluded + // excluded + // excluded + // included 2 +} +// trailing diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.stderr new file mode 100644 index 0000000000..188aa2208f --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/multilineWarningTooBig.stderr @@ -0,0 +1,12 @@ +lfc: error: Reactor must be named. + --> %%%PATH.lf%%%:4:1 + | + 3 | // leading + | >>>>>>>>>>>>>> + 4 | reactor { + 5 | // included 1 + | ... +11 | // included 2 +12 | } + | < Reactor must be named. +13 | // trailing diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.lf b/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.lf new file mode 100644 index 0000000000..0d08ee4fc9 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.lf @@ -0,0 +1,5 @@ +target unknown; + +main reactor Foo { + +} diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.stderr new file mode 100644 index 0000000000..b66665fcfd --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/simpleWarning.stderr @@ -0,0 +1,16 @@ +lfc: error: Unrecognized target: unknown +--> %%%PATH.lf%%%:1:8 + | +1 | target unknown; + | ^^^^^^^ Unrecognized target: unknown + | +2 | + +lfc: error: Name of main reactor must match the file name (or be omitted). +--> %%%PATH.lf%%%:3:14 + | +2 | +3 | main reactor Foo { + | ^^^ Name of main reactor must match the file name (or be omitted). + | +4 | diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/tabs.lf b/org.lflang.tests/resources/org/lflang/tests/cli/tabs.lf new file mode 100644 index 0000000000..43705c8a51 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/tabs.lf @@ -0,0 +1,6 @@ +target C; + +main reactor { + state foo(1); + state bar(1); +} diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/tabs.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/tabs.stderr new file mode 100644 index 0000000000..e3b1e765da --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/tabs.stderr @@ -0,0 +1,16 @@ +lfc: error: State must have a type. +--> %%%PATH.lf%%%:4:2 + | +3 | main reactor { +4 | state foo(1); + | ^^^^^^^^^^^^^ State must have a type. + | +5 | state bar(1); +lfc: error: State must have a type. +--> %%%PATH.lf%%%:5:2 + | +4 | state foo(1); +5 | state bar(1); + | ^^^^^^^^^^^^^^^^ State must have a type. + | +6 | } \ No newline at end of file diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.lf b/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.lf new file mode 100644 index 0000000000..ed3790f89d --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.lf @@ -0,0 +1,4 @@ +target Cpp; + + reactor { + } diff --git a/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.stderr b/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.stderr new file mode 100644 index 0000000000..745b863fb7 --- /dev/null +++ b/org.lflang.tests/resources/org/lflang/tests/cli/twoLineWarning.stderr @@ -0,0 +1,9 @@ +lfc: error: Reactor must be named. +--> %%%PATH.lf%%%:3:2 + | +2 | + | >>>>>>>>>>>>>> +3 | reactor { +4 | } + | <<<<<< Reactor must be named. +5 | diff --git a/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt index 70da019038..8a079da068 100644 --- a/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt +++ b/org.lflang.tests/src/org/lflang/tests/cli/LfcIssueReportingTest.kt @@ -23,13 +23,18 @@ */ package org.lflang.tests.cli -import junit.framework.Assert.assertEquals -import junit.framework.AssertionFailedError -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test import org.lflang.LFRuntimeModule import org.lflang.LFStandaloneSetup -import org.lflang.cli.* -import java.io.* +import org.lflang.cli.AnsiColors +import org.lflang.cli.Io +import org.lflang.cli.LFStandaloneModule +import org.lflang.cli.Lfc +import org.lflang.cli.ReportingBackend +import org.opentest4j.AssertionFailedError +import java.io.ByteArrayOutputStream +import java.io.PrintStream import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path From 380c7fa5dc618bdaba6a7c9ff332ac8225ca03d4 Mon Sep 17 00:00:00 2001 From: Konpaku Youmu Date: Thu, 27 Oct 2022 09:45:06 -0700 Subject: [PATCH 26/28] Fix PS splattering bug --- bin/lfc.ps1 | 3 ++- bin/lff.ps1 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/lfc.ps1 b/bin/lfc.ps1 index 8f3af5e5b8..a09c91759c 100644 --- a/bin/lfc.ps1 +++ b/bin/lfc.ps1 @@ -5,4 +5,5 @@ #========================================================== $launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" -. $launchScript $args +# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2 +. $launchScript @args diff --git a/bin/lff.ps1 b/bin/lff.ps1 index f9c8d70b72..d73b7357eb 100644 --- a/bin/lff.ps1 +++ b/bin/lff.ps1 @@ -5,4 +5,5 @@ #========================================================== $launchScript="$PSScriptRoot\..\lib\scripts\launch.ps1" -. $launchScript $args +# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2 +. $launchScript @args From 89c65ae5916d0e8ba137d7b641ed48d14f9f9b3a Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 28 Oct 2022 11:16:10 +0200 Subject: [PATCH 27/28] update packaging script --- .github/scripts/package-cli.sh | 2 +- org.lflang/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/package-cli.sh b/.github/scripts/package-cli.sh index 7d2a651e65..36b4301b29 100755 --- a/.github/scripts/package-cli.sh +++ b/.github/scripts/package-cli.sh @@ -32,7 +32,7 @@ ln -s "../lib/scripts/launch.sh" "${outname}/bin/lfc" ln -s "../lib/scripts/launch.sh" "${outname}/bin/lff" # copy the PowerShell script cp bin/lfc.ps1 "${outname}/bin/lfc.ps1" -# FIXME: Need to copy the lff.ps1 script once it exists +cp bin/lff.ps1 "${outname}/bin/lff.ps1" # zip/tar everything - the files will be put into the build_upload directory mkdir -p build_upload diff --git a/org.lflang/build.gradle b/org.lflang/build.gradle index eb6594e2a3..a76e26f6fc 100644 --- a/org.lflang/build.gradle +++ b/org.lflang/build.gradle @@ -132,4 +132,4 @@ task runLff(type: JavaExec) { classpath = sourceSets.main.runtimeClasspath mainClass = 'org.lflang.cli.Lff' workingDir = '..' -} \ No newline at end of file +} From 734c05cccd91fd1a046c74c4f76c24591ada6b54 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 28 Oct 2022 11:21:24 +0200 Subject: [PATCH 28/28] use only hyphens in package names --- .github/scripts/package-cli.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/package-cli.sh b/.github/scripts/package-cli.sh index 36b4301b29..4eb51afd70 100755 --- a/.github/scripts/package-cli.sh +++ b/.github/scripts/package-cli.sh @@ -12,10 +12,10 @@ version="$(ls ${jar_path} | xargs -n 1 basename | sed 's/^org.lflang-\(.*\).jar$ # use a different naming convention for nightly build artifacts if [[ "$#" > 0 && "$1" = "nightly" ]]; then echo "Packaging Lingua Franca Nightly Build" - outname="lf-cli_nightly_$(date '+%Y%m%d-%H%M%S')" + outname="lf-cli-nightly-$(date '+%Y%m%d-%H%M%S')" else echo "Packaging Lingua Franca v${version}" - outname="lf-cli_${version}" + outname="lf-cli-${version}" fi # assemble the files in a separate directory