terp - the ANT Tasks

Class DefineOption

  extended by com.codemesh.terp.ant.compiler.AbstractCompilerOption<CppCompiler>
      extended by com.codemesh.terp.ant.compiler.cpp.DefineOption
All Implemented Interfaces:
CompilerOption<CppCompiler>, PreprocessorOption

public class DefineOption
extends AbstractCompilerOption<CppCompiler>
implements PreprocessorOption

A preprocessor definition.

Constructor Summary
Method Summary
 void addCommands(java.util.List<java.lang.String> commandList, CppCompiler compiler, CompilerPhase phase)
          Adds the compiler switches repreesnted by this option to the list of switches.
 boolean appliesTo(CppCompiler compiler, CompilerPhase phase)
          Returns true if this compiler option applies to the given compiler and compiler phase.
 java.lang.String getName()
          Returns the preprocessor definition's name.
 java.lang.String getValue()
          Returns the preprocessor definition's value.
 void setName(java.lang.String name)
          Set the name of the preprocesor option.
 void setValue(java.lang.String value)
          Sets the preprocessor definition's value.
Methods inherited from class com.codemesh.terp.ant.compiler.AbstractCompilerOption
expand, expand, getIf, getProject, getUnless, quoteIfNecessary, satisfies, setIf, setProject, setUnless
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DefineOption()
Method Detail


public void addCommands(java.util.List<java.lang.String> commandList,
                        CppCompiler compiler,
                        CompilerPhase phase)
Adds the compiler switches repreesnted by this option to the list of switches. Some compiler options may result in more than one switch being added to a compiler invocation. Other compiler options may result in different options being added in different phases (compilation vs. linking) of the build.

This method is called by the compiler repeatedly with different values for the compiler phase to account for these possibilities.

Specified by:
addCommands in interface CompilerOption<CppCompiler>
commandList - the list to which the compiler switches represented by this option (if any) are added.
compiler - the compiler for which we're doing this.
phase - the compiler phase in wihch we're doing this.


public boolean appliesTo(CppCompiler compiler,
                         CompilerPhase phase)
Returns true if this compiler option applies to the given compiler and compiler phase. Not every option has switches to contribute for every compiler and every compilation phase. This method allows a quick, inexpensive check to filter out potentially more expensive calls later on.

Specified by:
appliesTo in interface CompilerOption<CppCompiler>
compiler - the compiler for which we're asking.
phase - the compiler phase we're executing.


public void setName(java.lang.String name)
Set the name of the preprocesor option. This is a required attribute.

name - the preprocessor definition's name.


public java.lang.String getName()
Returns the preprocessor definition's name.

the preprocessor definition's name.


public void setValue(java.lang.String value)
Sets the preprocessor definition's value. This is an optional attribute. Most preprocessors assign value-less definitions a default value, commonly the integer constant 1. To prevent this default assignment, when you truly want a definition with an empty value, please specify an empty string value.

You can define string and character literal values by surrounding the value string with doublequotes or quotes. Please remember to use the string &quot; to represent a doublequote in an ANT build script.

value - the preprocessor definition's value.


public java.lang.String getValue()
Returns the preprocessor definition's value.

the preprocessor definition's value.

terp - the ANT Tasks

Copyright © 2008-2016 by Codemesh, Inc. All Rights Reserved.