-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../util/scripts/launch.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#========================================================== | ||
# Description: Run the lff compiler. | ||
# Authors: Ruomu Xu | ||
# Usage: Usage: lff [options] files... | ||
#========================================================== | ||
|
||
$launchScript="$PSScriptRoot\..\util\scripts\launch.ps1" | ||
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2 | ||
. $launchScript @args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
plugins { | ||
id 'org.lflang.java-application-conventions' | ||
id 'com.github.johnrengelman.shadow' | ||
} | ||
|
||
dependencies { | ||
implementation project(':cli:base') | ||
implementation ("de.cau.cs.kieler.klighd:de.cau.cs.kieler.klighd.standalone:$klighdVersion") { | ||
exclude group: 'de.cau.cs.kieler.swt.mock' | ||
} | ||
implementation ("de.cau.cs.kieler.klighd:de.cau.cs.kieler.klighd.piccolo:${klighdVersion}") { | ||
exclude group: 'de.cau.cs.kieler.swt.mock' | ||
} | ||
implementation ("de.cau.cs.kieler.klighd:de.cau.cs.kieler.klighd.piccolo.freehep:${klighdVersion}") { | ||
exclude group: 'de.cau.cs.kieler.swt.mock' | ||
} | ||
implementation ("org.freehep:freehep-graphicsio-svg:${freehepVersion}") | ||
} | ||
|
||
application { | ||
mainClass = 'org.lflang.cli.Lfd' | ||
tasks.run.workingDir = System.getProperty("user.dir") | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
showStandardStreams = true | ||
} | ||
} | ||
|
||
shadowJar { | ||
mergeServiceFiles() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.lflang.cli; | ||
|
||
import de.cau.cs.kieler.klighd.LightDiagramServices; | ||
import de.cau.cs.kieler.klighd.standalone.KlighdStandaloneSetup; | ||
import java.nio.file.Path; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.lflang.lf.Model; | ||
import org.lflang.util.FileUtil; | ||
import picocli.CommandLine.Command; | ||
|
||
/** | ||
* Command lin tool for generating diagrams from Lingua Franca programs. | ||
* | ||
* @author Christian Menard | ||
*/ | ||
@Command( | ||
name = "lfd", | ||
// Enable usageHelp (--help) and versionHelp (--version) options. | ||
mixinStandardHelpOptions = true, | ||
versionProvider = VersionProvider.class) | ||
public class Lfd extends CliBase { | ||
|
||
@Override | ||
public void doRun() { | ||
KlighdStandaloneSetup.initialize(); | ||
|
||
for (Path relativePath : getInputPaths()) { | ||
Path path = toAbsolutePath(relativePath); | ||
final Resource resource = getResource(path); | ||
final Model model = (Model) resource.getContents().get(0); | ||
String baseName = FileUtil.nameWithoutExtension(relativePath); | ||
IStatus status = LightDiagramServices.renderOffScreen(model, "svg", baseName + ".svg"); | ||
if (!status.isOK()) { | ||
reporter.printFatalErrorAndExit(status.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Main entry point of the diagram tool. | ||
* | ||
* @param args CLI arguments | ||
*/ | ||
public static void main(String[] args) { | ||
main(Io.SYSTEM, args); | ||
} | ||
|
||
/** | ||
* Programmatic entry point, with a custom IO. | ||
* | ||
* @param io IO streams. | ||
* @param args Command-line arguments. | ||
*/ | ||
public static void main(Io io, final String... args) { | ||
cliMain("lfd", Lfd.class, io, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rootProject.name = 'org.lflang' | ||
include('core', 'lsp', 'cli:base', 'cli:lfc', 'cli:lff') | ||
include('core', 'lsp', 'cli:base', 'cli:lfc', 'cli:lff', 'cli:lfd') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters