MATLAB Examples

Customize Build Process with PostCodeGenCommand and Relocate Generated Code to an External Environment

This example shows how to use the Build Information API and the Post Code Generation Command parameter, PostCodeGenCommand.

The PostCodeGenCommand parameter value is rtwdemo_buildinfo_data. This value directs the build process to invoke the function after code generation.

The example also demonstrates how to use the rtwmakecfg.m API.

For more information, click on the documentation links in the model.

Contents

Open Example Model

Open the example model rtwdemo_buildinfo.

open_system('rtwdemo_buildinfo');

Generate Code from Model

Double-click on the Generate Code Using Simulink Coder button to generate code for the GRT target.

Or, if Embedded Coder is installed, double-click on the Generate Code Using Embedded Coder button to generate code for the ERT target.

The build process generates a BuildInfo.html file to document the build information object.

Examine the Build Process Customizations and Output

Use the links in the model to examine the build process customizations and the post code generation query of the build information object.

To view the BuildInfo.html file in a Web browser, click on Open BuildInfo.html.

The example uses the PostCodeGenCommand parameter of the model to generate the html file from the build information object. The file provides hyperlinks to open the source files (generated code) from the model. To view the PostCodeGenCommand parameter value, type:

get_param('rtwdemo_buildinfo','PostCodeGenCommand');

This value indicates a function to execute in the Post Code Gen Command stage.

rtwdemo_buildinfo_data(buildInfo);

To study how the example uses the rtwmakecfg API, click on Open rtwmakecfg.m or type:

edit rtwmakecfg.m;

To study the API for the buildInfo.mat object, click on Open rtwdemo_buildinfo_data.m or type:

edit rtwdemo_buildinfo_data.m;

The buildInfo.mat object is available at:

rtwdemo_<target>_rtw\buildInfo.mat

At the end of the rtwdemo_buildinfo_data.m post code generation function, the function invokes packNGo to package the source and objects identified in the buildInfo object for relocation.

Further Study Topics