Contenido principal

setDirective

Class: target.BuildTool
Namespace: target

Set directive values

Since R2023a

Syntax

myBuildTool.setDirective(directiveName,directiveValue)
myBuildTool.setDirective(pairedDirectiveName,startValue,endValue)

Description

myBuildTool.setDirective(directiveName,directiveValue) sets the named directive to the specified value.

myBuildTool.setDirective(pairedDirectiveName,startValue,endValue) sets the start and end values of the named directive.

If the Directives property does not contain the directive, the method appends a new object of the appropriate subclass of target.BaseDirective.

If the directive name is not supported by the build tool type specified by the target.BuildToolType object, the method produces an error.

Input Arguments

expand all

Name of directive. This table provides a list of supported directives.

Build Tool TypeDirective Name (Command-Line Flag)Optional or RequiredDirective PurposeExample Value
'Assembler''Debug'Required Generate debugging information.'-g'
'IncludeSearchPath'RequiredPrefix header file include path specification.'-I'
'OutputFlag'RequiredPrefix name of tool output (object file).'-o'
'PreprocessorDefine'RequiredPrefix preprocessor macro definitions.'-D'
'GenerateDependencyFiles'OptionalGenerate file that describes header file dependencies.'-MMD'
'C Compiler' or 'C++ Compiler''CompileFlag'RequiredCompile source file to produce object file.'-c'
'Debug' Required Generate debugging information.'-g'
'DisableOptimization' RequiredDisable compiler optimizations.'-O0'
'EnableOptimization'RequiredEnable compiler optimizations.'-O3'
'IncludeSearchPath'RequiredPrefix header file include path specification.'-I'
'OutputFlag'RequiredPrefix name of tool output (object file).'-o'
'PreprocessFile'RequiredOutput preprocessed source instead of completing compilation.'-E'
'PreprocessorDefine'RequiredPrefix preprocessor macro definitions.'-D'
'CommandFile'OptionalSpecify command, subcommand, or response file to circumvent command interpreter line length limitations. '@'
'GenerateDependencyFiles'OptionalGenerate file describing header file dependencies.'-MMD'
'Preinclude'OptionalPrefix name of header file to include (as if source code is included using #include).'-include'
'PreprocessorUndefine'OptionalPrefix undefinition of a previously defined preprocessor macro.'-U'
'Archiver''Debug'RequiredGenerate debugging information.''
'LibrarySearchPath'RequiredPrefix library search path specification.'-L'
'OutputFlag'RequiredPrefix name of tool output (static library).'-o '
'CommandFile'OptionalSpecify command, subcommand, or response file to circumvent command interpreter line length limitations.'@'
'Input'OptionalPrefix name of input object files.'-input=file.obj'
'Linker' or 'C++ Linker''Debug'RequiredGenerate debugging information.'-g'
'Library'RequiredPrefix “system library”. '-l'
'LibrarySearchPath'RequiredPrefix library search path specification.'-L'
'OutputFlag'RequiredPrefix name of tool output (executable file or shared library).'-o'
'CommandFile'OptionalSpecify command, subcommand, or response file to circumvent command interpreter line length limitations.'@'
'DefFile'OptionalPrefix name of module definition file containing information about symbols export (for shared library generation).'-def:'
'Input'OptionalPrefix name of input object files when using a command, subcommand, or response file.'-input=file.obj'
'LibraryGroup'OptionalEncapsulate group of input libraries or object files to indicate multiple linker passes to resolve circular or out-of-order dependencies.'-Wl,--start-group | -Wl,--end-group'
'LibraryLinkObj'OptionalPrefix name of input library files.'-library=file.lib'
'LibrarySearchPathRuntime'Optional Prefix run-time library search path specification. '-rpath'
'Shared'OptionalIndicate that shared library (instead of standalone executable file) must be generated.'-shared -Wl,--no-undefined'
'Make Tool''File'RequiredPrefix name of make file to process.'-f'

Example: cCompiler.setDirective('CommandFile', '@');

New value for named directive.

Example: cCompiler.setDirective('CommandFile', '@');

Name of directive that contains a pair of command-line flags.

Example: cLinker.setDirective('LibraryGroup', '-Wl,--start-group', '-Wl,--end-group');

New start value for paired directive.

Example: cLinker.setDirective('LibraryGroup', '-Wl,--start-group', '-Wl,--end-group');

New end value for paired directive.

Example: cLinker.setDirective('LibraryGroup', '-Wl,--start-group', '-Wl,--end-group');

Examples

expand all

This code snippet shows how you can use the setDirective method to state that the C compiler uses the @ symbol as the prefix to specify a command, subcommand, or response file (to circumvent command interpreter line length limitations).

cCompiler = target.create('BuildTool', 'C Compiler', 'gcc', ...
    'Name', 'MinGW GCC C Compiler');
cCompiler.setDirective('CommandFile', '@');
cCompiler.setFileExtensions('Object', {'.obj'});

Version History

Introduced in R2023a