Mathworks REAL-TIME WORKSHOP 7 Reference

Real-Time Worksho
Reference
p
®
7
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support
suggest@mathworks.com Product enhancem ent suggestions
bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes
info@mathwo
com
rks.com
rks.com
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
®
Real-Time Workshop
© COPYRIGHT 2006–20 10 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Reference
Revision History
March 2006 Online only New for Version 6.4 September 2006 Online only Revised for Version 6.5 (Release 2006b) March 2007 Online only Revised for Version 6.6 (Release 2007a) September 2007 Online only Revised for Version 7.0 (Release 2007b) March 2008 Online only Revised for Version 7.1 (Release 2008a) October 2008 Online only Revised for Version 7.2 (Release 2008b) March 2009 Online only Revised for Version 7.3 (Release 2009a) September 2009 Online only Revised for Version 7.4 (Release 2009b) March 2010 Online only Revised for Version 7.5 (Release 2010a)
Product Limitations Summary
1
Function Reference
2
Build Information ................................. 2-2
Contents
Glossary
Build Process
Embedded MATLAB Cod e Generation
Project Documentation
Rapid Simulation
Target Language Compiler and Function Library
..................................... 2-4
............... 2-5
............................ 2-6
.................................. 2-7
.... 2-8
v
Alphabetical List
3
Block Reference
4
Custom Code ...................................... 4-2
Interrupt Templates
S-Function Target
VxWorks
.......................................... 4-5
............................... 4-3
................................. 4-4
Blocks — Alphabetical List
5
Configuration Parameters for Simulink Models
6
Real-Time Workshop Pane: General ................. 6-2
Real-Time W orkshop: General Tab Overview System targ et file Language Compiler optimization level Custom co mpiler optimization flags TLC options Generate makefile Make command Template makefile Ignore custom storage classes Ignore test point signals
........................................ 6-8
................................. 6-6
......................... 6-10
................... 6-12
...................................... 6-13
................................. 6-15
................................... 6-17
................................. 6-19
....................... 6-21
............................ 6-23
........... 6-5
vi Contents
Select objective ................................... 6-25
Prioritized objectives Set objectives Set Objectiv es — Code Generation Adv isor Dialog Box Check model Check model before generating code Generate code only Build/Generate code
..................................... 6-28
..................................... 6-31
............................... 6-27
... 6-29
.................. 6-32
................................ 6-34
............................... 6-36
Real-Time Workshop Pane: Report
Real-Time W orkshop: Report Tab Overview Create code generation report Launch report automatically Code-to-model Model-to-code Configure Eliminated / virtual blocks Traceable Simulink blocks Traceable Stateflow objects Traceable Embedded MATLAB functions
Real-Time Workshop Pane: Comments
Real-Time W orkshop: Comments Tab Overview Include comments Simulink block / Stateflow object comments Show eliminated blocks Verbose comm ents for SimulinkGlobal storage class Simulink block descriptions Simulink data object descriptions Custom comments (MPT objects only) Custom comments function Stateflow object descriptions Requirements in block comments
.................................... 6-45
..................................... 6-47
........................................ 6-49
................................. 6-61
........................ 6-43
.......................... 6-50
.......................... 6-52
......................... 6-54
............................ 6-63
......................... 6-65
......................... 6-71
........................ 6-73
.................. 6-37
....................... 6-40
.............. 6-56
.............. 6-58
.................... 6-67
................. 6-69
.................... 6-75
............ 6-39
........ 6-60
............ 6-62
..... 6-64
Real-Time Workshop Pane: Symbols
Real-Time W orkshop: Symbols Tab Overview Global variables Global types Field n ame of global types Subsystem methods Subsystem method arguments Local temporary variables Local block output variables
................................... 6-82
...................................... 6-85
.......................... 6-88
............................... 6-90
....................... 6-93
.......................... 6-95
......................... 6-98
................. 6-77
.......... 6-81
vii
Constant macros .................................. 6-100
Minimum mangle length Maximum identifier length Generate scalar inlined parameter as Signal naming M-function Parameter naming #define naming Use the same reserved names as Simulation Target Reserved names
.................................... 6-108
....................................... 6-110
................................... 6-114
................................... 6-117
........................... 6-103
.......................... 6-105
................. 6-107
................................ 6-112
..... 6-116
Real-Time Workshop Pane: Custom Code
Real-Time W orkshop: Custom Code Tab Overview Use the same custom code settings as Simulation Target Use local custom code settings (do not inherit from main
model) Source file Header file Initialize function Terminate function Include directories Source files Libraries
Real-Time Workshop Pane: Debug
Real-Time Workshop: Debug Tab Overview Verbose build Retain .rtw file Profile TLC Start TLC debugger when generating code Start TLC coverage when generating code Enable TLC assertion
Real-Time Workshop Pane: Interface
Real-Time Workshop: Interface Tab Overview Target function library Utility function generation Support: floating-point numbers Support: absolute time Support: non-finite numbers Support: continuous time Support: complex numbers Support: non-inlined S-functions
........................................ 6-124
....................................... 6-126
....................................... 6-127
................................. 6-128
................................ 6-129
................................. 6-130
....................................... 6-132
........................................ 6-133
.................. 6-134
..................................... 6-137
.................................... 6-138
...................................... 6-139
.............................. 6-142
............................. 6-149
.......................... 6-151
..................... 6-153
............................. 6-155
........................ 6-157
........................... 6-159
.......................... 6-161
..................... 6-163
............ 6-119
............ 6-136
............. 6-140
............. 6-141
................ 6-143
.......... 6-148
...... 6-122
.. 6-123
viii Contents
Support: variable-size signals ....................... 6-165
Multiword type definitions Maximum word length GRT compatible call interface Single output/update function Terminate function required Generate reusable code Reusable code error diagnostic Pass root-level I/O as Block parameter visibility Internal data visibility Block parameter access Internal data access External I/O access Generate destructor Use operator new for referenced model object
registration Generate preprocessor conditionals Suppress error status in real-time model data structure Configure Model Functions Configure C++ Encapsulation Interface MAT-file logging MAT-file variable name modifier Interface Generate C API for: signals Generate C API for: parameters Generate C API for: states Transport layer MEX-file arguments Static memory allocation Static memory buffer size
......................................... 6-207
................................ 6-191
.................................... 6-195
.................................. 6-203
................................... 6-213
.......................... 6-166
............................. 6-168
....................... 6-170
....................... 6-172
........................ 6-174
............................. 6-176
....................... 6-179
.............................. 6-181
.......................... 6-183
............................. 6-185
............................. 6-187
............................... 6-189
............................... 6-193
................... 6-197
.. 6-199
.......................... 6-201
............... 6-202
..................... 6-205
......................... 6-210
..................... 6-211
.......................... 6-212
............................... 6-215
........................... 6-217
........................... 6-219
Real-Time Workshop Pane: RSim Target
Real-Time W orkshop: RSim Target Tab O ve rview Enable RSim executa bl e to load parameters from a
MAT-file Solver selection Force storage classes to AUTO
Real-Time Workshop Pane: Real-Time Workshop
S-Function Code Generation Options
Real-Time Workshop S-Function Code Generation Options
Tab Overview
....................................... 6-224
................................... 6-225
....................... 6-226
.................................. 6-229
............. 6-221
....... 6-223
.............. 6-227
ix
Create new model ................................. 6-230
Use valu e for tunable parameters Include custom source code
.......................... 6-232
.................... 6-231
Real-Time Workshop Pane: Tornado Target
Real-Time Workshop: Tornado Target Tab Overview Target function library Utility function generation MAT-file logging MAT-file variable name modifier Code Format StethoScope Download to VxWorks target Base task priority Task stack size External mode Transport layer MEX-file arguments Static memory allocation Static memory buffer size
Parameter Reference
Recommended S ettings Summary Parameter Command-Line Information Summary
..................................... 6-244
...................................... 6-245
................................... 6-251
.................................... 6-252
................................... 6-254
............................. 6-236
.......................... 6-238
.................................. 6-240
..................... 6-242
........................ 6-247
................................. 6-249
............................... 6-256
........................... 6-258
........................... 6-260
.............................. 6-262
.................... 6-262
.......... 6-233
.... 6-235
....... 6-287
x Contents
Configuration Param eters for Embedded
7
Real-Time Workshop Dialog Box for Embedded
MATLAB Coder
Real-Time Workshop Dialog Box Over view General Tab Report Tab Symbols Tab Custom Code Tab Debug Tab Interface Tab Code Style Tab Advanced Tab
....................................... 7-6
....................................... 7-17
................................. 7-2
...................................... 7-3
..................................... 7-8
................................. 7-14
..................................... 7-19
.................................... 7-23
.................................... 7-26
MATLAB Coder
............. 7-2
Generate code only ................................ 7-27
Automatic C MEX Generation Dialog Box for Embedd ed
MATLAB Coder
Automatic C MEX Generation D ialo g Box Overv iew General Tab Report Tab Symbols Tab Custom Code Tab Advanced Tab
Hardware Implementation Dialog Box for Embedded
MATLAB Coder
Hardware Implementation Parameters Dialog Box
Overview Hardware Implementation Parameters
....................................... 7-37
................................. 7-28
..... 7-28
...................................... 7-29
..................................... 7-38
................................. 7-40
.................................... 7-43
................................. 7-46
...................................... 7-46
................ 7-48
Compiler Options Dialog Box
Compiler Optio ns Parameters Dialog Box Overv iew Compiler Optio ns Parameters
....................... 7-55
....................... 7-57
Model Advisor Checks
8
Real-Time Workshop Checks ....................... 8-2
Real-Time Workshop Overview Check so lver for code generation Identify questionable blocks within the specified system Check the hardware implementation Identify questionable software environment
specifications Identify questionable code instrumentation (data I/O) Check for blocks that have constraints on tunable
parameters Check for blocks not recommended for MISRA-C:2004
compliance Check configuration parameters for MISRA-C:2004
compliance Check for model refe rence configuration mismatch
................................... 8-8
.................................... 8-11
..................................... 8-13
..................................... 8-14
...................... 8-3
..................... 8-4
.................. 8-7
...... 8-17
..... 7-55
.. 8-6
.... 8-10
xi
Disable signal logging .............................. 8-18
Identify blocks that generate expensive saturation and
rounding code Check sample times and tasking mode Identify questionable subsystem settings Identify questionable fixed-point operations Check model configuration settings against code generation
objectives Check for efficiency optimization parameters
.................................. 8-19
................ 8-20
.............. 8-21
............ 8-22
...................................... 8-31
........... 8-33
Index
xii Contents

