主要内容

配置生成代码的编译过程

自定义生成源代码的编译和链接

对于某些应用,您可能要控制在 C/C++ 源代码生成之后、编译之前发生的编译过程的各个方面。要从 MATLAB® 代码内指定其他编译文件和标志,请使用 coder.updateBuildInfo 函数。或者,在工作区中创建一个 RTW.BuildInfo 对象,并使用关联的对象函数来指定编译选项。当您处理外部代码集成或有多个使用相同编译信息的函数时,请使用 coder.ExternalDependency 类自定义编译过程。

使用 target 命名空间中的类来管理目标硬件和编译工具信息。例如,为代码生成注册新目标硬件,为外部模式和处理器在环 (PIL) 仿真设置目标连接,或为在开发计算机上编译生成的代码创建自定义 CMake 工具链定义。

函数

全部展开

coder.updateBuildInfo更新 RTW.BuildInfo 编译信息对象
target.addAdd target object to internal database
target.clearClear all target objects from internal database (自 R2023a 起)
target.create创建目标对象
target.exportExport target object data
target.getRetrieve target objects from internal database
target.removeRemove target object from internal database
target.updateUpdate target objects in internal database (自 R2023a 起)
target.upgradeUpgrade existing definitions of hardware devices
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 (自 R2024a 起)
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addUndefinesAdd undefine preprocessor directives to build information (自 R2024a 起)
removeIncludePathsRemove include paths from build information (自 R2023b 起)
removeSourceFilesRemove source files from build information object (自 R2021b 起)
removeUndefinesRemove undefine preprocessor macros from build information (自 R2024a 起)
findBuildArg在编译信息中查找特定编译参量
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 (自 R2024a 起)
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
getUndefinesFrom build information, get preprocessor macros to undefine (自 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

对象

RTW.BuildInfo提供用于编译和链接生成的代码的信息

coder.ExternalDependencyInterface to external code
target.AliasCreate alternative identifier for target object
target.BuildToolDescribe build tool (自 R2023a 起)
target.BuildToolTypeDescribe build tool type (自 R2023a 起)
target.CMakeSpecify CMake installation for building generated code (自 R2022b 起)
target.CMakeBuilder Configure how CMake builds generated code (自 R2022b 起)
target.CMakeBuildTypeDescribe CMake build type or build configuration (自 R2022b 起)
target.CMakeCacheEntryConfigure a CMake cache entry (自 R2022b 起)
target.EnvironmentConfigurationConfigure system environment for toolchain (自 R2022b 起)
target.HardwareComponentSupport描述对硬件组件的支持 (自 R2022b 起)
target.LanguageImplementation提供 C 和 C++ 编译器实现详细信息
target.Object用于目标类型的基类
target.ProcessorProvide target processor information
target.ToolchainCapture high-level information about toolchain (自 R2022b 起)

命名空间

target管理目标硬件和编译工具信息

主题

精选示例