com.codemesh.terp.ant.compiler.cpp
Class BestDirectoryFormatter
java.lang.Object
com.codemesh.terp.api.Transformer.AbstractTransformer<java.lang.CharSequence>
com.codemesh.terp.api.Formatter.AbstractFormatter
com.codemesh.terp.ant.compiler.cpp.BestDirectoryFormatter
- All Implemented Interfaces:
- Executor<java.lang.CharSequence>, Formatter, Transformer<java.lang.CharSequence>
public class BestDirectoryFormatter
- extends Formatter.AbstractFormatter
- implements Executor<java.lang.CharSequence>
A formatter that attempts to return a string that represents the best
matching directory that actually exists and satisfies a pattern which
contains variables for compiler, OS, and processor architecture information.
This is necessary because we build a lot of software into architecture-mangled
file hierarchies, for example:
cpp/v3/lib
|
+- sunos
| |
| +- amd64
| | |
| | + gcc-3.3
| | + suncc-5.8
|
+- windows
| |
| +- amd64
| | |
| | + msvc-14.00
| | + msvc-15.00
| | + msvc-16.00
| +- x86
| | |
| | + msvc-14.00
| | + msvc-15.00
| | + msvc-16.00
This is great for telling the user what the libraries were built with, but it is
hard to use when the user's compiler does not exactly match the version number
that we used, for example we built with gcc-3.3 and the user has gcc-3.4. The user's
compiler might well be compatible, but we typically don't know how to find "the compatible"
version of the library.
This formatter attempts to find the right directory based on a pattern including placeholders
such as:
| Pattern | Purpose |
| %c | Compiler code (acc, gcc, etc.) |
| %v | Compiler version |
| %o | OS family (aix, hpux, linux, sunos, windows, etc.) |
| %V | OS version |
| %p | Processor architecture family (amd64, parisc, x86, etc.) |
Use this terp feature for example in the <libpath> element to select
a compiler specific library that is in a directory that contains the operating system,
the processor architecture, and the compiler code/compiler version in its path:
<libpath path="${bestcppdir(libDir+'/%o/%p/%c-%v/release')}" />
| Nested classes/interfaces inherited from interface com.codemesh.terp.api.Formatter |
Formatter.AbstractFormatter, Formatter.Base64, Formatter.Capitalize, Formatter.Namefy, Formatter.Pad, Formatter.Remove, Formatter.Replace, Formatter.TextFormatter, Formatter.ToAscii, Formatter.ToLowercase, Formatter.ToSlug, Formatter.ToUppercase, Formatter.ToXml |
|
Method Summary |
java.lang.CharSequence |
execute(java.util.List<java.lang.Object> args)
Performs the executor's action on the given arguments. |
java.lang.CharSequence |
execute(java.util.List<java.lang.Object> args,
TerpEvaluator eval,
TerpContext ctx)
Performs the executor's action on the given arguments in the given context. |
static java.lang.CharSequence |
format(java.lang.String format,
java.lang.Object item)
|
static java.lang.CharSequence |
format(java.lang.String format,
java.lang.Object item,
TerpContext ctx)
|
boolean |
matches(java.util.List<java.lang.Object> args)
Returns true if the executor applies to the given arguments. |
java.lang.CharSequence |
transform(java.lang.Object item,
java.util.List<java.lang.Object> args,
TerpContext ctx)
Transforms an item into another item, taking optional arguments into account. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ALIAS
public static final java.lang.String ALIAS
- See Also:
- Constant Field Values
ESCAPE
public static final char ESCAPE
- See Also:
- Constant Field Values
COMPILER_FAMILY
public static final char COMPILER_FAMILY
- See Also:
- Constant Field Values
COMPILER_VERSION
public static final char COMPILER_VERSION
- See Also:
- Constant Field Values
OS_FAMILY
public static final char OS_FAMILY
- See Also:
- Constant Field Values
OS_VERSION
public static final char OS_VERSION
- See Also:
- Constant Field Values
PROCARCH_FAMILY
public static final char PROCARCH_FAMILY
- See Also:
- Constant Field Values
BestDirectoryFormatter
public BestDirectoryFormatter()
matches
public boolean matches(java.util.List<java.lang.Object> args)
- Description copied from interface:
com.codemesh.terp.api.Executor
- Returns true if the executor applies to the given arguments.
Typically, your custom executor will implement this method to check for the proper
number of arguments and the proper argument types.
- Specified by:
matches in interface Executor<java.lang.CharSequence>
- Parameters:
args - the arguments passed to the executor.
- Returns:
- true if the executor knows how to handle the given arguments, false otherwise.
execute
public java.lang.CharSequence execute(java.util.List<java.lang.Object> args)
- Description copied from interface:
com.codemesh.terp.api.Executor
- Performs the executor's action on the given arguments.
Typically, this method is implemented in terms of
Executor.execute(List,TerpEvaluator,TerpContext).
- Specified by:
execute in interface Executor<java.lang.CharSequence>
- Parameters:
args - the arguments.
- Returns:
- the execution result.
execute
public java.lang.CharSequence execute(java.util.List<java.lang.Object> args,
TerpEvaluator eval,
TerpContext ctx)
- Description copied from interface:
com.codemesh.terp.api.Executor
- Performs the executor's action on the given arguments in the given context.
Typically, your custom executor will implement this method to provide its
core functionality.
- Specified by:
execute in interface Executor<java.lang.CharSequence>
- Parameters:
args - the arguments.eval - the evaluator to use. Can frequently be null.ctx - the context in which the execution occurs. Can frequently be null.
- Returns:
- the execution result.
format
public static java.lang.CharSequence format(java.lang.String format,
java.lang.Object item)
format
public static java.lang.CharSequence format(java.lang.String format,
java.lang.Object item,
TerpContext ctx)
transform
public java.lang.CharSequence transform(java.lang.Object item,
java.util.List<java.lang.Object> args,
TerpContext ctx)
- Description copied from interface:
com.codemesh.terp.api.Transformer
- Transforms an item into another item, taking optional arguments into account.
- Specified by:
transform in interface Transformer<java.lang.CharSequence>
- Parameters:
item - the item to transform.args - the optional arguments.ctx - the context in which the transformation occurs.
- Returns:
- the transformed item.
Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.