Main Content

Manage Build Process Folders

The build process places generated files from Simulink® diagram updates and model builds into a hierarchy of folders that is specified by default. You can change the default specification for build process folders, if, for example:

  • Your company does not use the current working folder as the location for the code generation folder or the simulation cache folder.

  • You place the code generation folder under version control, but do not place the simulation cache folder under version control.

The MATLAB® session parameters CacheFolder, CodeGenFolder, and CodeGenFolderStructure are file generation control parameters that specify the folder locations for the build process. At the start of a MATLAB session, these Simulink preferences determine the values of the parameters:

Simulation cache folderCacheFolder

Code generation folderCodeGenFolder

Code generation folder structureCodeGenFolderStructure

To modify the parameters during a MATLAB session, use Simulink.fileGenControl. The parameter values that you set expire at the end of the MATLAB session.

File Generation Control Parameters

This table provides information about how you can use the parameters to manage build process folders.

MATLAB Session ParameterSimulink PreferenceDescription

CacheFolder

Simulation cache folder

The build process places generated files from Simulink diagram updates and model build artifacts for simulation and code generation in the simulation cache folder simulationCacheFolder. The folder is a root folder.

By default (CacheFolder = ''), simulationCacheFolder is the current working folder, pwd.

You can use the parameter to specify another folder. For example, if you want to:

  • Separate generated files from the models and other source material.

  • Reuse or share previously built simulation targets without having to set the current working folder back to a previous working folder.

CodeGenFolder

Code generation folder

The build process, which uses system target files to generate production code from a Simulink model, places the production code in the code generation folder codeGenerationFolder. The folder is a root folder.

If you choose to generate an executable program file, the build process writes the file model.exe (Windows®) or model (UNIX®) to the folder.

By default (CodeGenFolder = ''), codeGenerationFolder is the current working folder, pwd.

You can use the parameter to specify another folder. For example, if you want to separate generated production code from:

  • Models and other source material.

  • Generated simulation and code generation artifacts.

If you specify the root folder of a drive as the code generation folder, the build process cannot generate code for your model. For example, C:\.

CodeGenFolderStructure

Code generation folder structure To specify the folder structure within the code generation folder, use the parameter. For example, if you configure models for different target environments, you can specify a separate subfolder for the generated code from each model.

Build Process Folders

This table provides information about how CodeGenFolderStructure controls the folder structure within the simulation cache folder and the code generation folder.

Folder Name when CodeGenFolderStructure = 'ModelSpecific'

Folder Name when CodeGenFolderStructure = 'TargetEnvironmentSubfolder'

Description

codeGenerationFolder/model_target_rtw

The default for target is the name of the selected system target file, for example, grt, ert, and rsim. You can change target with the rtwgensettings.BuildDirSuffix field in the system target file.

codeGenerationFolder/targetSpecific/model

The build process uses configuration information for the system target file and the hardware device to produce a unique label for the subfolder, targetSpecific.

Build folder, which stores generated source code and other files created by the build process.

Contains the generated code modules, model.c and model.h, and generated makefile, model.mk.

model.mk is for compiling and linking code generated from model components.

model is the name of the source model.

codeGenerationFolder/model_target_rtw/services

codeGenerationFolder/targetSpecific/model/services

Folder created when you generate code for a component model that uses a service code interface configuration.

Contains services.h, the header file that specifies function prototypes for target platform services.

For more information, see Generate and Verify Code and Identify and Package Files for Deployment.

codeGenerationFolder/model_target_rtw/services/lib

codeGenerationFolder/targetSpecific/model/services/lib

Contains buildInfo.mat, which you use for building the component model library that represents the generated code compiled against services.h.

For more information, see Generate and Verify Code and Identify and Package Files for Deployment.

codeGenerationFolder/model_target_rtw/html

codeGenerationFolder/targetSpecific/model/html

Code generation report folder that contains report files generated by the build process.

codeGenerationFolder/slprj/target/model

codeGenerationFolder/targetSpecific/_ref/model

Model reference target files.

codeGenerationFolder/slprj/target/model/referenced_model_includes

codeGenerationFolder/targetSpecific/_ref/model/referenced_model_includes

Header files from models referenced by model.

codeGenerationFolder/slprj/target/model/tmwinternal

codeGenerationFolder/targetSpecific/_ref/model/tmwinternal

MAT-files used during code generation.

codeGenerationFolder/slprj/target/_sharedutils

codeGenerationFolder/targetSpecific/_shared

Utility functions for model reference system target files, which are shared across models.

Folder also contains rtwshared.mk for compiling generated shared utility code

simulationCacheFolder/slprj/sim/model

simulationCacheFolder/slprj/sim/model

Simulation target files for referenced models.

simulationCacheFolder/slprj/sim/model/tmwinternal

simulationCacheFolder/slprj/sim/model/tmwinternal

MAT-files used during code generation.

simulationCacheFolder/slprj/sim/_sharedutils

simulationCacheFolder/slprj/sim/_sharedutils

Utility functions for simulation system target files, which are shared across models.

If the system target file is ERT-based, then these model configuration parameters also control the location of shared utility code:

You can use RTW.getBuildDir to display build folder information for the model.

See Also

|

Related Topics