Main Content

rtwbuild

(Not recommended) Build generated code from a model

rtwbuild is not recommended. Use slbuild instead. rtwbuild is an alias for slbuild. If you run rtwbuild, the software executes slbuild.

Description

rtwbuild(model) builds a standalone binary executable file from the specified model, using the current configuration parameter settings. If the model is not loaded, rtwbuild loads the model before starting the build process.

rtwbuild(model,Name,Value) uses additional options specified by one or more Name,Value pair arguments.

rtwbuild(subsystem) generates subsystem code and builds a binary executable file by using the current configuration parameter settings of your model. If the selected system target file creates an S-Function block, the function returns a non-empty block handle to an autogenerated S-Function wrapper. Before you run the command, you must open or load the parent model.

rtwbuild(subsystem,'Mode','ExportFunctionCalls') generates code from subsystem that includes function calls that you can export to external application code if you have Embedded Coder®.

blockHandle = rtwbuild(subsystem,'Mode','ExportFunctionCalls') returns the handle to a SIL block created for code generated from the specified subsystem if the Create block configuration parameter is set to SIL and if you have Embedded Coder. You can then use the SIL block for numerical equivalence testing.

Input Arguments

collapse all

Model for which to generate code or build an executable image, specified as an object or a character vector representing the model name.

Example: 'rtwdemo_exporting_functions'

Subsystem for which to generate code or build an executable image, specified as a character vector representing the subsystem name or the full block path.

Example: 'mydemo_exporting_functions/mydemo_subsystem'

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: rtwbuild('TopModelCode','ForceTopModelBuild',true)

The code generator rebuilds a model or submodels only if they have changed since the last model build. Use this argument to force regeneration of top model code.

ActionSpecify
Force the code generator to regenerate code for the top model of a system that includes referenced models true
Specify that the code generator determine whether to regenerate top model code based on model and model parameter changes false

Consider forcing regeneration of code for a top model if you change items associated with external or custom code, such as code for a custom target. For example, set ForceTopModelBuild to true if you change:

  • TLC code

  • S-function source code, including rtwmakecfg.m files

  • Integrated custom code

Alternatively, you can force regeneration of top model code by deleting folders in the Code generation folder, such as slprj or the generated model code folder.

If you do not specify a value, the Generate code only (GenCodeOnly) option on the Code Generation pane controls build process behavior.

If you specify a value, the argument overrides the Generate code only (GenCodeOnly) option on the Code Generation pane.

ActionSpecify

Generate code only.

true

Generate code and build executable file.

false
  • 'ExportFunctionCalls' –– If you have Embedded Coder, generates code from subsystem that includes function calls that you can export to external application code.

  • 'Normal' –– Does not export function calls.

Name the exported initialization function for specified subsystem.

Example: rtwbuild(subsystem,'Mode','ExportFunctionCalls','ExportFunctionInitializeFunctionName', fcnname)

Display build information in the Build Status window, specified as true or false. For more information about using the Build Status window, see Monitor Parallel Building of Referenced Models.

The Build Status window supports parallel builds of referenced model hierarchies. Do not use the Build Status window for serial builds.

ActionSpecify
Display build information in the Build Status windowtrue
No actionfalse

Specify whether to generate obfuscated C code, specified as true or false.

ActionSpecify
Generate obfuscated C code that you can share with third parties with reduced likelihood of compromising intellectual property.true
No action.false

Output Arguments

collapse all

Handle to SIL block created for generated subsystem code. Returned only if both of the following conditions apply:

  • You are licensed to use Embedded Coder software.

  • Create block model configuration parameter is set to SIL.

Tips

You can initiate code generation and the build process by:

  • Pressing Ctrl+B.

  • Selecting Code > C/C++ Code > Build Model.

  • Invoking the slbuild command from the MATLAB® command line.

Extended Capabilities

Version History

Introduced in R2009a

expand all