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.

Namespaces

targetManage target hardware and build tool information

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
addPreincludeFilesAdd preinclude files to build information (Since R2024a)
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addTMFTokensAdd template makefile (TMF) tokens to build information
addUndefinesAdd undefine preprocessor directives to build information (Since R2024a)
removeIncludePathsRemove include paths from build information (Since R2023b)
removeSourceFilesRemove source files from build information object (Since R2021b)
removeUndefinesRemove undefine preprocessor macros from build information (Since R2024a)
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
getPreincludeFilesGet preinclude files from build information (Since R2024a)
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
getUndefinesFrom build information, get preprocessor macros to undefine (Since R2024a)
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
target.connection.openCreate a connection between MATLAB development computer and remote build computer (Since R2024a)
target.connection.showShow connection between MATLAB development computer and remote build computer (Since R2024a)
target.connection.closeClose connection between MATLAB development computer and remote build computer (Since R2024a)
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