Skip to content

Commit

Permalink
Merge pull request #2090 from lf-lang/ts-bin
Browse files Browse the repository at this point in the history
Fix to generate launch script for TS target and print informational message
  • Loading branch information
lhstrh authored Nov 9, 2023
2 parents 1a96598 + 7baef5b commit 6c3a1b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,11 @@ public void doGenerate(List<FederateInstance> federates, RtiConfig rtiConfig) {
}
}

messageReporter
.nowhere()
.info("##### Generating launcher for federation " + " in directory " + fileConfig.binPath);

// Write the launcher file.
// Delete file previously produced, if any.
File file = fileConfig.binPath.resolve(fileConfig.name).toFile();
messageReporter.nowhere().info("Script for launching the federation: " + file);

// Delete file previously produced, if any.
if (file.exists()) {
if (!file.delete())
messageReporter
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/lflang/generator/LFGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
Expand Down
9 changes: 6 additions & 3 deletions core/src/main/kotlin/org/lflang/generator/ts/TSGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {


Expand Down Expand Up @@ -440,6 +438,11 @@ 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)
messageReporter.nowhere().info("Script for executing the compiled program: $shScriptPath.")
}
}

Expand Down

0 comments on commit 6c3a1b8

Please sign in to comment.