Main Content

setTargetProvidesMain

Disable inclusion of code generator provided (generated or static) main.c source file during build

Description

setTargetProvidesMain(buildinfo,providesmain) disables the inclusion of a sample main.c source file from the code generator.

To replace the sample main.c file from the code generator with a custom main.c file:

  1. In the ert_make_rtw_hook.m or grt_make_rtw_hook.m file, call the setTargetProvidesMain function at the 'after_tlc' stage.

  2. If the System target file model configuration parameter is ERT-based, clear the Generate an example main program check box.

example

Examples

collapse all

To apply the setTargetProvidesMain function:

Add buildInfo to the arguments in the function call.

function ert_make_rtw_hook(hookMethod,Name,rtwroot, ...
   templateMakefile,buildOpts,buildArgs,buildInfo)

Add the setTargetProvidesMain function to the 'after_tlc' stage.

case 'after_tlc'
 % Called just after to invoking TLC Compiler (actual code generation.)
 % Valid arguments at this stage are hookMethod, Name, and
 % buildArgs, buildInfo
 %
 setTargetProvidesMain(buildInfo,true);

Use the Configuration Parameters > Code Generation > Custom Code > Source Files field to add your custom main.c to the project. When you indicate that the target provides main.c, the project requires this file to build without errors.

See also Use addUserHook Method to Customize Build Process.

Input Arguments

collapse all

RTW.BuildInfo object that contains information for compiling and linking generated code.

The providesmain argument specifies whether the code generator includes a (generated or static) main.c source file.

  • false — The code generator includes a sample main.obj object file.

  • true — The target provides the main.c source file.

Version History

Introduced in R2015a