Product Limitations Summary

The f ollow ing topics identify Real-Time Workshop®feature limitations:
“C++ Target Language Limitations”
“packNGo Function Limitations”
“Tunable Expression Limitations”
“Limitations on Specifying Data Types in the Workspace Explicitly”
1
“Code Reuse Limitations”
“Real-Time Workshop Model Referencing Limitations”
“External Mode Limitations”
“Noninlined S-Function Parameter Type Limitations”
“S-Function Target Limitations”
“Rapid Simulation Target Limitations”
“Asynchronous Support Limitations”
“C API Limitations”
“Block Support Considerations”
1 Product Limitations Summary
1-2

Glossary

Glossary
application modules
With respect to Real-Time W orkshop program architecture, these are collections o f programs that implement functions carried out by the system-dependent, system-independent, and application components.
atomic subsystem
Subsystem whose blocks are executed as a unit before moving on. Conditionally executed subsystems are atomic, and atomic subsystems are nonvirtual. Unconditionally executed subsystems are virtual by default, but can be designated as atomic. The Real-Time Workshop build process can generate reusable code only for nonvirtual subsystems.
base sample rate
Fundamental sample time of a model; in practice, limited by the fastest rate at which a processor’s timer can generate interrupts. All sample times must be integer multiples of the base rate.
block I/O structure (model_B)
Global data structure for storing block output signals. The number of block output signals is the sum of the widths of the data output ports of all nonvirtual blocks in your model. By default, Simulink Real-Time Workshop build process try to reduce the size of the structure by reusing the entries in the model_B structure and making other entries local variables.
®
and the
model_B
block target file
File that describes how a specific Simulink block is to be transformed to a language such as C, based on the block’s description in the Real-Time Workshop file (
model.rtw). Typically, there is one block target file for
each Simulink block.
code reuse
Optimization whereby code generated for ide ntical no nv irtual subsystems is collapsed into one function that is called for each subsystem instance with appropriate parameters. Code reuse, along with expression folding, can dramatically reduce the amount of generated code.
Glossary-1
Glossary
configuration
Set of attributes for a model which defines parameters governing how a model simulates and generates code. A model can have one or more such configuration sets, and users can switch between them to change code generation targets or to modify the behavior of models in other ways.
configuration component
Named element of a configuration set. Configuration components encapsulate settings associated with the Solver, Data Import/Export,
Optimization, Diagnostics, Hardware Implementation, Model Referencing,andReal-Time Workshop panes in the Configuration
Parameters dialog box. A component may contain subcomponents.
embedded real-time (ERT) target
Target configuration that generates model code for execution on an independent e mbe dded real-time system. R equires a Real-Time Workshop
®
Embedded Coder™ license.
expression folding
Code optimization technique that minimizes the computation of intermediate results at block outputs and the storage of such results in temporary buffers or variables. It can dramatically improve the efficiency of generated code, achie v ing results that compare favorably with hand-optimized code.
Glossary-2
file extensions
The table below lis ts the Simulink, Target Language Compiler, and Real-Time Workshop file extensions.
Extension Created by Description
.c or .cpp
.h
Target Language Compiler
Target Language Compiler
The generated C or C++ code
C/C++ include header file used by the
.cpp program
.c or
Extension Created by Description
.mdl
Simulink Contains structures
associated with Simulink block diagrams
.mk
Real-Time Workshop
Makefile specific to your model that is derived from the template makefile
.rtw
Real-Time Workshop Intermediate
compilation (
model.rtw)ofa
.mdl file used in
generating C or C++ code
.tlc
The MathWorks and Real-Time Workshop users
Target Language Compiler script files that the Real-Time Workshop build process uses to generate code for targets and blocks
.tmf
Supplied with
Template makefiles
Real-Time Workshop
.tmw
Real-Time Workshop Project marker
file inside a build directory that identifies the date and product version of g enerated code
Glossary
generic real-time (GRT) target
Target configuration that generates model code for a real-time system, with the resulting code executed on your workstation. (Execution is not tied to a real-time clock.) You can use GRT as a starting point for targeting custom hardware.
Glossary-3
Glossary
host system
Computer sy stem on which you create and may compile your real-time application. Also referred to as emulation hardware.
inline
Generally, this means to place something directly in the generated source code. You can inline parameters and S-functions using the Real-Time Workshop software and the Target Language Compiler.
inlined parameters
(Target Language Compiler Boolean global variable:
InlineParameters)
The numerical values of the block parameters are hard-coded into the generated code. Advantages include faster execution and less memory use, but you lose the ability to change the block parameter values at run time.
inlined S-function
An S-function can be inlined into the gen erate d code by implementing it as a
.tlc file. The code for this S-function is placed in the generated
model code itself. In contrast, noninlined S-functions require a function call to an S-function residing in an external MEX -file.
Glossary-4
interrupt service routine (ISR)
Piece of code that your processor executes when an external event, such as a timer, occurs.
loop rolling
(Target Language Compiler global variable:
RollThreshold) Depending
on the block’s operation and the width of the input/output ports, the generated code uses a
for statement (rolled code) instead of repeating
identical lines of code (flat code) over the signal width.
make
Utility to maintain, update, and regenerate related programs and files. Thecommandstobeexecutedareplacedinamakefile.
makefiles
Files that contain a collection of commands that allow groups of programs, object files, libraries, and so on, to interact. Makefiles are executed by your development system’s make utility.
model.rtw
Intermediate record file into which the Real-Time Workshop build process compiles the blocks, signals, states, and parameters a model, which the Target Language Compiler reads to generate code to represent the model.
multitasking
Process by which a microprocessor schedules the handling of multiple tasks. In generated code, the number of tasks is equal to the number of sample times in your model. See also pseudo multitasking.
noninlined S-function
In the context of the Real-Time Workshop build process, this is any C MEX S-function that is not implemented using a customized If you create a C MEX S-function as part of a Simulink model, it is by default noninlined unless you write your o wn
.tlc file that inlines it.
nonreal-time
Simulation environment of a block diagram provided for high-speed simulation of your model. Execution is not tied to a real-time clock.
Glossary
.tlc file.
nonvirtual block
Any block that performs some algorithm, such as a Gain block. The Real-Time Workshop build process generates code for all nonvirtual blocks, either inline or as separate functions and files, as directed by users.
pseudo multitasking
On processors that do not offer multitasking support, you can perform pseudo multitasking by scheduling events on a fixed time sh aring b asis.
real-time model data structure
The Real-Time Workshop build process encapsulates information about the root model in the real-time model data structure, often abbreviated as rtM. rtM contains global information related to timing, solvers, and logging, and model data such as inputs, outputs, states, and parameters.
real-time system
Computer that processes real-world events as they happen, under the constraint of a real-time clock, and that can implement algorithms in
Glossary-5
Glossary
dedicated hardware. Examples include m obile telephones, test and measurement devices, and avionic and automotive control systems.
Real-Time Workshop target
Set of code files generated by the Real-Time Workshop build process for a standard or custom target, specified by a Real-Time Workshop configuration component. These source files can be built into an executable program that will run independently of Simulink. See also simulation target, configuration.
run-time interface
Wrapper around the generated code that can be built into a stand-alone executable. The run-time interface consists of routines to move the time forward, save logged variables at the appropriate time steps, and so on The run-time interface is responsible for managing the execution of the real-time program created from your Simulink block diagram.
S-function
Customized Simulink block written in C, Fortran, or MATLAB The Real-Time Workshop build process can target C code S-functions as is or users can inline C code S-functions by preparing TLC scripts for them.
simstruct
Simulink data structure and associated application program interface (API) that enables S-functions to communicate with other entities in models. Simstructs are included in code generated by the Real-Time Workshop build process for noninlined S-functions.
simulation target
Set of code files generated for a model which is referenced by a Model block. Simulation target code is generated into
/slprj/sim project
directory in the working directory. Also an executable library compiled from these codes that implements a Model block. See also Real-Time Workshop target.
single-tasking
Mode in which a model runs in one task, regardless of the number of sample rates it contains.
®
code.
Glossary-6
stiffness
Property of a problem that forces a numerical method, in one or more intervals of integration, to use a step length that is excessively small in relation to the smoothness of the exact solution in that interval.
system tar get file
Entry point to the Target Language Compiler program, used to transformtheReal-TimeWorkshopfileintotarget-specificcode.
target file
File that is compiled and executed by the Target Language Compiler. The block and system target TLC files used specify how to transform the Real-Time Workshop file (
model.rtw) i n t o target-specific code.
Target Language Compiler (TLC)
Program that compiles and executes system and target files by translating a
model.rtw file into a target language by means of TLC
scripts and tem plate makefiles.
Glossary
Tar get Language Compiler program
One or more TLC script files that describe how to convert a file into generated code. There is one TLC file for the target, plus one for each built-in block. Users can provide their own TLC files to inline S-functionsortowrapexistingusercode.
target system
Specific or generic computer system on which your real-time application is intended to execute. Also referred to as embedded hardware.
targeting
Process of creating software modules appropriate for execution on your target system.
task id en tifier (tid)
In generated code, each sample rate in a multirate model is assigned a task identifier (
tid). The tid is used by the model output and update
routines to control the portion of your model that should execute at a given time step. Single-rate systems ignore the
tid. See also base
sample rate.
model.rtw
Glossary-7
Glossary
template makefile
Line-for-linemakefileusedbyamakeutility. TheReal-TimeWorkshop build process converts the templatemakefiletoamakefilebycopying the contents of the template makefile (usually makefile (usually
system.mk) replacing tokens describing your model’s
system.tmf)toa
configuration.
virtual block
Connection or graphical block, for example a Mux block, that has no algorithmic functionality. Virtual blocks incur no real-time overhead as no code is generated for them.
work vector
Data structures for saving internal states or similar information, accessible to blocks that may require such work areas. These include state work ( pointer work (
rtDWork), real work (rtRWork ), integer work (rtIWork), and
rtPWork) structures. For example, the Memory block uses
a real work element for each signal.
Glossary-8

