Main Content

Share Build Configuration Settings

To share build configuration settings between multiple projects or between the project and command-line workflow, you can export settings to and import settings from a code generation configuration object.

This functionality is not supported in MATLAB® Online™.

Export Settings

You can export project file settings to a code configuration object by using the MATLAB Coder™ app or at the command line. The type of the configuration object depends on the project file settings.

Project File Settings in MATLAB Coder AppCode Configuration Object

Build type is MEX.

coder.MexCodeConfig

Build type is static library, dynamically linked library, or executable.

One of the following conditions is true:

  • You do not have Embedded Coder®.

  • You have Embedded Coder. On the All Settings tab, Use Embedded Coder features is set to No.

coder.CodeConfig

Build type is static library, dynamically linked library, or executable.

You have Embedded Coder. On the All Settings tab, Use Embedded Coder features is set to Yes.

coder.EmbeddedCodeConfig

You can then either import these settings into another project or use the configuration object with the codegen function -config option to generate code at the command line. For example, if you export to the configuration object cfg, you can use this configuration object with the -config option of the codegen command.

codegen -config cfg myfunction

Export Settings by Using the MATLAB Coder App

In the MATLAB Coder app:

  1. To open the Generate dialog box, on the Generate Code page, click the Generate arrow .

  2. Set Build type to Source Code, Static Library, Dynamic Library), or Executable (depending on your requirements).

  3. Click More Settings.

  4. Click Import/Export Settings.

  5. In the Variable name field, specify a name for the configuration object.

  6. Click Export to Variable.

    MATLAB Coder saves the project settings information in a configuration object with the specified name in the base workspace.

Export Settings at the Command Line

At the MATLAB command line, use the -toconfig option with the coder command to export the code configuration settings stored in a MATLAB Coder project file to a code configuration object. For example, executing this command returns a code configuration object cfg corresponding to myProject.prj.

cfg = coder('-toconfig','myProject.prj')

Import Settings

To import the settings saved in a code generation configuration object stored in the base workspace:

  1. To open the Generate dialog box, on the Generate Code page, click the Generate arrow .

  2. Set Build type to Source Code, Static Library, Dynamic Library, or Executable (depending on your requirements).

  3. Click More Settings.

  4. Click Import/Export Settings.

  5. In the Variable name field, specify the name of the configuration object.

  6. Click Import from Variable.

See Also

|

Related Topics