主要内容

coder.make.BuildOpts

R2026b

Command options for invoking compile stage of code generation

Since R2026b

    Description

    A coder.make.BuildOpts object contains command options for invoking the compile stage of code generation. You can use the object as an input argument to the codebuild function.

    Creation

    Description

    You can create a coder.make.BuildOpts object in these ways:

    • Use the loadBuildInfo function to load build info from a MAT file. The function outputs a coder.make.BuildOpts object.

    • Use buildOptions = coder.make.BuildOpts.

    Properties

    expand all

    Build method for compilation, specified as a character vector or string scalar. 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 generates CMakeLists.txt configuration files for the CMake build system. The argument value is case-insensitive. For example, you can also specify "Cmake" or "CMake".

    Example: "CMake"

    Data Types: char | string

    Output type of the build, specified as one of these enumeration values:

    • STANDALONE_EXECUTABLE –– Generate a standalone, executable file.

    • MODEL_REFERENCE_CODER –– Generate a static library.

    • MEX_FILE –– Generate a MEX file. Use this value only for building a simulation target, for example, model reference simulation target (ModelReferenceSimTarget) and accelerator mode.

    • SHARED_LIBRARY –– Generate a dynamic library.

    • STATIC_LIBRARY –– Generate a static library.

    Example: SHARED_LIBRARY

    Examples

    collapse all

    Open example CodeBuildModel. Configure the model so that when you generate code for the model, you do not compile the code, generate a makefile, or package generated code and artifacts.

    openExample("CodeBuildModel")
    set_param("CodeBuildModel","GenerateMakefile","off");
    set_param("CodeBuildModel","PackageGeneratedCodeAndArtifacts","off");

    Generate code for the model.

    slbuild("CodeBuildModel");
    

    Load the build information and review the build options.

    buildFolder = RTW.getBuildDir("CodeBuildModel").BuildDirectory;
    [buildInfo,buildOpts] = loadBuildInfo(buildFolder);
    buildOpts
    
    buildOpts = 
    
      BuildOpts with properties:
    
         BuildMethod: 'GNU gcc/g++ | gmake (64-bit Linux)'
        BuildVariant: STANDALONE_EXECUTABLE

    Generate the CMakeLists.txt configuration files using the specified build folder and build options.

    codebuild(buildInfo,buildOpts)
    

    Change the build method and regenerate the configuration files.

    buildOpts.BuildMethod = 'cmake';
    codebuild(buildInfo,buildOpts)
    

    Version History

    Introduced in R2026b