Main Content

setDirective

Class: coder.make.BuildTool
Namespace: coder.make

Set value of directive in Directives

Syntax

h.setDirective(name,value)

Description

h.setDirective(name,value) assigns a value to the named directive in coder.make.Directives.

Input Arguments

expand all

Object handle for a coder.make.BuildTool object, specified as a variable.

Example: tool

Name of directive, specified as a character vector.

Data Types: char

Value of directive, specified as a character vector.

Data Types: char

Examples

Get a Default Build Tool and Set Its Properties

The following example code shows setDirective in a portion of the intel_tc.m file from the Add Custom Toolchains to MATLAB® Coder™ Build Process tutorial.

% ------------------------------
% C Compiler
% ------------------------------
 
tool = tc.getBuildTool('C Compiler');

tool.setName('Intel C Compiler');
tool.setCommand('icl');
tool.setPath('');

tool.setDirective('IncludeSearchPath','-I');
tool.setDirective('PreprocessorDefine','-D');
tool.setDirective('OutputFlag','-Fo');
tool.setDirective('Debug','-Zi');

tool.setFileExtension('Source','.c');
tool.setFileExtension('Header','.h');
tool.setFileExtension('Object','.obj');

tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

Use the setDirective Method Interactively

tc = coder.make.ToolchainInfo;
tool = tc.getBuildTool('C Compiler');
tool.addDirective('IncludeSearchPath','-O');
tool.setDirective('IncludeSearchPath','-I');
tool.getDirective('IncludeSearchPath')
ans  = 

-I

Specify Custom Toolchain Directives for Building PIL Target Application

If you use a custom toolchain for building a processor-in-the-loop (PIL) target application that supports Simulink® Coverage™ analysis or Embedded Coder® code execution profiling, in the toolchain definition file, you must provide these compiler directives:

  • CompileFlag — Specify the flag that C or C++ compiler uses to compile source files without linking. For example, if the compiler in the toolchain is GNU® C or C++, set the directive to -c.

  • PreprocessFile — Specify the flag that C or C++ compiler uses to preprocess the source files without running other compiler stages. For example, if the compiler in the toolchain is GNU C or C++, set the directive to -E.

This section from a toolchain definition file example shows how you can use the setDirective method to provide the directives.

tc = coder.make.ToolchainInfo('BuildArtifact','nmake makefile');
tc.Name ='My Toolchain Name';
tc.Platform ='win64';
tc.SupportedVersion ='14';
...
% ------------------------------
% C Compiler
% ------------------------------
tool = tc.getBuildTool('C Compiler');
tool.setName('My C Compiler');
...
tool.setDirective('CompileFlag','-c');
tool.setDirective('PreprocessFile','-E');
...

Version History

Introduced in R2013a