Code Compilation Customization - MATLAB & Simulink (original) (raw)
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 aToolchainInfo
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
target | Manage target hardware and build tool information |
---|
Classes
target.BuildTool | Describe build tool (Since R2023a) |
---|---|
target.BuildToolType | Describe build tool type (Since R2023a) |
target.CMake | Specify CMake installation for building generated code (Since R2022b) |
target.CMakeBuildType | Describe CMake build type or build configuration (Since R2022b) |
target.CMakeBuilder | Configure how CMake builds generated code (Since R2022b) |
target.CMakeCacheEntry | Configure a CMake cache entry (Since R2022b) |
target.Directive | Describe command-line flag for tool (Since R2023a) |
target.EnvironmentConfiguration | Configure system environment for toolchain (Since R2022b) |
target.FileType | Define identifier for file type (Since R2023a) |
target.HardwareComponentSupport | Describe support for a hardware component (Since R2022b) |
target.MakefileBuilder | Specify that toolchain is makefile-based (Since R2023a) |
target.MakeToolType | Describe syntax for makefile type (Since R2023a) |
target.PairedDirective | Describe pair of command-line flags (Since R2023a) |
target.RepeatingDirective | Describe repeated command-line flag for tools (Since R2023a) |
target.Toolchain | Capture high-level information about toolchain (Since R2022b) |
Objects
RTW.BuildInfo | Provide information for compiling and linking generated code |
---|
Functions
addCompileFlags | Add compiler options to build information |
---|---|
addDefines | Add preprocessor macro definitions to build information |
addIncludeFiles | Add include files to build information |
addIncludePaths | Add include paths to build information |
addLinkFlags | Add link options to build information |
addLinkObjects | Add link objects to build information |
addNonBuildFiles | Add nonbuild-related files to build information |
addPreincludeFiles | Add preinclude files to build information (Since R2024a) |
addSourceFiles | Add source files to build information |
addSourcePaths | Add source paths to build information |
addTMFTokens | Add template makefile (TMF) tokens to build information |
addUndefines | Add undefine preprocessor directives to build information (Since R2024a) |
removeIncludePaths | Remove include paths from build information (Since R2023b) |
removeSourceFiles | Remove source files from build information object (Since R2021b) |
removeUndefines | Remove undefine preprocessor macros from build information (Since R2024a) |
findBuildArg | Find a specific build argument in build information |
---|---|
findIncludeFiles | Find and add include (header) files to build information |
getBuildArgs | Get build arguments from build information |
---|---|
getCompileFlags | Get compiler options from build information |
getDefines | Get preprocessor macro definitions from build information |
getFullFileList | Get list of files from build information |
getIncludeFiles | Get include files from build information |
getIncludePaths | Get include paths from build information |
getLinkFlags | Get link options from build information |
getNonBuildFiles | Get nonbuild-related files from build information |
getPreincludeFiles | Get preinclude files from build information (Since R2024a) |
getSourceFiles | Get source files from build information |
getSourcePaths | Get source paths from build information |
getUndefines | From build information, get preprocessor macros to undefine (Since R2024a) |
setTargetProvidesMain | Disable inclusion of code generator provided (generated or static)main.c source file during build |
---|
updateFilePathsAndExtensions | Update files in build information with missing paths and file extensions |
---|---|
updateFileSeparator | Update file separator character for file lists in build information |
target.connection.open | Create a connection between MATLAB development computer and remote build computer (Since R2024a) |
---|---|
target.connection.show | Show connection between MATLAB development computer and remote build computer (Since R2024a) |
target.connection.close | Close connection between MATLAB development computer and remote build computer (Since R2024a) |
codebuild | Compile and link generated code (Since R2020b) |
---|
Topics
Compiler
- Select and Configure C or C++ Compiler
Consider programming language compliance for generated code and select a compiler for the build process. - Control Compiler Optimizations
Control compiler optimizations for your makefile at the Simulink® UI level. - Troubleshoot Compiler Issues
Identify and fix issues that prevent compiler operation in the build process. - Control Build Process Compiling and Linking
Select whether build process ends after code generation and (for template makefile approach) select template makefile options.
Library Names and Locations
- Control Library Location and Naming During Build
Choose the location for precompiled, non-precompiled, and model reference libraries and select the file extension that the build process applies to libraries.
CMake and Makefile-Based Toolchains Using Target Framework
- Create Custom CMake Toolchain Definition
CMake is a third-party, open-source tool for build process management. - Build Code in Windows Subsystem for Linux
Use CMake in WSL environment to build generated code. - Define Custom Makefile-Based Toolchains Using Target Framework
Define and register custom makefile-based toolchains. - Build Generated Code Remotely
Create a connection and build generated code on a remote computer. - Build and Execute Generated Code Remotely
Create an SSH connection, use it to build generated code on a remote computer, and then reuse it to execute the generated code remotely.
Makefile-Based Toolchains Using ToolchainInfo
- Custom Toolchain Registration
Register third-party software build tools for creating executables and libraries. - Register Custom Toolchain and Build Executable
Register and use a toolchain to build an executable program. - Troubleshooting Custom Toolchain Validation
Troubleshoot validation errors.
Template Makefile Approach
- Template Makefiles and Make Options
Template makefiles that are built into the code generator. - Customize Template Makefiles
Develop a custom template makefile to control the build process.
Advanced Techniques
- Customize Post-Code-Generation Build Processing
Modify the build process with a post-code-generation command and (optionally) use build information objects to augment this process. - Customize Build Process with STF_make_rtw_hook File
Modify the build process with the build process hook mechanism in a custom_`STF`__make_rtw_hook.m
hook file. - Customize Build Process with sl_customization.m
Modify the build process with the build process hook mechanism in a customsl_customization.m
hook file. - Use makecfg to Customize Generated Makefiles for S-Functions
Configure makefile generation for the S-function build process.