Main Content

Code Compilation Customization

Customize compilation stage of build process

If you install supported build tools, you can configure a build process that produces executable code after code generation. You can customize the compilation stage of the build process.

Using the Target Framework:

  • Create custom CMake toolchain definitions.

  • Define and register custom makefile-based toolchains.

You can also register and use a custom makefile-based toolchain by using a ToolchainInfo object.

For the template makefile approach, customize a shipped template makefile.

For the CMake, ToolchainInfo, and template makefile approaches:

  • Create and run a post-code-generation command.

  • Create and apply hook methods at specific points of the build process.

  • Configure compilation of S-function code.

Packages

targetManage target hardware and build tool information (Since R2019a)

Classes

expand all

target.BuildToolDescribe build tool (Since R2023a)
target.BuildToolTypeDescribe build tool type (Since R2023a)
target.CMakeSpecify CMake installation for building generated code (Since R2022b)
target.CMakeBuildTypeDescribe CMake build type or build configuration (Since R2022b)
target.CMakeBuilder Configure how CMake builds generated code (Since R2022b)
target.CMakeCacheEntryConfigure a CMake cache entry (Since R2022b)
target.DirectiveDescribe command-line flag for tool (Since R2023a)
target.EnvironmentConfigurationConfigure system environment for toolchain (Since R2022b)
target.FileTypeDefine identifier for file type (Since R2023a)
target.HardwareComponentSupportDescribe support for a hardware component (Since R2022b)
target.MakefileBuilderSpecify that toolchain is makefile-based (Since R2023a)
target.MakeToolTypeDescribe syntax for makefile type (Since R2023a)
target.PairedDirectiveDescribe pair of command-line flags (Since R2023a)
target.RepeatingDirectiveDescribe repeated command-line flag for tools (Since R2023a)
target.ToolchainCapture high-level information about toolchain (Since R2022b)

Objects

expand all

RTW.BuildInfoProvide information for compiling and linking generated code

Functions

expand all

addCompileFlagsAdd compiler options to build information
addDefinesAdd preprocessor macro definitions to build information
addIncludeFilesAdd include files to build information
addIncludePathsAdd include paths to build information
addLinkFlagsAdd link options to build information
addLinkObjectsAdd link objects to build information
addNonBuildFilesAdd nonbuild-related files to build information
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addTMFTokensAdd template makefile (TMF) tokens to build information
removeIncludePathsRemove include paths from build information (Since R2023b)
removeSourceFilesRemove source files from build information object (Since R2021b)
findBuildArgFind a specific build argument in build information
findIncludeFilesFind and add include (header) files to build information
getBuildArgsGet build arguments from build information
getCompileFlagsGet compiler options from build information
getDefinesGet preprocessor macro definitions from build information
getFullFileListGet list of files from build information
getIncludeFilesGet include files from build information
getIncludePathsGet include paths from build information
getLinkFlagsGet link options from build information
getNonBuildFilesGet nonbuild-related files from build information
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
setTargetProvidesMainDisable inclusion of code generator provided (generated or static) main.c source file during build
updateFilePathsAndExtensionsUpdate files in build information with missing paths and file extensions
updateFileSeparatorUpdate file separator character for file lists in build information
codebuildCompile and link generated code (Since R2020b)

Topics

Compiler

Library Names and Locations

CMake and Makefile-Based Toolchains Using Target Framework

Makefile-Based Toolchains Using ToolchainInfo

Template Makefile Approach

Advanced Techniques