From 97def7ccd5c362e8cb7b91f5f4182ba06e2cbf35 Mon Sep 17 00:00:00 2001 From: Hokeun Kim Date: Wed, 8 Nov 2023 10:38:19 -0700 Subject: [PATCH 1/7] Generate shell script in `bin` for executing the compiled js file for TypeScript target. --- core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index 995bbf2a84..0b7f4fb57b 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -440,6 +440,10 @@ class TSGenerator( context.unsuccessfulFinish() } else { context.finish(GeneratorResult.Status.COMPILED, codeMaps) + val shScriptPath = fileConfig.binPath.resolve(fileConfig.name) + val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js") + FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) + shScriptPath.toFile().setExecutable(true) } } From 7f63075430b3c414623f8dd6f65e194e4a2fde47 Mon Sep 17 00:00:00 2001 From: Hokeun Kim Date: Wed, 8 Nov 2023 11:48:50 -0700 Subject: [PATCH 2/7] Remove unused code. --- core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index 0b7f4fb57b..7e7cfda8f8 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -34,7 +34,6 @@ import org.lflang.generator.* import org.lflang.generator.GeneratorUtils.canGenerate import org.lflang.lf.Preamble import org.lflang.model -import org.lflang.scoping.LFGlobalScopeProvider import org.lflang.target.property.DockerProperty import org.lflang.target.property.NoCompileProperty import org.lflang.target.property.ProtobufsProperty @@ -59,8 +58,7 @@ private const val NO_NPM_MESSAGE = "The TypeScript target requires npm >= 6.14.4 * @author Hokeun Kim */ class TSGenerator( - private val context: LFGeneratorContext, - private val scopeProvider: LFGlobalScopeProvider + context: LFGeneratorContext ) : GeneratorBase(context) { From 2deaa3ddeaef3bcef57cf04c11e6d9f5e041f1ef Mon Sep 17 00:00:00 2001 From: Hokeun Kim Date: Wed, 8 Nov 2023 11:52:30 -0700 Subject: [PATCH 3/7] Fix error in the call to the constructor of TSGenerator. --- core/src/main/java/org/lflang/generator/LFGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/lflang/generator/LFGenerator.java b/core/src/main/java/org/lflang/generator/LFGenerator.java index b43254f1ae..f4e61e93d5 100644 --- a/core/src/main/java/org/lflang/generator/LFGenerator.java +++ b/core/src/main/java/org/lflang/generator/LFGenerator.java @@ -80,7 +80,7 @@ private GeneratorBase createGenerator(LFGeneratorContext context) { case CCPP -> new CGenerator(context, true); case Python -> new PythonGenerator(context); case CPP -> new CppGenerator(context, scopeProvider); - case TS -> new TSGenerator(context, scopeProvider); + case TS -> new TSGenerator(context); case Rust -> new RustGenerator(context, scopeProvider); }; } From 04bfbb371e312d9cd579d81983d11b1973a08716 Mon Sep 17 00:00:00 2001 From: Hokeun Kim Date: Wed, 8 Nov 2023 12:18:20 -0700 Subject: [PATCH 4/7] Print an info message about the execution script for user. --- core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index 7e7cfda8f8..5417910632 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -442,6 +442,7 @@ class TSGenerator( val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js") FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) shScriptPath.toFile().setExecutable(true) + messageReporter.nowhere().info("Script for executing the compiled program is in ${fileConfig.binPath}.") } } From 8a45e91032648eca35717b1515f6bfbc6b942c61 Mon Sep 17 00:00:00 2001 From: Hokeun Kim Date: Wed, 8 Nov 2023 14:26:40 -0700 Subject: [PATCH 5/7] Update message for script. --- core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index 5417910632..6256777467 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -442,7 +442,7 @@ class TSGenerator( val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js") FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) shScriptPath.toFile().setExecutable(true) - messageReporter.nowhere().info("Script for executing the compiled program is in ${fileConfig.binPath}.") + messageReporter.nowhere().info("Script for executing the compiled program is $shScriptPath.") } } From b6eba5f6b995a407e33e25f17762b544b9859d3e Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 8 Nov 2023 14:31:12 -0800 Subject: [PATCH 6/7] Address comment from code review --- .../org/lflang/federated/launcher/FedLauncherGenerator.java | 6 +++--- core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index ac827ceda7..1a6314e5b2 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -228,13 +228,13 @@ public void doGenerate(List federates, RtiConfig rtiConfig) { } } + // Write the launcher file. + File file = fileConfig.binPath.resolve(fileConfig.name).toFile(); messageReporter .nowhere() - .info("##### Generating launcher for federation " + " in directory " + fileConfig.binPath); + .info("Script for launching the federation: " + file); - // Write the launcher file. // Delete file previously produced, if any. - File file = fileConfig.binPath.resolve(fileConfig.name).toFile(); if (file.exists()) { if (!file.delete()) messageReporter diff --git a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt index 6256777467..66f8f47330 100644 --- a/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt +++ b/core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt @@ -442,7 +442,7 @@ class TSGenerator( val jsPath = fileConfig.srcGenPath.resolve("dist").resolve("${fileConfig.name}.js") FileUtil.writeToFile("#!/bin/sh\nnode $jsPath", shScriptPath) shScriptPath.toFile().setExecutable(true) - messageReporter.nowhere().info("Script for executing the compiled program is $shScriptPath.") + messageReporter.nowhere().info("Script for executing the compiled program: $shScriptPath.") } } From 7baef5b7099596e9505a5276259ccedd91e01c93 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 8 Nov 2023 14:33:38 -0800 Subject: [PATCH 7/7] Apply Spotless --- .../org/lflang/federated/launcher/FedLauncherGenerator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 1a6314e5b2..ad8743a7c3 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -230,9 +230,7 @@ public void doGenerate(List federates, RtiConfig rtiConfig) { // Write the launcher file. File file = fileConfig.binPath.resolve(fileConfig.name).toFile(); - messageReporter - .nowhere() - .info("Script for launching the federation: " + file); + messageReporter.nowhere().info("Script for launching the federation: " + file); // Delete file previously produced, if any. if (file.exists()) {