| Contents | Index |
The Simulink Coder product provides a set of tools, including a build information object, you can use to customize build processing that occurs after code generation. You might use such customizations for target development or the integration of third-party tools into your application development environment. The next figure and the steps that follow show the general workflow for setting up such customizations.

Suppress makefile generation, if applicable..
Build the model.
Modify the command and rebuild the model until the build results are acceptable.
At the start of a model build, the Simulink Coder build process logs the following build option and dependency information to a temporary build information object:
Compiler options
Preprocessor identifier definitions
Linker options
Source files and paths
Include files and paths
Precompiled external libraries
You can retrieve information from and add information to this object by using an extensive set of functions. For a list of available functions and detailed function descriptions, see Alphabetical List in the Simulink Coder documentation. Program a Post Code Generation Command explains how to use the functions to control post code generation build processing.
For certain applications, you might want to control aspects of the build process after the code generation. For example, you might do this if you develop your own target, or you want to apply an analysis tool to the generated code before continuing with the build process. You can apply this level of control to the build process by programming and then defining a post code generation command.
A post code generation command is a MATLAB language file that typically calls functions that get data from or add data to the model's build information object. You can program the command as a script or function.
| If You Program the Command as a... | Then the... |
|---|---|
| Script | Script can gain access to the model name and the build information directly |
| Function | Function can pass the model name and the build information as arguments |
If your post code generation command calls user-defined functions, make sure the functions are on the MATLAB path. If the Simulink Coder build process cannot find a function you use in your command, the build process errors out.
You can then call any combination of build information functions to customize the model's post code generation build processing.
The following example shows a fragment of a post code generation command that gets the filenames and paths of the source and include files generated for a model for analysis.
function analyzegencode(buildInfo)
% Get the names and paths of all source and include files
% generated for the model and then analyze them.
% buildInfo - build information for my model.
% Define cell array to hold data.
MyBuildInfo={};
% Get source file information.
MyBuildInfo.srcfiles=getSourceFiles(buildInfo, true, true);
MyBuildInfo.srcpaths=getSourcePaths(buildInfo, true);
% Get include (header) file information.
MyBuildInfo.incfiles=getIncludeFiles(buildInfo, true, true);
MyBuildInfo.incpaths=getIncludePaths(buildInfo, true);
% Analyze generated code.
.
.
.For a list of available functions and detailed function descriptions, see Alphabetical List in the Simulink Coder documentation.
After you program a post code generation command, you need to inform the Simulink Coder build process that the command exists and to add it to the model's build processing. You do this by defining the command with the PostCodeGenCommand model configuration parameter. When you define a post code generation command, the Simulink Coder build process evaluates the command after generating and writing the model's code to disk and before generating a makefile.
As the following syntax lines show, the arguments that you specify when setting the configuration parameter varies depending on whether you program the command as a script, function, or set of functions.
Note When defining the command as a function, you can specify an arbitrary number of input arguments. To pass the model's name and build information to the function, specify identifiers modelName and buildInfo as arguments. |
Script
set_param(model, 'PostCodeGenCommand',... 'pcgScriptName');
Function
set_param(model, 'PostCodeGenCommand',... 'pcgFunctionName(modelName)');
Multiple Functions
pcgFunctions=... 'pcgFunction1Name(modelName);... pcgFunction2Name(buildInfo)'; set_param(model, 'PostCodeGenCommand',... pcgFunctions);
The following call to set_param defines PostCodGenCommand to evaluate the function analyzegencode.
set_param(model, 'PostCodeGenCommand',... 'analyzegencode(buildInfo)');
The Simulink Coder product provides the ability to suppress makefile generation during the build process. For example, you might do this to integrate tools into the build process that are not driven by makefiles.
To instruct the Simulink Coder build process to not generate a makefile, do one of the following:
Clear the Generate makefile option on the Code Generation pane of the Configuration Parameters dialog box.
Set the value of the configuration parameter GenerateMakefile to off.
When you suppress makefile generation,
You no longer can explicitly specify a make command or template makefile.
You must specify your own instructions for any post code generation processing, including compilation and linking, in a post code generation command as explained in Program a Post Code Generation Command and Define a Post Code Generation Command.
![]() | Recompile Precompiled Libraries | Configure Generated Code with TLC | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |