Main Content

getDefines

Get preprocessor macro definitions from model build information

Description

example

[macrodefs,identifiers,values] = getDefines(buildinfo,includeGroups,excludeGroups) returns preprocessor macro definitions from the build information.

The function requires the buildinfo, macrodefs, identifiers, and values arguments. You can use optional includeGroups and excludeGroups arguments. These optional arguments let you include or exclude groups selectively from the preprocessor macro definitions returned by the function.

If you choose to specify excludeGroups and omit includeGroups, specify a null character vector ('') for includeGroups.

Examples

collapse all

Get the preprocessor macro definitions stored in the build information myModelBuildInfo.

myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'},'OPTS');
[defs,names,values] = getDefines(myModelBuildInfo);
>> defs

defs = 

    '-DPROTO=first'   '-DDEBUG'   '-Dtest'   '-DPRODUCTION'

>> names

names = 
 
    'PROTO'
    'DEBUG'
    'test'
    'PRODUCTION'

>> values

values = 

    'first'
    ''
    ''
    ''

Get the preprocessor macro definitions stored with the group name Debug in the build information myModelBuildInfo.

myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
   {'Debug' 'Debug' 'Debug' 'Release'});
[defs,names,values] = getDefines(myModelBuildInfo,'Debug');
>> defs

defs = 

    '-DPROTO=first'   '-DDEBUG'     '-Dtest'

Get the preprocessor macro definitions stored in the build information myModelBuildInfo, except those definitions with the group name Debug.

myModelBuildInfo = RTW.BuildInfo;
addDefines(myModelBuildInfo, ...
   {'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, ...
   {'Debug' 'Debug' 'Debug' 'Release'});
[defs,names,values] = getDefines(myModelBuildInfo,'','Debug');
>> defs

defs = 

    '-DPRODUCTION'

Input Arguments

collapse all

To use the includeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

To use the excludeGroups argument, view available groups by using myGroups = getGroups(buildInfo).

Example: ''

Output Arguments

collapse all

The macrodefs provide the complete macro definitions with a -D prefix. When the function returns a definition:

  • If the -D was not specified when the definition was added to the build information, prepends a -D to the definition.

  • Changes a lowercase -d to -D.

The values provide anything specified to the right of the first equal sign in the macro definition. The default is an empty character vector ('').

Introduced in R2006a