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

Python file configuration. More...

Inherits org.lflang.generator.c.CFileConfig.

Public Member Functions

void doClean () throws IOException
 Clean any artifacts produced by the code generator and target compilers.
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 getIncludePath ()
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).
String getRuntimeIncludePath ()
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.
 PyFileConfig (Resource resource, Path srcGenBasePath, boolean useHierarchicalBin) throws IOException

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

Python file configuration.

Constructor & Destructor Documentation

◆ PyFileConfig()

org.lflang.generator.python.PyFileConfig.PyFileConfig ( Resource resource,
Path srcGenBasePath,
boolean useHierarchicalBin ) throws IOException

Member Function Documentation

◆ doClean()

void org.lflang.FileConfig.doClean ( ) throws IOException
inherited

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 in org.lflang.federated.generator.FederationFileConfig.

◆ 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.generator.python.PyFileConfig.getExecutableExtension ( )
protected

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

Reimplemented from org.lflang.FileConfig.

◆ getIncludePath()

Path org.lflang.generator.c.CFileConfig.getIncludePath ( )
inherited

◆ 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.

◆ getRuntimeIncludePath()

String org.lflang.generator.c.CFileConfig.getRuntimeIncludePath ( )
inherited

◆ 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.FileConfig.getSrcGenPath ( )
inherited

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 in org.lflang.federated.generator.FederationFileConfig.

◆ 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.

◆ 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

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/generator/python/PyFileConfig.java