Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to generate launch script for TS target and print informational message #2090

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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