Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Customizing Post Code Generation Build Processing

The Real-Time Workshop 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.

  1. Program the post code generation command.

  2. Define the post code generation command.

  3. Suppress makefile generation, if appropriate for your application.

  4. Build the model.

  5. Modify the command, if necessary, and rebuild the model. Repeat this step until the build results are acceptable.

Build Information Object

At the start of a model build, the Real-Time Workshop build process logs the following build option and dependency information to a temporary build information object:

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 Real-Time Workshop documentation. Programming a Post Code Generation Command explains how to use the functions to control post code generation build processing.

Programming a Post Code Generation Command

For certain applications, it might be necessary to control aspects of the build process after the code generation. For example, this is necessary when 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 an M-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...
ScriptScript can gain access to the model name and the build information directly
FunctionFunction 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 Real-Time Workshop 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 Real-Time Workshop documentation.

Defining a Post Code Generation Command

After you program a post code generation command, you need to inform the Real-Time Workshop 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 Real-Time Workshop 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.

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)');

Suppressing Makefile Generation

The Real-Time Workshop 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 Real-Time Workshop build process to not generate a makefile, do one of the following:

When you suppress makefile generation,

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS