codebuild - Compile and link generated code - MATLAB (original) (raw)
Compile and link generated code
Since R2020b
Syntax
Description
[buildResults](#mw%5F0affc2b7-4b2a-43e5-b259-35deebdf9bcc) = codebuild([buildFolder](#mw%5F10275a3c-e807-4d92-92f4-1372e4ba59f6))
loads data from the buildInfo.mat
file inbuildFolder
, generates a makefile inbuildFolder
, and uses the specified toolchain or template makefile to compile source code that is registered in the RTW.BuildInfo
object. If the object is at the top of a hierarchy, the function performs the process for each object in the hierarchy.
The function saves compilation artifacts, including object code files, inbuildFolder
.
The function returns an object that contains the display output. To view the output, rundisp(`buildResults`)
.
codebuild([buildFolder](#mw%5F10275a3c-e807-4d92-92f4-1372e4ba59f6), [Name,Value](#namevaluepairarguments))
specifies additional options using one or more name-value pairs.
codebuild([buildInfo](#mw%5Fb4d4cf85-bff7-457f-8648-ff09da6099ab), [Name,Value](#namevaluepairarguments))
compiles the code specified in buildInfo
using one or more name-value pairs.
Examples
Input Arguments
Path to the build folder, which typically contains the generated source code. The folder must contain the buildInfo.mat
file.
Example: codebuild(_`pathToCodeFolder`_, 'BuildMethod',_` myToolchain`_)
RTW.BuildInfo
object that contains information for compiling and linking generated code.
Example: codebuild(_`myBuildInfo`_, 'BuildMethod','CMake')
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose Name
in quotes.
Example: codebuild(_`pathToCodeFolder`_, 'BuildMethod',_` myToolchain`_)
Use one of these build methods:
- Toolchain — Specify the name of the toolchain, for example,
'GNU gcc/g++ | gmake (64-bit Linux)'
. - Template makefile — Specify the path to the template makefile.
- CMake — Specify
'cmake'
, which generatesCMakeLists.txt
configuration files for the CMake build system. The argument value is case-insensitive. For example, you can also specify'Cmake'
or'CMake'
.
Example: codebuild(_`pathToCodeFolder`_, 'BuildMethod', 'CMake')
Specify the type of build output:
'STANDALONE_EXECUTABLE'
–– Generates a standalone, executable file.'MODEL_REFERENCE_CODER'
–– Generates a static library.'MEX_FILE'
–– Generates a MEX file. Use this value only for building a simulation target, for example, model reference simulation target (ModelReferenceSimTarget
) and accelerator mode.'SHARED_LIBRARY'
–– Generates a dynamic library.'STATIC_LIBRARY'
–– Generates a static library.
Example: codebuild(_`pathToCodeFolder`_, 'BuildVariant', 'SHARED_LIBRARY')
Output Arguments
Capture display output from build process. To view the display output, in the Command Window, run disp(buildResults)
.
Version History
Introduced in R2020b