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

Responsible for creating and executing the necessary CMake command to compile code that is generated by the CGenerator. More...

Public Member Functions

LFCommand buildCmakeCommand ()
 Return a command to build the specified C file using CMake.
LFCommand buildWestFlashCommand (PlatformOptions options)
 Return a flash/emulate command using west.
 CCompiler (TargetConfig targetConfig, FileConfig fileConfig, MessageReporter messageReporter, boolean cppMode)
 Create an instance of CCompiler.
LFCommand compileCmakeCommand ()
 Return a command to compile the specified C file using CMake.
boolean runCCompiler (GeneratorBase generator, LFGeneratorContext context) throws IOException
 Run the C compiler by invoking cmake and make.

Static Package Functions

static String getFileExtension (boolean cppMode, TargetConfig targetConfig)
 Return the file extension of the output source files.
static String getTargetFileName (String fileName, boolean cppMode, TargetConfig targetConfig)
 Produces the filename including the target-specific extension.

Package Attributes

GeneratorCommandFactory commandFactory
 A factory for compiler commands.
FileConfig fileConfig
MessageReporter messageReporter
TargetConfig targetConfig

Detailed Description

Responsible for creating and executing the necessary CMake command to compile code that is generated by the CGenerator.

This class uses CMake to compile.

Author
Soroush Bateni
Edward A. Lee
Marten Lohstroh
Christian Menard
Matt Weber
Peter Donovan

Constructor & Destructor Documentation

◆ CCompiler()

org.lflang.generator.c.CCompiler.CCompiler ( TargetConfig targetConfig,
FileConfig fileConfig,
MessageReporter messageReporter,
boolean cppMode )

Create an instance of CCompiler.

Parameters
targetConfigThe current target configuration.
fileConfigThe current file configuration.
messageReporterUsed to report errors.
cppModeWhether the generated code should be compiled as if it were C++.

Member Function Documentation

◆ buildCmakeCommand()

LFCommand org.lflang.generator.c.CCompiler.buildCmakeCommand ( )

Return a command to build the specified C file using CMake.

This produces a C-specific build command.

Note: It appears that configuration and build cannot happen in one command. Therefore, this is separated into a compile command and a build command.

◆ buildWestFlashCommand()

LFCommand org.lflang.generator.c.CCompiler.buildWestFlashCommand ( PlatformOptions options)

Return a flash/emulate command using west.

If board is null (defaults to qemu_cortex_m3) or qemu_* Return a flash command which runs the target as an emulation If ordinary target, return west flash

◆ compileCmakeCommand()

LFCommand org.lflang.generator.c.CCompiler.compileCmakeCommand ( )

Return a command to compile the specified C file using CMake.

This produces a C-specific compile command.

◆ getFileExtension()

String org.lflang.generator.c.CCompiler.getFileExtension ( boolean cppMode,
TargetConfig targetConfig )
staticpackage

Return the file extension of the output source files.

Parameters
cppModeWhether we are building C code using a C++ compiler.
targetConfigThe target configuration that parameterizes the build process.

◆ getTargetFileName()

String org.lflang.generator.c.CCompiler.getTargetFileName ( String fileName,
boolean cppMode,
TargetConfig targetConfig )
staticpackage

Produces the filename including the target-specific extension.

Parameters
fileNameThe base name of the file without any extensions
cppModeIndicate whether the compiler is in C++ mode In C++ mode, the compiler produces .cpp files instead of .c files and uses a C++ compiler to compiler the code.
targetConfigThe target configuration.

◆ runCCompiler()

boolean org.lflang.generator.c.CCompiler.runCCompiler ( GeneratorBase generator,
LFGeneratorContext context ) throws IOException

Run the C compiler by invoking cmake and make.

Parameters
generatorAn instance of GeneratorBase, only used to report error line numbers in the Eclipse IDE.
contextThe generator context.
Returns
true if compilation succeeds, false otherwise.

Member Data Documentation

◆ commandFactory

GeneratorCommandFactory org.lflang.generator.c.CCompiler.commandFactory
package

A factory for compiler commands.

◆ fileConfig

FileConfig org.lflang.generator.c.CCompiler.fileConfig
package

◆ messageReporter

MessageReporter org.lflang.generator.c.CCompiler.messageReporter
package

◆ targetConfig

TargetConfig org.lflang.generator.c.CCompiler.targetConfig
package

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/c/CCompiler.java