Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The new project builder is configured using a domain specific language, namely KiBuild. Corresponding to the actions that are performed during the build, its configuration consists of model compilers, simulation compilers and template processors. A template processor is either a simple template processor, wrapper code template processor or simulation template processor.

When writing the configuration, use code

...

titleSimple KiBuild Example
linenumberstrue

...

// Compile models to C code
model compiler kico {
  outputFolder: kieler-gen   // The folder, in which the compilation output is saved
  outputFileExtension: c     // The file extension for compiled files
  compilationSystem: de.cau.cs.kieler.sccharts.netlist.simple  // The system that determines the compile chain within the KIELER compiler
  
  // Generate C simulation for compiled models
  process simulation template {
    file: assets/CSimulation.ftl  // A template for simulation code
  }
}

// Compile C simulation via gcc
simulation compiler c {
  libFolder: kieler-gen/sim/lib      // Create additional libraries required for compilation in this folder
  outputFolder: kieler-gen/sim/bin   // Create the executables in this folder
  command: "gcc -std=c99 -o ./${outputFolder}/${executable_name}"  // Use gcc to compile the code
}


...

titleComplex KiBuild Example

...

completion to see available attributes for the entities. The following table describes the available attributes.

AttributeDomainDefault ValueDescription
KiCo Model Compiler


outputFolderStringkieler-gen
The folder in which compilation output is saved
whitelistString, Regular expression-Only model files that have a location matching this regular expression are compiled. Thus to compile only a specific model, one can use the expression "ModelName.sctx"
blacklistString, Regular expression-Model files that have a location matching this regular expression are exluded from the build. Thus to exclued all models and skip compilation, one can use ".*", which matches everything.
compilationSystemString, Id of a pre-defined compilation system or project relative file path to a system definitionde.cau.cs.kieler.sccharts.netlist.simpleThe compilation system that is used by KiCo to determine the compile chain.
outputFileExtensionStringcCompiled models are saved with using this file extension. Thus this attribute should match the code format that is generated by KiCo at the end of the compilation.
outputTemplateString, Project relative file path-An optional template to add surrounding code to KiCo generated output for every compiled file. In the template the placeholder ${kico_code} can be used an will be replaced with the compiled code.
Simulation Compiler


commandString

For C:

"gcc -std=c99 -Werror=int-conversion -o \"./${outputFolder}/${executable_name}\""

For Java:

"jar cvfe \"../${outputFolder}/${executable_name}\""

The command that is called to compile simulation code to an executable.

In case of the C simulation, the compiled file is added implicitly as additional parameter, to create an executable.

In case of Java, all class files and the class file of the compiled model are added implicitly to create an executable JAR file.

outputFolderString, Project relative folder pathkieler-gen/sim/bin

The folder in which compiled output will be saved.

Note that it is possible to use a command that creates the compiled files in a different location. However the folder specified in this attribute is created before the command is executed and refreshed afterwards. This ensures that the folder exists and changes will be noticed in the Eclipse workspace.

libFolderString, Project relative folder pathkieler-gen/sim/libThe folder where additional files are saved before the command is run. These files can be linked into the simulation code, e.g., for JSON handling.
timeoutint10Time in seconds that is waited for the executed command to finish. If the command runs longer, it is assumed to be failed and aborted.
Template Processor


fileString, Project relative file path-The template file that should be processed
targetString, Project relative file path-The file in which the output should be saved
Wrapper Code Template Processor


modelFileString, Project relative file path-The model file that is searched for annotations to determine the code snippets to be injected.
Simulation Code Template Processor


modelFileString, Project relative file path-The model file that is searched for annotations to determine the code snippets to be injected
compiledModelFileString, Absolute file system path-The absolute path of the compiled model file for which the simulation is created. This is used to replace the placeholder ${compiled_model_loc} in the simulation code template
variables

Map, e.g.,
variables: {
    input: a,b,c
    output: x,y,z
    other: g1,g2,g3
}

-Optional additional variables that should be communicated to the outside
interfaceTypesString, List of Strings-The interface types that should be communicated in the simulation, e.g., input, output, internal


Example for KiBuild files:

Code Block
titleSimple KiBuild Example
linenumberstrue
// Compile models to C code
model compiler kico {
  outputFolder: kieler-gen   // The folder, in which the compilation output is saved
  outputFileExtension: c     // The file extension for compiled files
  compilationSystem: de.cau.cs.kieler.sccharts.netlist.simple  // The system that determines the compile chain within the KIELER compiler
  
  // Generate C simulation for compiled models
  process simulation template {
    file: assets/CSimulation.ftl  // A template for simulation code
  }
}

// Compile C simulation via gcc
simulation compiler c {
  libFolder: kieler-gen/sim/lib      // Create additional libraries required for compilation in this folder
  outputFolder: kieler-gen/sim/bin   // Create the executables in this folder
  command: "gcc -std=c99 -o ./${outputFolder}/${executable_name}"  // Use gcc to compile the code
}


Code Block
titleComplex KiBuild Example
// Compile models to Java code
model compiler kico {
  outputFolder: kieler-gen
  outputFileExtension: java
  outputTemplate: assets/OutputTemplate.ftl
  compilationSystem: de.cau.cs.kieler.sccharts.netlist.simple
  whitelist: "ModelA|ModelB"    // Only compile models that match this regex

  // Generate C simulation for compiled models
  process simulation template {
    file: assets/JavaSimulation.ftl
  }
}

// Compile C simulation via gcc
simulation compiler java {
  libFolder: kieler-gen/org/json
  outputFolder: kieler-gen/sim/bin
  outputFileExtensioncommand: java
"jar  outputTemplate: assets/OutputTemplate.ftl
  compilationSystem: de.cau.cs.kieler.sccharts.netlist.simple
  whitelist: "ModelA|ModelB"    // Only compile models that match this regex

  // Generate C simulation for compiled models
  process simulationcvfe ../${outputFolder}/${executable_name}"
}

// Process a simple template
process template {
 file: Template.ftl
 target: Output.txt
}

// Process a template to generate a main file that can be deployed.
process wrapper template {
  file: Main.ftl
  filetarget: assetskieler-gen/JavaSimulationMain.ftlc
  }modelFile: MyModel.sctx
}

// Compile CProcess a template to generate a simulation via gcc
simulation compiler java  for a model that has been compiled with some other framework
process simulation template {
  libFolderfile: kieler-gen/org/jsonassets/JavaSimulationForOtherModel.ftl
  outputFoldertarget: kieler-gen/sim/binSim_OtherModel.java
  commandvariables: {  "jar cvfe ../${outputFolder}/${executable_name}"
}

// Process a simple template
process template {
 file: Template.ftl
 target: Output.txt
}

// Process a template to generate a main file that can be deployed.
process wrapper template {
  file: Main.ftl
  target: kieler-gen/Main.c
  modelFile: MyModel.sctx/ These variables should be communicated to the outside
    input: a,b,c
    output: x,y,z
    internal: foo, bar
  }
  interfaceTypes: input, output  // Only communicate these interface types. In this case, internal variables are not communicated.
}


...

Prom Environments

Environments are used to provide default settings for project creation. They are configured in the preferences (Window > Preferences > KIELER SCCharts > Execution Environments).

...