Function Reference

Build Information (p. 2-2) Set up and manage model’s build
information
Build Process (p. 2-4) Perform build process steps
2
Embedded MATLAB Code Generation (p. 2-5)
Project D ocumentation (p. 2-6)
Rapid Simulation (p. 2-7) Get model’s parameter structures
Target Language Compiler and Function Library (p. 2-8)
Generate embeddable C code or MEX code from MATLAB language file
Document generated code
Optimize code generated for model’s blocks
2 Function Reference

Build Information

addCompileFlags Add compiler options to model’s
build information
addDefines Add preprocessor macro definitions
to model’s build information
addIncludeFiles
addIncludePaths
addLinkFlags
addLinkObjects Add link objects to model’s build
addNonBuildFiles
addSourceFiles Add source files to model’s build
addSourcePaths Add source paths to model’s build
addTMFTokens
findIncludeFiles Find and add include (header) files
getCompileFlags Compiler options from model’s build
Add include files to model’s build information
Add include paths to model’s build information
Add link options to model’s build information
information
Add nonbuild-related files to model’s build information
information
information
Addtemplatemakefile(TMF)tokens that provide build-time information for m akefile generation
to build information object
information
2-2
getDefines Preprocessor macro definitions from
model’s b uild information
getFullFileList
getIncludeFiles
All files from model’s build information
Include files from model’s build information
Build Information
getIncludePaths
Include paths from model’s build information
getLinkFlags
Link options from model’s build information
getNonBuildFiles
Nonbuild-related files from model’s build information
getSourceFiles Source files from model’s build
information
getSourcePaths Source paths from model’s build
information
packNGo Package model code in zip file for
relocation
updateFilePathsAndExtensions Update files in model’s build
information with mis sing paths and file extensions
updateFileSeparator Change file separator used in
model’s b uild information
2-3
2 Function Reference

Build Process

RTW.getBuildDir
rtwbuild Initiate build process
rtwrebuild Rebuild gener
rtw_precompile_libs Build libraries within model without
switchTarget
Build directory informa t ion for specified model
ated code
building model
Specify target for configuration set
2-4

Embedded MATLAB Code Generation

Embedded MATLAB®Code Generation
emlc
Generate embeddable C/C++ code from MATLAB code
2-5
2 Function Reference

Project Documentation

rtwreport
rtwtrace
Generate report documenting generated code for model
Trace block to generated code
2-6

Rapid Simulation

Rapid Simulation
rsimgetrtp
rsimsetrtpparam
Global model parameter structure
Set parameters of parameter structure
rtP model
2-7
2 Function Reference

Target Language Compiler and Function Library

tlc
See the “TLC Function Library Reference” in the Real-Time Workshop Target Language Compiler documentation for a list of Target Language Compiler functions.
Invoke Target Language Compiler to convert model description file to generated code
2-8

Alphabetical List

