lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.federated.generator.FederationFileConfig Class Reference

A subclass of {. More...

Inherits org.lflang.FileConfig.

Public Member Functions

void doClean () throws IOException
 Clean any artifacts produced by the code generator and target compilers.
 FederationFileConfig (FileConfig fileConfig) throws IOException
 FederationFileConfig (Resource resource, Path srcGenBasePath, boolean useHierarchicalBin) throws IOException
LFCommand getCommand ()
 Return an LFCommand instance that can be used to execute the program under compilation.
Path getDirectory (Resource r)
 Get the directory a resource is located in relative to the root package.
Path getExecutable ()
 Return a path to an executable version of the program under compilation.
Path getFedBinPath ()
 Return the path to the directory in which the executables of compiled federates are stored.
Path getFedGenPath ()
 Return the path to the root of a LF project generated on the basis of a federated LF program currently under compilation.
Path getGenPath ()
 Return the path to the root of a LF project generated on the basis of a federated LF program currently under compilation.
Path getModelGenBasePath ()
 Path representation of the root directory for generated verification models.
Path getModelGenPath ()
 The directory in which to put the generated verification models.
Path getOutPath ()
 The parent of the directory designated for placing generated sources into (src-gen by default).
Path getRtiBinPath ()
 The path to the RTI binary that is compiled for this federation.
Path getRtiSrcGenPath ()
 The directory in which to put a copy of reactor-c for compiling a RTI for this federation.
Path getSrcGenBasePath ()
 Path representation of srcGenRoot, the root directory for generated sources.
Path getSrcGenPath ()
 The directory in which to put the generated sources.
Path getSrcGenPkgPath ()
 The directory that denotes the root of the package to which the generated sources belong.
Path getSrcPath ()
 Return the path for storing generated LF sources that jointly constitute a federation.
void relativizePaths (FederateTargetConfig targetConfig)
 Relativize target properties that involve paths like files and cmake-include to be relative to the generated .lf file for the federate.

Static Public Member Functions

static Path findPackageRoot (final Path input, final Consumer< String > printWarning)
 Find the package root by looking for an 'src' directory.
static Resource getResource (File file, Provider< ResourceSet > resourceSetProvider)
 Return a resource obtained from the given resource set provider that matches the given file.
static Resource getResource (Path path, XtextResourceSet xtextResourceSet)
 Return a resource obtained from the given resource set that matches the given path.
static Path getSrcGenRoot (IFileSystemAccess2 fsa) throws IOException
 Returns the root directory for generated sources.

Public Attributes

final Path binPath
 The directory in which to put binaries, if the code generator produces any.
final IResource iResource
 If running in an Eclipse IDE, the iResource refers to the IFile representing the Lingua Franca program.
final String name
 The name of the main reactor, which has to match the file name (without the .lf extension).
final Resource resource
 The file containing the main source code.
final Path srcFile
 The full path to the file containing the .lf file including the full filename with the .lf extension.
final Path srcPath
 The directory in which the source .lf file was found.
final Path srcPkgPath
 The directory that is the root of the package in which the .lf source file resides.
final boolean useHierarchicalBin
 Indicate whether the bin directory should be hierarchical.

Static Public Attributes

static final String DEFAULT_BIN_DIR = "bin"
 Default name of the directory to store binaries in.
static final String DEFAULT_MODEL_GEN_DIR = "mod-gen"
 Default name of the directory to store generated verification models in.
static final String DEFAULT_SRC_DIR = "src"
static final String DEFAULT_SRC_GEN_DIR = "src-gen"
 Default name of the directory to store generated sources in.

Protected Member Functions

String getExecutableExtension ()
 Return the extension used for binaries on the platform on which compilation takes place.
Path getSubPkgPath (Path srcPath)
 Given a path that denotes the full path to a source file (not including the file itself), return the relative path from the root of the 'src' directory, or, if there is no 'src' directory, the relative path from the root of the package.

Protected Attributes

Path modelGenBasePath
 Path representation of the root directory for generated verification models.
Path modelGenPath
 The directory in which to put the generated verification models.
Path srcGenBasePath
 Path representation of srcGenRoot, the root directory for generated sources.
Path srcGenPath
 The directory in which to put the generated sources.

Detailed Description

A subclass of {.

See also
FileConfig} that extends the base functionality to add support for compiling federated LF programs.
Author
Soroush Bateni

Constructor & Destructor Documentation

◆ FederationFileConfig() [1/2]

org.lflang.federated.generator.FederationFileConfig.FederationFileConfig ( Resource resource,
Path srcGenBasePath,
boolean useHierarchicalBin ) throws IOException

◆ FederationFileConfig() [2/2]

org.lflang.federated.generator.FederationFileConfig.FederationFileConfig ( FileConfig fileConfig) throws IOException

Member Function Documentation

◆ doClean()

void org.lflang.federated.generator.FederationFileConfig.doClean ( ) throws IOException

Clean any artifacts produced by the code generator and target compilers.

The base implementation deletes the bin and src-gen directories. If the target code generator creates additional files or directories, the corresponding generator should override this method.

Exceptions
IOExceptionIf an I/O error occurs.

Reimplemented from org.lflang.FileConfig.

◆ findPackageRoot()

Path org.lflang.FileConfig.findPackageRoot ( final Path input,
final Consumer< String > printWarning )
staticinherited

Find the package root by looking for an 'src' directory.

If none can be found, return the current working directory instead.

Parameters
inputThe *.lf file to find the package root for.
printWarningA function to print a warning message.
Returns
The package root, or the current working directory if none exists.

◆ getCommand()

LFCommand org.lflang.FileConfig.getCommand ( )
inherited

Return an LFCommand instance that can be used to execute the program under compilation.

◆ getDirectory()

Path org.lflang.FileConfig.getDirectory ( Resource r)
inherited

Get the directory a resource is located in relative to the root package.

◆ getExecutable()

Path org.lflang.FileConfig.getExecutable ( )
inherited

Return a path to an executable version of the program under compilation.

◆ getExecutableExtension()

String org.lflang.FileConfig.getExecutableExtension ( )
protectedinherited

Return the extension used for binaries on the platform on which compilation takes place.

Reimplemented in org.lflang.generator.python.PyFileConfig.

◆ getFedBinPath()

Path org.lflang.federated.generator.FederationFileConfig.getFedBinPath ( )

Return the path to the directory in which the executables of compiled federates are stored.

◆ getFedGenPath()

Path org.lflang.federated.generator.FederationFileConfig.getFedGenPath ( )

Return the path to the root of a LF project generated on the basis of a federated LF program currently under compilation.

◆ getGenPath()

Path org.lflang.federated.generator.FederationFileConfig.getGenPath ( )

Return the path to the root of a LF project generated on the basis of a federated LF program currently under compilation.

◆ getModelGenBasePath()

Path org.lflang.FileConfig.getModelGenBasePath ( )
inherited

Path representation of the root directory for generated verification models.

This is the root, meaning that if the source file is x/y/Z.lf relative to the package root, then the generated sources will be put in x/y/Z relative to this URI.

◆ getModelGenPath()

Path org.lflang.FileConfig.getModelGenPath ( )
inherited

The directory in which to put the generated verification models.

◆ getOutPath()

Path org.lflang.FileConfig.getOutPath ( )
inherited

The parent of the directory designated for placing generated sources into (src-gen by default).

Additional directories (such as bin or build) should be created as siblings of the directory for generated sources, which means that such directories should be created relative to the path assigned to this class variable.

The generated source directory is specified in the IDE (Project Properties->LF->Compiler->Output Folder). When invoking the standalone compiler, the output path is specified directly using the -o or --output-path option.

◆ getResource() [1/2]

Resource org.lflang.FileConfig.getResource ( File file,
Provider< ResourceSet > resourceSetProvider )
staticinherited

Return a resource obtained from the given resource set provider that matches the given file.

Parameters
fileThe file to find a matching resource for.
resourceSetProviderThe resource set provider used to look up the resource.

◆ getResource() [2/2]

Resource org.lflang.FileConfig.getResource ( Path path,
XtextResourceSet xtextResourceSet )
staticinherited

Return a resource obtained from the given resource set that matches the given path.

Parameters
pathThe path to find a matching resource for.
xtextResourceSetThe resource set used to look up the resource.

◆ getRtiBinPath()

Path org.lflang.federated.generator.FederationFileConfig.getRtiBinPath ( )

The path to the RTI binary that is compiled for this federation.

◆ getRtiSrcGenPath()

Path org.lflang.federated.generator.FederationFileConfig.getRtiSrcGenPath ( )

The directory in which to put a copy of reactor-c for compiling a RTI for this federation.

◆ getSrcGenBasePath()

Path org.lflang.FileConfig.getSrcGenBasePath ( )
inherited

Path representation of srcGenRoot, the root directory for generated sources.

This is the root, meaning that if the source file is x/y/Z.lf relative to the package root, then the generated sources will be put in x/y/Z relative to this URI.

◆ getSrcGenPath()

Path org.lflang.federated.generator.FederationFileConfig.getSrcGenPath ( )

The directory in which to put the generated sources.

This takes into account the location of the source file relative to the package root. Specifically, if the source file is x/y/Z.lf relative to the package root, then the generated sources will be put in x/y/Z relative to srcGenBasePath.

Reimplemented from org.lflang.FileConfig.

◆ getSrcGenPkgPath()

Path org.lflang.FileConfig.getSrcGenPkgPath ( )
inherited

The directory that denotes the root of the package to which the generated sources belong.

Even if the target language does not have a notion of packages, this directory groups all files associated with a single main reactor.

◆ getSrcGenRoot()

Path org.lflang.FileConfig.getSrcGenRoot ( IFileSystemAccess2 fsa) throws IOException
staticinherited

Returns the root directory for generated sources.

◆ getSrcPath()

Path org.lflang.federated.generator.FederationFileConfig.getSrcPath ( )

Return the path for storing generated LF sources that jointly constitute a federation.

◆ getSubPkgPath()

Path org.lflang.FileConfig.getSubPkgPath ( Path srcPath)
protectedinherited

Given a path that denotes the full path to a source file (not including the file itself), return the relative path from the root of the 'src' directory, or, if there is no 'src' directory, the relative path from the root of the package.

Parameters
srcPathThe path to the source.
Returns
the relative path from the root of the 'src' directory, or, if there is no 'src' directory, the relative path from the root of the package

◆ relativizePaths()

void org.lflang.federated.generator.FederationFileConfig.relativizePaths ( FederateTargetConfig targetConfig)

Relativize target properties that involve paths like files and cmake-include to be relative to the generated .lf file for the federate.

Member Data Documentation

◆ binPath

final Path org.lflang.FileConfig.binPath
inherited

The directory in which to put binaries, if the code generator produces any.

◆ DEFAULT_BIN_DIR

final String org.lflang.FileConfig.DEFAULT_BIN_DIR = "bin"
staticinherited

Default name of the directory to store binaries in.

◆ DEFAULT_MODEL_GEN_DIR

final String org.lflang.FileConfig.DEFAULT_MODEL_GEN_DIR = "mod-gen"
staticinherited

Default name of the directory to store generated verification models in.

◆ DEFAULT_SRC_DIR

final String org.lflang.FileConfig.DEFAULT_SRC_DIR = "src"
staticinherited

◆ DEFAULT_SRC_GEN_DIR

final String org.lflang.FileConfig.DEFAULT_SRC_GEN_DIR = "src-gen"
staticinherited

Default name of the directory to store generated sources in.

◆ iResource

final IResource org.lflang.FileConfig.iResource
inherited

If running in an Eclipse IDE, the iResource refers to the IFile representing the Lingua Franca program.

This is the XText view of the file, which is distinct from the Eclipse eCore view of the file and the OS view of the file.

This is null if running outside an Eclipse IDE.

◆ modelGenBasePath

Path org.lflang.FileConfig.modelGenBasePath
protectedinherited

Path representation of the root directory for generated verification models.

◆ modelGenPath

Path org.lflang.FileConfig.modelGenPath
protectedinherited

The directory in which to put the generated verification models.

◆ name

final String org.lflang.FileConfig.name
inherited

The name of the main reactor, which has to match the file name (without the .lf extension).

◆ resource

final Resource org.lflang.FileConfig.resource
inherited

The file containing the main source code.

This is the Eclipse eCore view of the file, which is distinct from the XText view of the file and the OS view of the file.

◆ srcFile

final Path org.lflang.FileConfig.srcFile
inherited

The full path to the file containing the .lf file including the full filename with the .lf extension.

◆ srcGenBasePath

Path org.lflang.FileConfig.srcGenBasePath
protectedinherited

Path representation of srcGenRoot, the root directory for generated sources.

◆ srcGenPath

Path org.lflang.FileConfig.srcGenPath
protectedinherited

The directory in which to put the generated sources.

This takes into account the location of the source file relative to the package root. Specifically, if the source file is x/y/Z.lf relative to the package root, then the generated sources will be put in x/y/Z relative to srcGenBasePath.

◆ srcPath

final Path org.lflang.FileConfig.srcPath
inherited

The directory in which the source .lf file was found.

◆ srcPkgPath

final Path org.lflang.FileConfig.srcPkgPath
inherited

The directory that is the root of the package in which the .lf source file resides.

This path is determined differently depending on whether the compiler is invoked through the IDE or from the command line. In the former case, the package is the project root that the source resides in. In the latter case, it is the parent directory of the nearest src directory up the hierarchy, if there is one, or just the outPath if there is none. It is recommended to always keep the sources in a src directory regardless of the workflow, in which case the output behavior will be identical irrespective of the way the compiler is invoked.

◆ useHierarchicalBin

final boolean org.lflang.FileConfig.useHierarchicalBin
inherited

Indicate whether the bin directory should be hierarchical.


The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/federated/generator/FederationFileConfig.java