3
addCompileFlags
Purpose Add compiler options to model’s build information
Syntax addCompileFlags(buildinfo, options, groups)
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
options
A character array or cell array of character arrays that specifies the compiler options to be added to the build information. The function adds each option to the end of a compiler option vector. If you specify m ultiple options within a single character array, for example as a single element. For example, if you add then
'-Zi -Wall' '-O3'
groups
(optional) A character array or cell array of character arrays that groups specified compiler options. You can use groups to
Document the use of specific compiler op tions
Retrieve or apply collections of compiler options
You can apply
Asinglegroupnametooneormorecompileroptions
'-Zi -Wall', the function adds the string to the vector
'-Zi -Wall' and
'-O3', the vector cons ists of two elements, as shown below.
3-2
Multiple group names to collections of compiler options
(available for nonmakefile build environments only)
addCompileFlags
To ...
Apply one group
Specify
groups as a...
Character array. name to all compiler options
Apply different group names to compiler options
Cell array of character arrays such that
the number of group names matches
the number of elements you specify for
options.
Note
To specify compiler options to be used in the standard
Real-Time Workshop makefile build process, specify either
'OPTS' or 'OPT_OPT S'.
groups as
To control compiler optimizations for your Real-Time Workshop
makefile build at Simulink GUI level, use the Compiler optimization level parameter on the Real-Time Workshop pane of the Simulink Configuration Parameters dialog box. The Compiler optimization level parameter provides
Target-independent values
runs)
and Optimizations off (faster builds),which
Optimizations on (faster
allow you to easily toggle compiler optimizations on and off during code development
The value
Custom for entering custom compiler optimization
flags at Simulink GUI level (rather than at other levels of the build process)
If you use the configuration parameter Make command to specify compiler options for your Real-Time Workshop makefile build using
MEX_OPT_FILE,thevalueofCompiler optimization level is
OPT_OPTS, MEX_OPTS (except MEX_OPTS="-v"), or
ignored and a warning is issued about the ignored parameter.
3-3
addCompileFlags
Description The addCom pile Flags function adds specified compiler options to the
model’s build information. Real-Time Workshop stores the compiler options i n a vector. The function adds options to the end of the vector based on the order in which you specify them.
In addition to the required use a n optional
groups argument to group your options.
buildinfo and options arguments, you can
Examples • Add the compiler option -O3 to build information myModelBuildInfo
andplacetheoptioninthegroupOPTS.
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, '-O3', 'OPTS');
Add the compiler options -Zi and -Wall to build information
myModelBuildInfo and place the options in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, '-Zi -Wall', 'OPT_OPTS');
For a nonmakefile build environment, add the compiler options -Zi,
-Wall,and-O3 to build information myModelBuildInfo.Placethe
options group
-Zi and -Wall in the group Debug and the option -O3 in the
MemOpt.
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'});
See Also addDefines, addLinkFlags, getCompileFlags
“Customizing Post Code Generation Build Processing”
3-4
addDefines
Purpose Add preprocessor macro definitions to m odel’s build information
Syntax addDefines(buildinfo, macrodefs, groups)
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
macrodefs
A character array or cell array of character arrays that specifies thepreprocessormacrodefinitionstobeaddedtotheobject. The function adds each definition to the end of a comp il er option vector. If you specify multiple definitions within a single character array, for exam ple thestringtothevectorasasingleelement. Forexample,ifyou add consists of two elements, as shown below.
'-DPROTO -DDEBUG' '-DPRODUCTION'
groups
(optional) A character array or cell array of character arrays that groups specified definitions. You can use groups to
Document the use of specific macro definitions
Retrieve or apply groups of macro definitions
You can apply
'-DRT -DDEBUG',thefunctionadds
'-DPROTO -DDEBUG' and then '-DPRODUCTION',thevector
Asinglegroupnametooneormoremacrodefinitions
Multiple group names to collections of macro definitions
(available for nonmakefile build environments only)
3-5
addDefines
To ...
Apply one group name to all macro definitions
Apply different group names to macro definitions
Note To specify macro definitions to be u sed in the standard Real-Time Workshop m ake file build process, specify either
'OPTS' or 'OPT_OPTS'.
Specify
Character array.
Cell array of character arrays such that the number of group names matches the number elements you specify for
macrodefs.
groups as a...
groups as
Description The addDefines function adds specified preprocessor macro definitions
to the model’s build information. The Real-Time Workshop software stores the definitions in a vector. The function adds definitions to the end of the vector based on the order in which you specify them.
In addition to the required can use an optional
groups argument to group your options.
buildinfo and macrodefs arguments, you
Examples Add the macro definition -DPRODUCTION to build information
myModelBuildInfo and place the definition in the group OPTS.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, '-DPRODUCTION', 'OPTS');
Add the macro definitions -DPROTO and -DDEBUG to build information
myModelBuildInfo and place the definitions in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, ...
'-DPROTO -DDEBUG', 'OPT_OPTS');
3-6
For a nonmakefile build environment, add the compiler definitions
-DPROTO, -DDEBUG,and-DPRODUCTION to build information myModelBuildInfo. Place the definitions -DPROTO and -DDEBUG in the
group
Debug and the definition -DPRODUCTION in the group Release.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, ...
{'-DPROTO -DDEBUG' '-DPRODUCTION'}, ...
{'Debug' 'Release'});
See Also addCompileFlags, addLinkFlags, getDefines
“Customizing Post Code Generation Build Processing”
addDefines
3-7
addIncludeFiles
Purpose Add include files to model’s build information
Syntax addIncludeFiles(buildinfo, filenames, paths, groups)
paths
and groups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of include files to be added to the build information.
Thefilenamestringscanincludewildcard characters, provided that the dot delimiter ( and
The function adds the filenames to the end of a vector in the order that you specify them.
The function removes duplicate include file entries that
You specify as input
Already exist in th e include file vector
Have a path that matches the path of a matching filename
A duplicate entry consists of an exact match of a path string and corresponding filename.
.)ispresent. Examplesare'*.*', '*.h',
'*.h*'.
3-8
paths (optional)
A character array or cell array of character arrays that specifies paths to the include files. The function adds the paths to the end of a vector in the order that you specify them. If you specify a single path as a character array, the function uses that path for all files.
groups (optional)
A character array or cell array of character arrays that groups specified include files. You can use groups to
addIncludeFiles
Document the u se of specific include files
Retrieve or apply group s of include files
You can apply
A single g roup name to an include file
A single group name to multiple include files
Multiple group names to collections of multiple include files
To ...
Apply o ne group name to all include files
Apply different group names to include files
Specify
Character array.
Cell array of chara cter arrays such that the number of group names that you specify matches the number of elements you specify for
groups as a...
filenames.
Description The addIncludeFiles function adds specified include files to the
model’s build information. The Real-Time Workshop software stores the include files in a vector. The function adds the filenames to the end of the vector in the order that you specify them.
In addition to the required can specify optional each optional argument as a character array or a cell array of character arrays.
If You Specify an Optional Argument as a...
Character array Applies the character array to all include files it adds to
Cell array of character arrays Pairs each character array with a spe c if ied include file.
The Func tion ...
the build information
Thus, the length of the cell array must match the length of the ce ll array you specify for
paths and groups arguments. You can specify
buildinfo and filenames arguments, you
filenames.
3-9
addIncludeFiles
If you choose to s pecify groups,butomitpaths, specify a null string (
'')forpaths.
Note The packNGo function also can add include files to a model’s build information. If you call the
packNGo finds include files from all source and include paths recorded in
the model’s build information and adds them to the build information.
Examples • Add the include file mytypes.h to build information
myModelBuildInfo and place the fil e in the group SysFiles.
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, ... 'mytypes.h', '/proj/src', 'SysFiles');
Add the include files etc.h and etc_private.h to build information
myModelBuildInfo and place the files in the group AppFiles.
packNGo function to package model code,
3-10
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, ... {'etc.h' 'etc_private.h'}, ... '/proj/src', 'AppFiles');
Add the include files etc.h, etc_private.h,andmytypes.h to
build information
etc_private.h with the string AppFiles and the file mytypes.h
myModelBuildInfo.Groupthefilesetc.h and
with the string SysFiles.
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, ... {'etc.h' 'etc_private.h' 'mytypes.h'}, ... '/proj/src', ... {'AppFiles' 'AppFiles' 'SysFiles'});
Add all of the .h files in a specified directory to build information
myModelBuildInfo and place the files in the group HFiles.
addIncludeFiles
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, ... '*.h', '/proj/src', 'HFiles');
See Also addIncludePaths, addSourceFiles, addSourcePaths,
findIncludeFiles, getIncludeFiles, updateFilePathsAndExtensions, updateFileSeparator
“Customizing Post Code Generation Build Processing”
3-11
addIncludePaths
Purpose Add include paths to model’s build information
Syntax addIncludePaths(buildinfo, paths, groups)
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
paths
A character array or cell array of character arrays that specifies include file paths to be added to the build information. The function adds the paths to the end of a vector in the order that you specify them.
The function removes duplicate include file entries that
You specify as input
Already exist in the include path vector
Have a path that matches the path of a matching filename
A duplicate entry consists of an exact match of a path string and corresponding filename.
groups (optional)
A character array or cell array of character arrays that groups specified include paths. You can use groups to
Document the use of specific include paths
3-12
Retrieve or apply groups of include paths
You can apply
A single group name to an include path
A single group name to multiple inclu de paths
Multiple group names to collections of multiple include paths
addIncludePaths
To ...
Apply one group name to all include paths
Apply different group names to include paths
Specify
Character array.
Cell array of character arrays such that the number of group names that you specify matches the number of elements you specify for
groups as a...
paths.
Description The addIncludePaths function adds specified include paths to the
model’s build information. The Real-Time Workshop software stores the include paths in a vector. The function adds the paths to the end of the vector in the order that you specify them.
In addition to the required specify an optional character array or a cell array of character arrays.
If You Specify an Optional Argument as a...
Character array Applies the character array to all
groups argument. You can specify groups as a
buildinfo and paths arguments, you can
The Fun ction...
include paths it adds to the build information.
Cell array of character arrays
Pairs each character array with a specified include path. Thus, the length of the cell array m us t match the length of the cell array you specify for
paths.
3-13
addIncludePaths
Examples Add the include path /etcproj/etc/etc_build to build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addIncludePaths(myModelBuildInfo,... '/etcproj/etc/etc_build');
Add the include paths /etcproj/etclib and
/etcproj/etc/etc_build to build information myModelBuildInfo
and place th e files in the group etc.
myModelBuildInfo = RTW.BuildInfo; addIncludePaths(myModelBuildInfo,... {'/etcproj/etclib' '/etcproj/etc/etc_build'},'etc');
• Add the include paths /etcproj/etclib, /etcproj/etc/etc_build,
and
/common/lib to build information myModelBuildInfo.Groupthe
paths
/etc/proj/etclib and /etcproj/etc/etc_build with the
string
etc and the path /common/lib with the string shared.
myModelBuildInfo = RTW.BuildInfo; addIncludePaths(myModelBuildInfo,... {'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
See Also addIncludeFiles, addSourceFiles, addSourcePaths,
getIncludePaths, updateFilePathsAndExtensions, updateFileSeparator
“Customizing Post Code Generation Build Processing”
3-14
Purpose Add link op tions to mode l’s build information
Syntax addLinkFlags(buildinfo, options, groups)
addLinkFlags
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
options
A character array or cell array of character arrays that specifies the linker options to be added to the build information. The function adds each option to the e nd of a linker option v ector. If you specify m ultiple options within a single character array, for example a single element. For example, if you add
'-T', the vector consists of two elements, as shown below.
'-MD -Gy' '-T'
groups
(optional) A character array or cell array of character arrays that groups specified linker options. You can use group s to
Document the u se of specific linker options
Retrieve or apply groups of linker options
You can apply
A single group name to one or more linker options
'-MD -Gy', the function adds the string to the vector as
'-MD -Gy' and then
Multiple group names to collections of linker options (avail able
for nonmakefile build environments only)
3-15
addLinkFlags
To ...
Apply one group name to all linker options
Apply different group names to linker options
Note To specify linker options to be used in the standard Real-Time Workshop m ake file build process, specify either
'OPTS' or 'OPT_OPTS'.
Specify
Character array.
Cell array of character arrays s uch that the number of group names matches the number of elements you specify for
options.
groups as a...
groups as
Description The addLinkFlags function adds specified linker options to the model’s
build information. The Real-Time Workshop software stores the linker options i n a vector. The function adds options to the end of the vector based on the order in which you specify them.
In addition to the required use a n optional
groups argument to group your options.
buildinfo and options arguments, you can
Examples • Add the linker -T option to build information myModelBuildInfo and
place the option in the group
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, '-T', 'OPTS');
Add the linker options -MD and -Gy to build information
myModelBuildInfo and place the options in the group OPT_OPTS.
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, '-MD -Gy', 'OPT_OPTS');
3-16
OPTS.
• For a nonmakefile build environment, add the linker options -MD, -Gy,
and
-T to build information myModelBuildInfo.Placetheoptions
-MD and-Gy in the group Debug and the option -T in the groupTemp.
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, ...
{'Debug' 'Temp'});
See Also addCompileFlags, addDefines, getLinkFlags
“Customizing Post Code Generation Build Processing”
addLinkFlags
3-17
addLinkObjects
Purpose Add link objects to model’s build information
Syntax addLinkObjects(buildinfo, linkobjs, paths, priority,
precompiled, linkonly, groups)
All arguments except buildinfo , l inko bjs,andpaths are optional. If you specify an optional argument, you must specify all of the optional arguments preceding it.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
linkobjs
A character array or cell array of character arrays that specifies the filenames of linkable objectstobeaddedtothebuild information. The function adds the filenames that you specify in the function call to a vector that stores the object filenames in priority order. If you specify multiple objects that have the same priority (see the vector based on the order in which you specify the object filenames in the cell array.
priority below), the function adds them to
3-18
The function removes duplicate link objects that
You specify as input
Already exist in the linkable object filename vector
Have a path that matches the path of a matching linkable
object filename
A duplicate entry consists of an exact match of a path string and corresponding linkable object filename.
paths
A character array or cell array of character arrays that specifies paths to the linkable objects. If you specify a character array, the path string applies to all linkable objects.
addLinkObjects
priority (optional)
A numeric value or vector of numeric values that indicates the relative priority of each specified link object. Lower values have higher priority. The default priority is 1000.
precompiled (optional)
The logical value indicates whether each specified link object is precompiled.
true or false or a vector of logical values that
Specify
true if the link object has been prebuilt for faster
compiling and linkin g and exists in a specified location.
If precompiled is
false (the default), the Real-Time Workshop
build process creates the link object in the build directory.
This argument is ignored if
linkonly (optional)
The logical value
true or false or a vector of logical values that
linkonly equals true.
indicates whether each specified link object is to be used only for linking.
Specify
true if the Real-Tim e Workshop build process should
not build, nor generate rules in the makefile for building, the specified link object, but should include it when linking the final executable. F or example, you can u se this to incorporate link objects for which source files are not available. If true, the value of
If
linkonly is false (the default), rules for building the link
precompiled is ignored.
linkonly is
objects are added to the makefile. In this case, the value of
precompiled determines which subsection of the added
rulesisexpanded,
START_EXPAND_LIBRARIES (false).
START_PRECOMP_LIBRARIES (true)or
groups (optional)
A character array or cell array of character arrays that groups specified link objects. You can use groups to
3-19
addLinkObjects
Document the use of specific link objects
Retrieve or apply groups of link objects
You can apply
Asinglegroupnametoalinkableobject
A single group name to multiple linkable objects
Multiple group name to collections of multiple linkable objects
To ...
Apply one group name to all link objects
Apply different group names to link objects
The default value of groups is {''}.
Specify
Character array.
Cell array of character arrays such that the number of group names matches the number elements you specify for
linkobjs.
groups as a...
Description The addLinkObjects function adds specified link objects to the model’s
build information. The Real-Time Workshop software stores the link objects in a vector in relative priority order. If multiple objects have the same priority or you do not specify prioritie s, the function adds the objects to the vector based on the order in which you specify them.
In addition to the required you can specify the optional arguments
linkonly,andgroups. You can specify paths and groups as a character
array or a cell array of character arrays.
buildinfo, linkobjs,andpaths arguments,
priority, precompiled,
3-20
addLinkObjects
If You Specify paths or
groups as a...
The Fun ction...
Character array Applies the character array to
all objects it adds to the build information.
Cell array of character arrays
Pairs each character array with a specified object. Thus, the length of the cell array must match the length of the cell array you specify for
linkobjs.
Similarly, you can specify priority, p recompiled,andlinkonly as a valueorvectorofvalues.
If You Specify priority,
precompiled,orlinkonly
The Fun ction...
as a. ..
Value
Appliesthevaluetoallobjectsitadds to the build information.
Vector of values Pairs each value with a specified
object. Thus, the length of the vector must match the length of the cell array you specify for
linkobjs.
If you choose to specify an optional argument, you must specify all of the optional arguments preceding it. For example, to specify that all objects are precompiled using the specify the
priority argument that precedes precompiled.Youcould
precompiled argument, you must
pass the default priority value 1000, as shown below.
addLinkObjects(myBuildInfo, 'test1', '/proj/lib/lib1', 1000, true);
Examples Add the linkable objects libobj1 and libobj2 to build information
myModelBuildInfo and set the priorities of the objects to 26 and 10,
respectively. Since
libobj2 is assigned the low er numeric priority
3-21
addLinkObjects
Add the linkable objects libobj1 and libobj2 to build information
Add the linkable objects libobj1 and libobj2 to build information
value, and thus has the higher priority, the function orders the objects such that
myModelBuildInfo = RTW.BuildInfo; addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},... {'/proj/lib/lib1' '/proj/lib/lib2'}, [26 10]);
myModelBuildInfo. M ark both objects as link-only. Since individual
libobj2 precedes libobj1 in the vector.
priorities are not specified, the function adds the objects to the vector in the order specified.
myModelBuildInfo = RTW.BuildInfo; addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},... {'/proj/lib/lib1' '/proj/lib/lib2'}, 1000,... false, true);
myModelBuildInfo. Set the priorities of the objects to 26 and 10,
respectively. Mark both objects as precompiled, and group them under the name
MyTest.
myModelBuildInfo = RTW.BuildInfo; addLinkObjects(myModelBuildInfo, {'libobj1' 'libobj2'},... {'/proj/lib/lib1' '/proj/lib/lib2'}, [26 10],... true, false, 'MyTest');
See Also “Customizing Post Code Generation Build Processing”
3-22
addNonBuildFiles
Purpose Addnonbuild-relatedfilestomodel’s build information
Syntax addNonBuildFiles(buildinfo, filenames, paths, groups)
paths
and groups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of nonbuild-related files to be added to the build information.
Thefilenamestringscanincludewildcard characters, provided that the dot delimiter (
'*.DLL',and'*.D*'.
The function adds the filenames to the end of a vector in the order that you specify them.
The function removes duplicate nonbuild file entries that
Already exist in the nonbuild file v ector
Have a path that matches the path of a matching filename
A duplicate entry consists of an exact match of a path string and corresponding filename.
paths (optional)
A character array or cell array of character arrays that specifies paths to the nonbuild files. The function adds the paths to the end of a vector in the order that you specify them. If you s pecify a single path as a character array, the function uses that path for all files.
.) is present. Examples are '*.*',
groups (optional)
A character array or cell array of character arrays that groups specified nonbuild files. You can use groups to
3-23
addNonBuildFiles
Document the use of specific nonbuild files
Retrieve or apply groups of nonbuild files
You can apply
A single g roup name to a nonbuild file
A single group name to multiple nonbuild files
Multiple group na mes to collections of multiple nonbuild files
To ...
Apply o ne group name to all nonbuild files
Apply different group names to nonbuild files
Specify
Character array.
Cell array of chara cter arrays such that the number of group names that you specify matches the number of elements you specify for
groups as a...
filenames.
Description The addNonBu ild Files function adds specified nonbuild-related files,
such as DLL files required for a final executable, or a README file, to the model’s build information. The Real-Time Workshop software stores the nonbuild files in a vector. The function adds the filenames to the end of the vector in the order that you specify them.
In addition to the required can specify optional each optional argument as a character array or a cell array of character arrays.
paths and groups arguments. You can specify
buildinfo and filenames arguments, you
3-24
addNonBuildFiles
If You Specify an Option al
The Function...
Argument as a...
Character array Applies the character array to all nonbuild files it adds
to the build information.
Cell array of character arrays Pairs each character array with a specified nonbuild file.
Thus, t h e length of the cell array must match the length of the cell array you specify for
filenames.
If you choose to s pecify groups,butomitpaths, specify a null string (
'')forpaths.
Examples Add the nonbuild file readme.txt to build information
myModelBuildInfo and place the fil e in the group DocFiles.
myModelBuildInfo = RTW.BuildInfo; addNonBuildFiles(myModelBuildInfo, ... 'readme.txt', '/proj/docs', 'DocFiles');
Add the nonbuild files myutility1.dll and myutility2.dll to
build information
DLLFiles.
myModelBuildInfo = RTW.BuildInfo; addNonBuildFiles(myModelBuildInfo, ... {'myutility1.dll' 'myutility2.dll'}, ... '/proj/dlls', 'DLLFiles');
myModelBuildInfo and place the files in the group
Add all of the DLL files in a specified directory to build information
myModelBuildInfo and place the files in the group DLLFiles.
myModelBuildInfo = RTW.BuildInfo; addNonBuildFiles(myModelBuildInfo, ... '*.dll', '/proj/dlls', 'DLLFiles');
See Also getNonBuildFiles
“Customizing Post Code Generation Build Processing”
3-25
addSourceFiles
Purpose Add source files to model’s build information
Syntax addSourceFiles(buildinfo, filenames, paths, groups)
paths
and groups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
filenames
A character array or cell array of character arrays that specifies names of the source files to be added to the build information.
Thefilenamestringscanincludewildcard characters, provided that the dot delimiter ( and
The function adds the filenames to the end of a vector in the order that you specify them.
The function removes duplicate source file entries that
You specify as input
Already exist in the source file vector
Have a path that matches the path of a matching filename
A duplicate entry consists of an exact match of a path string and corresponding filename.
.)ispresent. Examplesare'*.*', '*.c',
'*.c*'.
3-26
paths (optional)
A character array or cell array of character arrays that specifies paths to the source files. T he function adds the paths to the end of a vector in the order that you specify them. If you specify a single path as a character array, the function uses that path for all files.
groups (optional)
A character array or cell array of character arrays that groups specified source files. You can use groups to
addSourceFiles
Document the use of specific source files
Retrieve or apply groups of source files
You can apply
A single group name to a source file
A single group name to multiple source files
Multiple group names to collections of multiple source files
To ...
Apply one group name to all source files
Apply different group names to source files
Specify
Character array.
Cell array of character arrays such that the number of group names that you specify matches the number of elements you specify for
group as a...
filenames.
Description The addSourceFiles function adds specified source files to the model’s
build information. The Real-Time Workshop software stores the source files in a vector. The function adds the filenames to the end of the vector in the order that you specify them.
In addition to the required can specify optional each optional argument as a character array or a cell array of character arrays.
If You Specify an Optional Argument as a...
Character array Applies the character array to all source files it adds to the
Cell array of character arrays
The Function...
build information.
Pairs each character array with a specified source file. Thus, th e length of the cell array must match the length of the cell array you specify for
paths and groups arguments. You can specify
buildinfo and filenames arguments, you
filenames.
3-27
addSourceFiles
If you choose to s pecify groups,butomitpaths, specify a null string (
'')forpaths.
Examples • Add the source file driver.c to build information myModelBuildInfo
and place the file in the group Drivers.
myModelBuildInfo = RTW.BuildInfo; addSourceFiles(myModelBuildInfo, 'driver.c', ... '/proj/src', 'Drivers');
Add the source files test1.c and test2.c to build information
myModelBuildInfo and place the files in the group Tests.
myModelBuildInfo = RTW.BuildInfo; addSourceFiles(myModelBuildInfo, ... {'test1.c' 'test2.c'}, ... '/proj/src', 'Tests');
Add the source files test1.c, test2.c,anddriver.c to build
information
test2.c with the string Tests and the file driver.c with the string Drivers.
myModelBuildInfo.Groupthefilestest1.c and
myModelBuildInfo = RTW.BuildInfo; addSourceFiles(myModelBuildInfo, ... {'test1.c' 'test2.c' 'driver.c'}, ... '/proj/src', ... {'Tests' 'Tests' 'Drivers'});
Add all of the .c files in a specified directory to build information
myModelBuildInfo and place the files in the group CFiles.
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, ... '*.c', '/proj/src', 'CFiles');
See Also addIncludeFiles, addIncludePaths, addSourcePaths,
getSourceFiles, updateFilePathsAndExtensions,
3-28
addSourceFiles
updateFileSeparator
“Customizing Post Code Generation Build Processing”
3-29
addSourcePaths
Purpose Add source paths to model’s build information
Syntax addSourcePaths(buildinfo, paths, groups)
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
paths
A character array or cell array of character arrays that specifies source file paths to be added to the build information. The function adds the paths to the end of a vector in the order that you specify them.
The function removes duplicate source file entries that
You specify as input
Already exist in the source path vector
Have a path that matches the path of a matching filename
A duplicate entry consists of an exact match of a path string and corresponding filename.
Note The Real-Time Workshop software does not check whether a specified path string is valid.
3-30
groups (optional)
A character array or cell array of character arrays that groups specified source paths. You can use groups to
Document the use of specific source paths
Retrieve or apply groups of source paths
addSourcePaths
You can apply
A single group name to a source path
A single group name to multiple source paths
Multiple group n ames to collections of multiple source paths
To ...
Apply one group name to all source paths
Apply different group names to source paths
Specify
Character array.
Cell array of character arrays such that the number of group names that you specify matches the number of elements you specify for
groups as a...
paths.
Description The addSourcePaths function adds specified source paths to the model’s
build information. The Real-Time Workshop software stores the source paths in a vector. The function adds the paths to the end of the vector in the order that you specify them.
In addition to the required specify an optional character array or a cell array of character arrays.
If You Specify an Optional Argument as a...
Character array Applies the character array to all
Cell array of character arrays
groups argument . You can specify groups as a
buildinfo and paths arguments, you can
The Fun ction...
source paths it adds to the build information.
Pairs each character array with a specified source path. Thus, the length of the character array o r cell array must match the length of the cell array you specify for
paths.
3-31
addSourcePaths
Note The Real-Time Workshop software does not check whether a
specified path string is valid.
Examples • Add the source path /etcproj/etc/etc_build to build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addSourcePaths(myModelBuildInfo,... '/etcproj/etc/etc_build');
Add the source paths /etcproj/etclib and
/etcproj/etc/etc_build to build information myModelBuildInfo
and place th e files in the group etc.
myModelBuildInfo = RTW.BuildInfo; addSourcePaths(myModelBuildInfo,... {'/etcproj/etclib' '/etcproj/etc/etc_build'}, 'etc');
• Add the source paths /etcproj/etclib, /etcproj/etc/etc_build,
and
/common/lib to build information myModelBuildInfo.Groupthe
paths
/etc/proj/etclib and /etcproj/etc/etc_build with the
string
etc and the path /common/lib with the string shared.
myModelBuildInfo = RTW.BuildInfo; addSourcePaths(myModelBuildInfo,... {'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
See Also addIncludeFiles, addIncludePaths, addSourceFiles,
getSourcePaths, updateFilePathsAndExtensions, updateFileSeparator
“Customizing Post Code Generation Build Processing”
3-32
addTMFTokens
Purpose Add template makefile (TMF) tokens that provide build-time
information for makefile generation
Syntax addTMFTokens(buildinfo, tokennames, tokenvalues, groups)
groups
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
tokennames
A character array or cell array of character arrays that specifies names of TMF tokens (for example, be added to the build information. The function adds the token names to the end of a vector in the order that you specify them.
If y ou specify a token name that already exists in the vector, the first instance takes precedence and its value used for replacement.
tokenvalues
A character array or cell array of character arrays that specifies TMF token values corresponding to the previously-specified TMF token names. The function adds the token values to the end of a vector in the order that you specify them.
groups (optional)
A character array or cell array of character arrays that groups specified TMF token s. You can use groups to
Document the use of specific TMF tokens
Retrieve or apply groups of TMF tokens
'|>CUSTOM_OUTNAME<|')to
You can apply
A single group name to a TMF token
A single group name to multiple TMF tokens
Multiple group n a mes to collections of multiple TMF tokens
3-33
addTMFTokens
To ...
Apply o ne group name to all TMF tokens
Apply different group names to TMF tokens
Specify
Character array.
Cell array of chara cter arrays such that the number of group names that you specify matches the number of elements you specify for
groups as a...
tokennames.
Description Call the addTMFTokens function inside a post code generation command
to provide build-time information to help customize makefile generation. The tokens specified in the appropriately in the template makefile (TMF) for the target selected for your model. For example, if your post code generation comm and calls
addTMFTokens to add a TMF token named |>CUSTOM_OUTNAME<|
that specifies an output file name for the build, the TMF m ust take appropriate action with the value of the desired result. (See “Example” on page 3-35.)
The
addTMFTokens function adds specified TMF token names and
values to the model’s build information. The Real-Time Workshop software stores the TMF tokens in a vector. The function adds the tokens to the end of the vector in the order that you specify them.
In addition to the required arguments, you can specify an optional groups argument. You can specify
groups as a character array or a cell array of character arrays.
addTMFTokens function call must be handled
|>CUSTOM_OUTNAME<| to achieve
buildinfo, tokennames,andtoken valu es
If You Specify an Option al Argument as a...
Character array Applies the character array to all TMF tokens it adds to
Cell array of character arrays Pairs each character array with a specified TMF token.
The Function...
the build information.
Thus, t h e length of the cell array must match the length of the cell array you specify for
tokennames.
3-34
addTMFTokens
Example Inside a post code generation command, add the TMF token
|>CUSTOM_OUTNAME<| and its value to build information myModelBuildInfo, and place the token in the group LINK_INFO.
myModelBuildInfo = RTW.BuildInfo; addTMFTokens(myModelBuildInfo, ...
'|>CUSTOM_OUTNAME<|', 'foo.exe', 'LINK_INFO');
In the TMF for the target selected for your model, code such as the following uses the token value to ach ieve the desired result:
CUSTOM_OUTNAME = |>CUSTOM_OUTNAME<| ... target: $(LD) -o $(CUSTOM_OUTNAME) ...
See Also “Customizing Post Code Generation Build Processing”
3-35
emlc
Purpose Generate embeddable C/C++ code from MATLAB code
Syntax emlc
-global_options files fcn_1 -options_1...fcn_n -options_n
Description emlc -global_options files fcn_1 -options_1...fcn_n
-options_n
to an embeddable C/C++ library or executable or to a MEX function. Optionally, you can specify custom
global_options applies to all functions fcn_1 through fcn_n. options_n applies only to the preceding function, fcn_n.
translates the MATLAB functions fcn_1 through fcn_n
files to include in the build.
Input Arguments
fcn_1 ... fcn_n
MATLAB functions from which to generate a MEX function, C/C++ library, or C/C++ executable code. comply with the correct syntax and semantics for Embedded MATLAB
files
Space-separated list of custom files to include in generated code. You can include the following types of files:
Cfile(
C++ file (
Header file (
Object file (
Library (
Template makefile (
global_options
Choice of compiler options. emlc resolves options from left to right. If you specify conflicting options, the rightmost option prevails.
®
, a subset of the MATLAB language.
.c)
.cpp)
.h)
.o or .o bj)
.a, .so,or.lib)
.tmf)
fcn_1 ... fcn_n must
3-36
emlc
-c
-d out_folder
Generate C/C++ code, but do not invoke the Use only with and
rtw:lib targets.
make command.
rtw, rtw:exe,
Store generated files in the absolute or relative path specified by
out_folder.
If the folder specified by
out_folder does not exist,
emlc creates it for you.
If you do not specify the folder location,
emlc generates files
in the default folder:
emcprj/target/fcn1.
target
can be:
mexfcn for MEX functions
rtwexe for embeddable
C/C++ executables
rtwlib for embeddable
C/C++ libraries
fcn1 is the name of the first
MATLAB function specified at the command line.
The function does not support the following characters in folder names: asterisk (*), question-mark (?), dollar ($), and pound (#).
3-37
emlc
-F fimath_obj
-g
-global global_values
Specify fimath_obj as the default
fimath object for
all fixed-point inputs to the primary function.
You can define
fimath_obj
using the fimath function.
If not specified, the MATLAB default
emlc uses
fimath
value.
Compiles MEX functions in debug mode, with optimization turned off. Us e only for
mex
targets. If not specified, emlc generates MEX functions in optimized mode.
Specify initial values for global variables in Embedded MATLAB files. Use the values in cell array
global_values
to init ialize gl obal va ria bles in the function you compile. The cell array should provide the name and initial value of each global variable. You must initialize global variables before compiling with
emlc.
Ifyoudonotprovideinitial values for global variables using the
emlc checks for the variable
-global option,
in the MATLAB global workspace. If you do not supply an initial value,
emlc
generates an error.
3-38
-I include_path
-launchreport
-N numerictype_obj
The Embedded MATLAB subset and MATLAB each have their o wn copies of global data. To ensure consistency, you must synchronize their global data whenever the two interact. If you do not synchronize the data, their global variables might differ.
Add include_path to the beginning of the Embedded MATLAB path.
emlc searches the Embedded
MATLAB path first when converting MATLAB code to C/C++ code.
Generate and open a compilation report. If you do not specify this option,
emlc
generates a report only error or warning messages occur or you specify the
-report
option.
Specify numerictype_obj as the default numerictype object for all fixed-point inputs to the MATLAB function.
emlc
You can define
numerictype_obj using
the
numerictype function.
If you do not specify the object, you must define fixed-point inputs using the
-eg option.
3-39
emlc
-o output_file_name
-O optimization_option
Generate the ME X function, C/C++ library, or C/C++ executable file with the base name
output_file_name plus
an extension:
.a or .lib for C/C++
libraries
.exe or no extension for
C/C++ executables
Platform-dependent
extension for generated MEX functions
output_file_name can be
afilenameorincludean existing path.
If you do not specify an output file name, the base name is
fcn_1,wherefcn_1 is the
name of the first MA TLAB function specified at the command line.
Optimize generated code, based on the value of
optimization_option:
3-40
enable:inline —Enable
function inlining
disable:inline — Disable
function inlining
enable:blas — Use BLAS
library, if available
disable:blas —Donot
use BLAS library
emlc
-report
-s config_obj
If not specified,
emlc uses
inlining and BLAS library functions for optimization.
Generate a compilation report. If you do not specify this option,
emlc generates a
report only if error or warning messages occur or you specify the
-launchreport option.
Specify code generation parameters, based on
config_obj, defined as
one of these objects:
emlcoder.HardwareImplementation
— Parameters of the target hardware for embeddable C/C++ code. Use with
rtw:exe targets. If not
specified,
rtw, rtw:lib,or
emlc generates
code compatible with the MATLAB host computer.
emlcoder.MEXConfig
Parameters for M EX code generation. Use with target.
emlcoder.RTWConfig
Parameters for embeddable C/C++ code generation. Use
mex
3-41
emlc
with rtw, rtw:lib,and
rtw:exe targets.
-T target_option
-v
-?
Define
config_obj as a
MATLAB variable. For example:
rtw_config = emlcoder.RTWConfig
Specify target for generated code, based on value of
target_option:
mex —GenerateaMEX
function (default)
rtw or rtw:lib —Generate
embeddable C/C++ library file
rtw:exe —Generate
embeddable C/C++ code executable file. You must provide a
main function to
include in the build.
If not specified,
emlc generates
a MEX function.
Enable verbose mode to show compilation steps. Use with
rtw, rtw:lib,andrtw:exe
targets.
Display help for emlc command.
3-42
options_1 .. . options_n
emlc
-eg example_inputs
Define the size, class, and complexity of all MATLAB function inputs. Use the values in
example_inputs
to define these properties.
example_inputs must be
a cell array that specifies thesamenumberandorder of inputs as the MATLAB function.
Specify the example inputs immediately after the function to which they apply.
Examples Generate a MEX function from an Embedded MATLAB compliant
function:
1 Write a MATLAB function emcrand that generates a random scalar
value drawn from the standard uniform distribution on the open interval (0,1):
function r = emcrand() %#eml % The directive %#eml decl are s the function % to be Embedded MATLAB compliant r = rand();
2 Generate and run the MEX function:
emlc emcrand emcrand
Generate C executable files from an Embedded MATLAB compliant function. Specify the main C function as a configuration parameter:
3-43
emlc
1 Write a MATLAB function emcrand that generates a random scalar
value drawn from the standard uniform distribution on the open interval (0,1):
function r = emcrand() %#eml r = rand();
2 Write a main C function c:\myfiles\main.c that calls emcrand:
/* ** main.c */ #include <stdio.h> #include <stdlib.h>
int main() {
emcrand_initialize();
printf("emcrand=%g\n", emcrand());
3-44
emcrand_terminate();
return 0;
}
3 ConfigureyourcodegenerationparameterstoincludethemainC
function, then generate the C executable:
rtwcfg = emlcoder.RTWConfig rtwcfg.CustomSource = 'main.c' rtwcfg.CustomInclude = 'c:\myfiles' emlc -T rtw:exe -s rtwcfg emcrand
generates C executables and supporting files in the default
emlc
folder
emcprj/rtwexe/emcrand.
emlc
This example shows how to specify a main function as a parameter in the configuration object specify the file containing You can use a source, object, or library file.
Generate C library files in a custom folder from an Embedded MATLAB compliant function with inputs of different classes and sizes. The first input is a 1-by-4 vector of unsigned 16-bit integers; the second input is a double-precision scalar:
1 Write a MATLAB function emcadd that returns the sum of tw o values:
function y = emcadd(u,v) %#eml y=u+v;
2 Generate the C library files in a custom folder emcaddlib:
emlc -T rtw:lib -d emcadd lib emcadd -eg {zeros(1,4,'uint16'),0}
emlcoder.RTWConfig. Alternatively, you can
main() separately on the command line.
Generate C library files from an Embedded MATLAB compliant function that takes a fixed-point input:
1 Write a MATLAB language function emcsqrtfi that computes the
square root of a fixed-point input:
function y = emcsqrtfi(x) %#eml y = sqrt(x);
2 Define nume rictype and fimath properties for the fixed-point input
x and generate C library code for emcsqrtfi:
T = numerictype('WordLength',32, ...
'FractionLength',23, ... 'Signed',true)
F = fimath('SumMode','SpecifyPrecision', ...
3-45
emlc
'SumWordLength',32, ... 'SumFractionLength',23, ... 'ProductMode','SpecifyPrecision', ... 'ProductWordLength',32, ...
'ProductFractionLength',23) % Define a fixed-point variable with these % numerictype and fimath properties myfiprops = {fi(4.0,T,F)} emlc -T rtw:lib emcsqrtfi -eg myfipro ps
generates C library and supporting files in the default folder
emlc emcprj/rtwlib/emcsqrtfi.
Specify global data at the command line.
1 Write a MATLAB function use_globals that takes one input
parameter
u and uses two global variables AR and B:
3-46
function y = use_globals( u) %#eml % Turn off inlining to make % generated code easier to read eml.inline('never'); global AR; global B; AR(1) = u(1) + B(1); y=AR*2;
2 Generate a MEX function named use_globalsx in the current folder.
Specify the properties of the global variables at the command line using the
emlc -global {'AR', ones(4), 'B', [1 2 3 4]}
-global option:
... -o use_globalsx use_globals
emlc
Alternatively, you can initialize the global data in the MATLAB workspace. At the M ATLA B prompt, enter:
global AR B; AR = ones(4); B=[1 2 3];
Compile the function to generate a MEX file named use_globalsx.
emlmex -o use_globalsx use_globals
Alternatives You can use a GUI to modify parameters for code generation with emlc:
To modify hardware implementation parameters using a dialog box:
hw_config = emlcoder.HardwareImplementation open hw_config
To modify C/C++ code generation parameters using a dialog box:
rtw_config = emlcoder.RTWConfig open rtw_config
To modify MEX code generation parameters using a dialog box:
mex_config = emlcoder.MEXConfig open mex_config
See Also fimath | numerictype | emlmex | mex | fi
Tutorials • “Tutorial: Generating C Code from MATLAB Code”
• Generating Code for Embedded MATLAB
How To • “Making MATLAB Code Compliant with the Embedded MATLAB
Subset”
• “Converting MATLAB Code to C/C++ Code”
• “Specifying Properties of Primary Function Inputs”
3-47
emlc
• “Configuring Your Environment for Code Generation”
• “Specifying a Language for Embeddable Code Generation”
• “File Paths and Naming Conventions”
• “Generating C/C++ Code from MATLAB Code That Uses Global Data”
• “Synchronizing Global Data with MATLAB”
• “Compiling More Than One Entry-Point MATLAB Function”
3-48
findIncludeFiles
Purpose Find and add include (header) files to build information object
Syntax findIncludeFiles(buildinfo, extPatterns)
extPatterns
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
extPatterns (optional)
A cell array of character arrays that specify patterns of file name extensions for which the function is to search. Each pattern
Must start with
Can include any combination of alphanumeric and underscore
(_) characters
The default pattern is
Examples of valid patterns include
*.h *.hpp *.x*
*.
*.h.
Description The findIncludeFiles function
Searches for include files, based on specifie d file name extension
patterns, in all source and include paths recorded in a model’s build information object
Adds the files found, along with their full pa th s, to the build
information object
Deletes duplicate entries
3-49
findIncludeFiles
Examples Find all include files with filename extension .h that are in build
information object files found to the object.
myModelBuildInfo = RTW.BuildInfo; addSourcePaths(myModelBuildInfo, {fullfile(pwd,... 'mycustomheaders')}, 'myheaders'); findIncludeFiles(myModelBuildInfo); headerfiles = getIncludeFiles(myModelBuildInfo, true, false); headerfiles headerfiles =
'W:\work\mycustomheaders\myheader.h'
See Also addIncludeFiles, getIncludeFiles, packNGo
“Customizing Post Code Generation Build Processing”
myModelBuildInfo, and add the full paths for any
3-50
getCompileFlags
Purpose Compiler options from model’s build information
Syntax options = getCompileFlags(buildinfo, includeGroups,
excludeGroups)
includeGroups
and excludeGroups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of compiler flags you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of compiler flags you do not want the function to return.
Returns Compiler options stored in the model’s build information.
Description The getCompileFlags function returns compi le r options stored in
the model’s build information. Using optional
excludeGroups arguments, you can selectively include or exclude
groups of options the function returns.
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
includeGroups and
Examples Get all compiler options stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
'OPTS'); compflags=getCompileFlags(myModelBuildInfo); compflags
compflags =
3-51
getCompileFlags
Get the compiler options stored with the group name Debug in build
Get all compiler options stored in build information
'-Zi -Wall' '-O3'
information
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'}); compflags=getCompileFlags(myModelBuildInfo, 'Debug'); compflags
compflags =
myModelBuildInfo, except those with the group name Debug.
myModelBuildInfo.
'-Zi -Wall'
myModelBuildInfo = RTW.BuildInfo; addCompileFlags(myModelBuildInfo, {'-Zi -Wall' '-O3'}, ...
{'Debug' 'MemOpt'}); compflags=getCompileFlags(myModelBuildInfo, '', 'Debug'); compflags
compflags =
'-O3'
See Also addCompileFlags, getDefines, getLinkFlags
“Customizing Post Code Generation Build Processing”
3-52
getDefines
Purpose Preprocessor macro definitions from model’s build information
Syntax [macrodefs, identifiers, values] = getDefines(buildinfo,
includeGroups, excludeGroups)
includeGroups
and excludeGroups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of macro definitions you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of macro definitions you do not want the function to return.
Returns Preprocessor macro definitions stored in the model’s build information.
The function returns the macro definitions in three vectors.
Vector
macrodefs
identifiers
values
Description
Complete macro definitions with -D prefix
Names of the macros
Values assigned to the macros (anything specified to the right of the first equals sign) ; the default is an empty string (
'')
3-53
getDefines
Description The getDefines function returns preprocessor macro definitions
stored in the model’s build information. When the function returns a definition, it automatically
Prepends a
-D to the definition if the -D was not specified when the
definition was added to the build information
Changes a lowercase
-d to -D
Using optional includeGroups and excludeGroups arguments, you can selectively include or exclude groups of definitions the function is to return.
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
Examples Get all preprocessor macro definitions stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addDefines(myModelBuildInfo, ...
{'PROTO=first' '-DDEBUG' 'test' '-dPRODUCTION'}, 'OPTS'); [defs names values]=getDefines(myModelBuildInfo); defs
defs =
'-DPROTO=first' '-DDEBUG' '-Dtes t' '-DPRODUCTION'
names
3-54
names =
'PROTO' 'DEBUG' 'test' 'PRODUCTION'
getDefines
values
values =
'first' '' '' ''
Get the preprocessor macro definitions stored with the group name
Debug in 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 all preprocessor macro definitions stored in build information
myModelBuildInfo, except those 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'
3-55
getDefines
See Also addDefines, getCompileFlags, getLinkFlags
“Customizing Post Code Generation Build Processing”
3-56
getFullFileList
Purpose All files from model’s build information
Syntax [fPathNames, names] = getFullFileList(buildinfo, fcase)
fcase
is optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
fcase (optional)
The string is omitted, the function returns all files from the model’s build information.
If You Specify...
'source'
'include'
'nonbuild'
'source', 'include',or'nonbuild'.Iftheargument
The Function ...
Returns source filesfromthemodel’s build information.
Returns include filesfromthemodel’s build information.
Returns nonbuild files from the model’s build information.
Returns Fully-qualified file paths and file names for files stored in the model’s
build information.
Description The getFullFileList function returns the fully-qualified paths
and names of all files, or files of a selected type (source, include, or nonbuild), stored in the mod el’s build information.
The
packNGo function calls getFullFileList to return a list of all files
in the model’s build information before processing files for packaging.
Examples List all the files stored in build information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; [fPathNames, names] = getF ullFileList(myModelBuildInfo);
3-57
getFullFileList
See Also “Customizing Post Code Generation Build Processing”
3-58
getIncludeFiles
Purpose Include files from model’s build information
Syntax files = getIncludeFiles(buildinfo, concatenatePaths,
replaceMatlabroot, includeGroups, excludeGroups)
includeGroups
Arguments buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
If You Specify...
true
false
replaceMatlabroot
The logical value true or false.
If You Specify...
true
false
and excludeGroups are optional.
The Function ...
Concatenates and returns each filename with its corresponding path.
Returns only filenames.
The Function ...
Replaces the token $(MATLAB_ROOT) withtheabsolutepathstringforyour MATLAB installation directory.
Does not replace the token
$(MATLAB_ROOT).
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of include files you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of include files you do not want the function to return.
3-59
getIncludeFiles
Returns Names of include files stored in the model’s build information. The
names include any files you added using the and, if you called the
packNGo function, any files packNGo found and
added while packaging model code.
Description The getIncludeFiles function returns the names of include files
stored in the model’s build information. Use the
replaceMatlabroot arguments to control whether the function includes
paths and your MATLAB roo t definition in the output it returns. Using optional can selectively include or exclude groups of include files the function returns.
includeGroups and excludeGroups arguments, you
addIncludeFiles function
concatenatePaths and
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
Examples Get all include paths and filenames stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addIncludeFiles(myModelBuildInfo, {'etc.h' 'etc_private.h'...
'mytypes.h'}, {'/etc/proj/etclib' '/etcproj/etc/etc_build'...
'/common/lib'}, {'etc' 'etc' 'shared'});
incfiles=getIncludeFiles(myModelBuildInfo, true, false);
incfiles
incfiles =
[1x22 char] [1x36 char] [1x21 char]
3-60
getIncludeFiles
Get the names of include files in group et c that are stored in build
information
myModelBuildInfo = RTW.BuildInfo; addIncludeFiles(myModelBuildInfo, {'etc.h' 'etc_private.h'... 'mytypes.h'}, {'/etc/proj/etclib' '/etcproj/etc/etc_build'... '/common/lib'}, {'etc' 'etc' 'shared'}); incfiles=getIncludeFiles(myModelBuildInfo, false, false,... 'etc'); incfiles
incfiles =
See Also addIncludeFiles, findIncludeFiles, getIncludePaths,
getSourceFiles, getSourcePaths
“Customizing Post Code Generation Build Processing”
myModelBuildInfo.
'etc.h' 'etc_private.h'
3-61
getIncludePaths
Purpose Include paths from model’s build information
Syntax files=getIncludePaths(buildinfo, replaceMatlabroot,
includeGroups, excludeGroups)
includeGroups
and excludeGroups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
replaceMatlabroot
The logical value true or false.
If You Specify...
true
false
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of include paths you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of include paths you do not want the function to return.
The Function ...
Replaces the token $(MATLAB_ROOT) withtheabsolutepathstringforyour MATLAB installation dire ctory.
Does not replace the token
$(MATLAB_ROOT).
Returns Paths of include files stored in the model’s build information.
Description The getIncludePaths function returns the names of include file paths
stored in the model’s build information. Use the argument to control w hether the function includes your MATLAB root definition in the output it returns. Using optional and ex clud eGroups arguments, you can selectively include or exclude groups of include file paths the function returns.
3-62
replaceMatlabroot
includeGroups
getIncludePaths
IfyouchoosetospecifyexcludeGroups and omit includeGroups, specify a null string (
Examples • Get all include paths stored in build information m yMod elBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addIncludePaths(myModelBuildInfo, {'/etc/proj/etclib'... '/etcproj/etc/etc_build' '/common/lib'},... {'etc' 'etc' 'shared'}); incpaths=getIncludePaths(myModelBuildInfo, false); incpaths
incpaths =
'\etc\proj\etclib' [1x22 char] '\common\lib'
Get the paths in group shared that are stored in build information
myModelBuildInfo.
'')forincludeGroups.
myModelBuildInfo = RTW.BuildInfo; addIncludePaths(myModelBuildInfo, {'/etc/proj/etclib'... '/etcproj/etc/etc_build' '/common/lib'},... {'etc' 'etc' 'shared'}); incpaths=getIncludePaths(myModelBuildInfo, false, 'shared'); incpaths
incpaths =
'\common\lib''
See Also addIncludePaths, getIncludeFiles, getSourceFiles,
getSourcePaths
“Customizing Post Code Generation Build Processing”
3-63
getLinkFlags
Purpose Link options from model’s build information
Syntax options=getLinkFlags(buildinfo, includeGroups,
excludeGroups)
includeGroups
and excludeGroups are optional.
Arguments buildinfo
Build information returned by RTW.BuildInfo.
includeGroups (optional)
A character array or cell array that specifies groups of linker flags you want the function to return.
excludeGroups (optional)
A character array or cell array that specifies groups of linker flags you do not want the function to return. To exclude groups and not include specific groups, specify an empty cell array ( for
includeGroups.
'')
Returns Linker options stored in the model’s build information.
Description The getLinkFlags function returns linker options stored in the model’s
build information. Using optional arguments, you can selectively include or exclude groups of options the function returns.
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
includeGroups and excludeGroups
3-64
getLinkFlags
Examples Get all linker options stored in buil d information myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, 'OPTS'); linkflags=getLinkFlags(myModelBuildInfo); linkflags
linkflags =
'-MD -Gy' '-T'
Get the linker options stored with the group name Debug in build
information
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, ...
{'Debug' 'MemOpt'}); linkflags=getLinkFlags(myModelBuildInfo, {'Debug'}); linkflags
myModelBuildInfo.
linkflags =
'-MD -Gy'
Get all compiler options stored in build information
myModelBuildInfo, except those with the group name Debug.
myModelBuildInfo = RTW.BuildInfo; addLinkFlags(myModelBuildInfo, {'-MD -Gy' '-T'}, ...
{'Debug' 'MemOpt'}); linkflags=getLinkFlags(myModelBuildInfo, '', {'Debug'}); linkflags
linkflags =
'-T'
3-65
getLinkFlags
See Also addLinkFlags, getCompileFlags, getDefines
“Customizing Post Code Generation Build Processing”
3-66
getNonBuildFiles
Purpose Nonbuild-related files from model’s build information
Syntax files=getNonBuildFiles(buildinfo, concatenatePaths,
replaceMatlabroot, includeGroups, excludeGroups)
includeGroups
Arguments buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
If You Specify...
true
false
replaceMatlabroot
The logical value true or false.
If You Specify...
true
false
and excludeGroups are optional.
The Function ...
Concatenates and returns each filename with its corresponding path.
Returns only filenames.
The Function ...
Replaces the token $(MATLAB_ROOT) withtheabsolutepathstringforyour MATLAB installation directory.
Does not replace the token
$(MATLAB_ROOT).
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of nonbuild files you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of nonbuild files you do not want the function to return.
3-67
getNonBuildFiles
Returns Names of nonbuild files stored in the model’s build information.
Description The getNonBuildFiles function returns the nam es of nonbuild-related
files, such as DLL files required for a final executable, or a README file, stored in the m od el ’s build information. Use th e and replaceMatlabroot arguments to control whether the function includes paths and your MATLAB root definition in the output it returns. Using optional
includeGroups and excludeG roups arguments,
you can selectively include or excl ude groups of nonbuild files the function returns.
concatenatePaths
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
Examples Get all nonbuild filenames stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo;
addNonBuildFiles(myModelBuildInfo, {'readme.txt' 'myutility1.dll'...
'myutility2.dll'});
nonbuildfiles=getNonBuildFiles(myModelBuildInfo, false, false);
nonbuildfiles
nonbuildfiles =
'readme.txt' 'myutility1.dll' 'myutility2.dll'
See Also addNonBuildFiles
“Customizing Post Code Generation Build Processing”
3-68
getSourceFiles
Purpose Source files from model’s build information
Syntax srcfiles=getSourceFiles(buildinfo, concatenatePaths,
replaceMatlabroot, includeGroups, excludeGroups)
includeGroups
Arguments buildinfo
Build information returned by RTW.BuildInfo.
concatenatePaths
The logical value true or false.
If You Specify...
true
false
replaceMatlabroot
The logical value true or false.
If You Specify...
true
false
and excludeGroups are optional.
The Function ...
Concatenates and returns each filename with its corresponding path.
Returns only filenames.
The Function ...
Replaces the token $(MATLAB_ROOT) withtheabsolutepathstringforyour MATLAB installation directory.
Does not replace the token
$(MATLAB_ROOT).
includeGroups (optional)
A character array or cell array of character arrays that specifies groups of source files you want the function to return.
excludeGroups (optional)
A character array or cell array of character arrays that specifies groups of source files you do not want the function to return.
3-69
getSourceFiles
Returns Names of source files stored in the model’s build information.
Description The getSourceFiles function returns the names of source files stored
in the model’s build information. Use the
replaceMatlabroot arguments to control whether the function includes
paths and your MATLAB root definition in the output it returns. Using optional selectively include or exclude groups of source files the function returns.
includeGroups and excludeGroups arguments, you can
concatenatePaths and
Ifyouchoosetospecify specify a null string (
excludeGroups and omit incl udeGroups,
'')forincludeGroups.
Examples Get all source paths and filenames stored in build information
myModelBuildInfo.
myModelBuildInfo = RTW.BuildInfo; addSourceFiles(myModelBuildInfo,... {'test1.c' 'test2.c' 'driver.c'}, '',... {'Tests' 'Tests' 'Drivers'}); srcfiles=getSourceFiles(myModelBuildInfo, false, false); srcfiles
srcfiles =
'test1.c' 'test2.c' 'driver.c'
3-70
Loading...