diff options
Diffstat (limited to 'src/net/sf/antcontrib/cpptasks/openwatcom')
9 files changed, 1132 insertions, 0 deletions
diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCCompiler.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCCompiler.java new file mode 100644 index 0000000..4c36438 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCCompiler.java @@ -0,0 +1,84 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.io.File; + +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.parser.CParser; +import net.sf.antcontrib.cpptasks.parser.Parser; + +import org.apache.tools.ant.types.Environment; + +/** + * Adapter for the OpenWatcom C Compiler. + * + * @author Curt Arnold + */ +public final class OpenWatcomCCompiler + extends OpenWatcomCompiler { + /** + * Singleton. + */ + private static final OpenWatcomCCompiler INSTANCE = new OpenWatcomCCompiler( + "wcl386", + false, null); + + /** + * Get compiler. + * @return OpenWatcomCCompiler compiler + */ + public static OpenWatcomCCompiler getInstance() { + return INSTANCE; + } + + /** + * Constructor. + * @param command String command + * @param newEnvironment boolean use new environment + * @param env Environment environment + */ + private OpenWatcomCCompiler(final String command, + final boolean newEnvironment, + final Environment env) { + super(command, "/?", + new String[] {".c", ".cc", ".cpp", ".cxx", ".c++"} + , + new String[] {".h", ".hpp", ".inl"} + , + newEnvironment, env); + } + + /** + * Create parser. + * @param source File file to be parsed. + * @return Parser parser + */ + public Parser createParser(final File source) { + return new CParser(); + } + + /** + * Get linker. + * @param type link type + * @return linker + */ + public Linker getLinker(final LinkType type) { + return OpenWatcomCLinker.getInstance().getLinker(type); + } +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCLinker.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCLinker.java new file mode 100644 index 0000000..93e65b4 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCLinker.java @@ -0,0 +1,69 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; + +/** + * Adapter for the OpenWatcom linker. + * + * @author Curt Arnold + */ +public final class OpenWatcomCLinker + extends OpenWatcomLinker { + /** + * Dll linker. + */ + private static final OpenWatcomCLinker DLL_LINKER = + new OpenWatcomCLinker(".dll"); + /** + * Exe linker. + */ + private static final OpenWatcomCLinker INSTANCE = + new OpenWatcomCLinker(".exe"); + /** + * Get linker instance. + * @return OpenWatcomCLinker linker + */ + public static OpenWatcomCLinker getInstance() { + return INSTANCE; + } + + /** + * Constructor. + * @param outputSuffix String output suffix. + */ + private OpenWatcomCLinker(final String outputSuffix) { + super("wcl386", outputSuffix); + } + + /** + * Get linker. + * @param type LinkType link type + * @return Linker linker + */ + public Linker getLinker(final LinkType type) { + if (type.isStaticLibrary()) { + return OpenWatcomLibrarian.getInstance(); + } + if (type.isSharedLibrary()) { + return DLL_LINKER; + } + return INSTANCE; + } +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCompiler.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCompiler.java new file mode 100644 index 0000000..4cf2d18 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomCompiler.java @@ -0,0 +1,169 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.io.File; +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.OptimizationEnum; +import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Processor; + +import org.apache.tools.ant.types.Environment; + +/** + * An abstract base class for the OpenWatcom C and Fortran compilers. + * + * @author Curt Arnold + */ +public abstract class OpenWatcomCompiler + extends CommandLineCompiler { + /** + * Constructor. + * @param command String command + * @param identifierArg String identifier + * @param sourceExtensions String[] source extension + * @param headerExtensions String[] header extension + * @param newEnvironment boolean use new enviroment + * @param env Environment environment + */ + protected OpenWatcomCompiler(final String command, + final String identifierArg, + final String[] sourceExtensions, + final String[] headerExtensions, + final boolean newEnvironment, + final Environment env) { + super(command, identifierArg, sourceExtensions, + headerExtensions, ".obj", false, + null, newEnvironment, env); + } + + /** + * Add implied arguments. + * @param args Vector command line arguments + * @param debug boolean is debug + * @param multithreaded boolean multithreaderd + * @param exceptions boolean support exceptions + * @param linkType LinkType link type + * @param rtti Boolean run time type information + * @param optimization OptimizationEnum + */ + protected final void addImpliedArgs(final Vector args, + final boolean debug, + final boolean multithreaded, + final boolean exceptions, + final LinkType linkType, + final Boolean rtti, + final OptimizationEnum optimization) { + args.addElement("/c"); + if (exceptions) { + args.addElement("/xs"); + } + if (multithreaded) { + args.addElement("/bm"); + } + if (debug) { + args.addElement("/d2"); + args.addElement("/od"); + args.addElement("/d_DEBUG"); + } else { + if (optimization != null) { + if (optimization.isSize()) { + args.addElement("/os"); + } + if (optimization.isSpeed()) { + args.addElement("/ot"); + } + } + args.addElement("/dNDEBUG"); + } + if (rtti != null && rtti.booleanValue()) { + args.addElement("/xr"); + } + } + + /** + * Add warning switch. + * @param args Vector command line arguments + * @param level int warning level + */ + protected final void addWarningSwitch(final Vector args, final int level) { + OpenWatcomProcessor.addWarningSwitch(args, level); + } + + /** + * Change enviroment. + * @param newEnvironment boolean use new enviroment + * @param env Environment environment + * @return Processor modified processor + */ + public final Processor changeEnvironment(final boolean newEnvironment, + final Environment env) { + return this; + } + + /** + * Get define switch. + * @param buffer StringBuffer buffer + * @param define String preprocessor macro + * @param value String value, may be null. + */ + protected final void getDefineSwitch(final StringBuffer buffer, + final String define, + final String value) { + OpenWatcomProcessor.getDefineSwitch(buffer, define, value); + } + + /** + * Get include path from environment. + * @return File[] + */ + protected final File[] getEnvironmentIncludePath() { + return CUtil.getPathFromEnvironment("INCLUDE", ";"); + } + + /** + * Get include directory switch. + * @param includeDir String include directory + * @return String command line argument + */ + protected final String getIncludeDirSwitch(final String includeDir) { + return OpenWatcomProcessor.getIncludeDirSwitch(includeDir); + } + + + /** + * Get maximum command line length. + * @return int maximum command line length + */ + public final int getMaximumCommandLength() { + return 4096; + } + + /** + * Get undefine switch. + * @param buffer StringBuffer argument destination + * @param define String preprocessor macro + */ + protected final void getUndefineSwitch(final StringBuffer buffer, + final String define) { + OpenWatcomProcessor.getUndefineSwitch(buffer, define); + } + +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranCompiler.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranCompiler.java new file mode 100644 index 0000000..ca3abcb --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranCompiler.java @@ -0,0 +1,86 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.io.File; + +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.parser.FortranParser; +import net.sf.antcontrib.cpptasks.parser.Parser; + +import org.apache.tools.ant.types.Environment; + +/** + * Adapter for the OpenWatcom Fortran compiler. + * + * @author Curt Arnold + */ +public final class OpenWatcomFortranCompiler + extends OpenWatcomCompiler { + /** + * Singleton. + */ + private static final OpenWatcomFortranCompiler[] INSTANCE = + new OpenWatcomFortranCompiler[] { + new OpenWatcomFortranCompiler( + "wfl386", false, null)}; + + /** + * Get instance. + * @return OpenWatcomFortranCompiler compiler instance + */ + public static OpenWatcomFortranCompiler getInstance() { + return INSTANCE[0]; + } + + /** + * Constructor. + * @param command String command + * @param newEnvironment boolean use new environment + * @param env Environment environment + */ + private OpenWatcomFortranCompiler(final String command, + final boolean newEnvironment, + final Environment env) { + super(command, "/?", + new String[] {".f90", ".for", ".f"} + , + new String[] {".i", ".i90", ".fpp"} + , + newEnvironment, env); + } + + /** + * Create dependency parser. + * @param source File source file + * @return Parser parser + */ + public Parser createParser(final File source) { + return new FortranParser(); + } + + /** + * Get linker. + * @param type link type + * @return linker + */ + public Linker getLinker(final LinkType type) { + return OpenWatcomFortranLinker.getInstance().getLinker(type); + } + +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranLinker.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranLinker.java new file mode 100644 index 0000000..82b6999 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomFortranLinker.java @@ -0,0 +1,69 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; + +/** + * Adapter for the OpenWatcom Fortran linker. + * + * @author Curt Arnold + */ +public final class OpenWatcomFortranLinker + extends OpenWatcomLinker { + /** + * Singleton for DLL linking. + */ + private static final OpenWatcomFortranLinker DLL_LINKER = new + OpenWatcomFortranLinker(".dll"); + /** + * Singleton for executables. + */ + private static final OpenWatcomFortranLinker INSTANCE = new + OpenWatcomFortranLinker(".exe"); + /** + * Get instance. + * @return OpenWatcomFortranLinker linker + */ + public static OpenWatcomFortranLinker getInstance() { + return INSTANCE; + } + + /** + * Constructor. + * @param outputSuffix String output suffix + */ + private OpenWatcomFortranLinker(final String outputSuffix) { + super("wfl386", outputSuffix); + } + + /** + * Get linker. + * @param type LinkType link type + * @return Linker linker + */ + public Linker getLinker(final LinkType type) { + if (type.isStaticLibrary()) { + return OpenWatcomLibrarian.getInstance(); + } + if (type.isSharedLibrary()) { + return DLL_LINKER; + } + return INSTANCE; + } +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java new file mode 100644 index 0000000..848c395 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLibrarian.java @@ -0,0 +1,254 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.io.File; +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; +import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; + +/** + * Adapter for the OpenWatcom Librarian. + * + * @author Curt Arnold + */ +public final class OpenWatcomLibrarian + extends CommandLineLinker { + /** + * Singleton. + */ + private static final OpenWatcomLibrarian INSTANCE = new OpenWatcomLibrarian(); + /** + * Singleton accessor. + * @return OpenWatcomLibrarian librarian instance + */ + public static OpenWatcomLibrarian getInstance() { + return INSTANCE; + } + + /** + * Constructor. + */ + private OpenWatcomLibrarian() { + super("wlib", null, new String[] {".obj"} + , new String[0], ".lib", false, + null); + } + + /** + * Add base address. + * @param base long base address + * @param args Vector command line arguments + */ + protected void addBase(final long base, final Vector args) { + } + + /** + * Add alternative entry point. + * @param entry String entry point + * @param args Vector command line arguments + */ + protected void addEntry(final String entry, final Vector args) { + } + + /** + * Add fixed parameter. + * @param fixed Boolean true if fixed + * @param args Vector command line arguments + */ + protected void addFixed(final Boolean fixed, final Vector args) { + } + + /** + * Add implied arguments. + * @param debug boolean true if debugging + * @param linkType LinkType link type + * @param args Vector command line arguments + */ + protected void addImpliedArgs(final boolean debug, + final LinkType linkType, + final Vector args) { + } + + /** + * Add incremental option. + * @param incremental boolean true if incremental + * @param args Vector command line arguments + */ + protected void addIncremental(final boolean incremental, + final Vector args) { + } + + /** + * Add map option. + * @param map boolean true to create map file + * @param args Vector command line argument + */ + protected void addMap(final boolean map, + final Vector args) { + } + + /** + * Add stack size option. + * @param stack int stack size + * @param args Vector command line arguments + */ + protected void addStack(final int stack, + final Vector args) { + } + + /** + * Get command file switch. + * @param cmdFile String command file + * @return String command file switch + */ + protected String getCommandFileSwitch(final String cmdFile) { + return OpenWatcomProcessor.getCommandFileSwitch(cmdFile); + } + + + /** + * Get library search path. + * @return File[] library search path + */ + public File[] getLibraryPath() { + return CUtil.getPathFromEnvironment("LIB", ";"); + } + + /** + * Get file selectors for specified library names. + * @param libnames String[] library names + * @param libType LibraryTypeEnum library type enum + * @return String[] file selection patterns + */ + public String[] getLibraryPatterns(final String[] libnames, + final LibraryTypeEnum libType) { + return OpenWatcomProcessor.getLibraryPatterns(libnames, libType); + } + + /** + * Get linker. + * @param type LinkType link type + * @return Linker linker + */ + public Linker getLinker(final LinkType type) { + return OpenWatcomCLinker.getInstance().getLinker(type); + } + + /** + * Gets maximum command line. + * @return int maximum command line + */ + public int getMaximumCommandLength() { + return 1024; + } + + /** + * Create output file switch. + * @param outFile String output file switch + * @return String[] output file switch + */ + public String[] getOutputFileSwitch(final String outFile) { + return OpenWatcomProcessor.getOutputFileSwitch(outFile); + } + + /** + * Gets case-sensisitivity of processor. + * @return boolean true if case sensitive + */ + public boolean isCaseSensitive() { + return OpenWatcomProcessor.isCaseSensitive(); + } + + /** + * Builds a library. + * @param task task + * @param outputFile generated library + * @param sourceFiles object files + * @param config linker configuration + */ + public void link(final CCTask task, + final File outputFile, + final String[] sourceFiles, + final CommandLineLinkerConfiguration config) { + // + // delete any existing library + outputFile.delete(); + // + // build a new library + super.link(task, outputFile, sourceFiles, config); + } + + /** + * Prepares argument list for exec command. + * @param task task + * @param outputDir output directory + * @param outputName output file name + * @param sourceFiles object files + * @param config linker configuration + * @return arguments for runTask + */ + protected String[] prepareArguments( + final CCTask task, + final String outputDir, + final String outputName, + final String[] sourceFiles, + final CommandLineLinkerConfiguration config) { + String[] preargs = config.getPreArguments(); + String[] endargs = config.getEndArguments(); + StringBuffer buf = new StringBuffer(); + Vector execArgs = new Vector(preargs.length + endargs.length + 10 + + sourceFiles.length); + + execArgs.addElement(this.getCommand()); + String outputFileName = new File(outputDir, outputName).toString(); + execArgs.addElement(quoteFilename(buf, outputFileName)); + + for (int i = 0; i < preargs.length; i++) { + execArgs.addElement(preargs[i]); + } + + int objBytes = 0; + + for (int i = 0; i < sourceFiles.length; i++) { + String last4 = sourceFiles[i] + .substring(sourceFiles[i].length() - 4).toLowerCase(); + if (!last4.equals(".def") + && !last4.equals(".res") + && !last4.equals(".lib")) { + execArgs.addElement("+" + quoteFilename(buf, sourceFiles[i])); + objBytes += new File(sourceFiles[i]).length(); + } + } + + for (int i = 0; i < endargs.length; i++) { + execArgs.addElement(endargs[i]); + } + + String[] execArguments = new String[execArgs.size()]; + execArgs.copyInto(execArguments); + + return execArguments; + } + +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java new file mode 100644 index 0000000..f0bbe3d --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomLinker.java @@ -0,0 +1,205 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.io.File; +import java.io.IOException; +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; +import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.platforms.WindowsPlatform; +import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; + +/** + * Adapter for the OpenWatcom linker. + * + * @author Curt Arnold + */ +public abstract class OpenWatcomLinker + extends CommandLineLinker { + /** + * Constructor. + * @param command String command string (wcl386 or wfl386) + * @param outputSuffix String output suffix + */ + protected OpenWatcomLinker(final String command, + final String outputSuffix) { + super(command, "-r", new String[] {".obj", ".lib", ".res"} + , + new String[] {".map", ".pdb", ".lnk"} + , outputSuffix, false, null); + } + + /** + * Add specified base address to linker options. + * @param base long base address + * @param args Vector command options + */ + protected final void addBase(final long base, final Vector args) { + } + + /** + * Adds non-default entry point. + * @param entry entry point name + * @param args command line parameters + */ + protected final void addEntry(final String entry, final Vector args) { + } + + /** + * Adds fixed option. + * @param fixed if executable is fixed + * @param args command line parameters + */ + protected final void addFixed(final Boolean fixed, final Vector args) { + } + + /** + * Adds other command line parameters. + * @param debug boolean is debug + * @param linkType LinkType link type + * @param args Vector command line arguments + */ + protected final void addImpliedArgs(final boolean debug, + final LinkType linkType, + final Vector args) { + if (linkType.isExecutable()) { + if (linkType.isSubsystemConsole()) { + args.addElement("/bc"); + } else { + if (linkType.isSubsystemGUI()) { + args.addElement("/bg"); + } + } + } + if (linkType.isSharedLibrary()) { + args.addElement("/bd"); + } + } + + /** + * Add command line switch to force incremental linking. + * @param incremental boolean do incremental linking + * @param args Vector command line arguments + */ + protected final void addIncremental(final boolean incremental, + final Vector args) { + } + + /** + * Add command line switch to force map generation. + * @param map boolean build map + * @param args Vector command line arguments + */ + protected final void addMap(final boolean map, final Vector args) { + if (map) { + args.addElement("/fm"); + } + } + + /** + * Add command line switch for stack reservation. + * @param stack int stack size. + * @param args Vector command line arguments. + */ + protected final void addStack(final int stack, final Vector args) { + if (stack >= 0) { + String stackStr = Integer.toString(stack); + args.addElement("/k" + stackStr); + } + } + + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param outputFile name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + * @throws IOException if unable to write version resource + */ + public final void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) throws IOException { + WindowsPlatform.addVersionFiles(versionInfo, linkType, outputFile, isDebug, + objDir, matcher); + } + + /** + * Get command file switch. + * @param commandFile String command file name + * @return String command line option + */ + public final String getCommandFileSwitch(final String commandFile) { + return "@" + commandFile; + } + + /** + * Get search path for libraries. + * @return File[] library path + */ + public final File[] getLibraryPath() { + return CUtil.getPathFromEnvironment("LIB", ";"); + } + + /** + * Get file selectors for libraries. + * @param libnames String[] + * @param libType LibraryTypeEnum + * @return String[] + */ + public final String[] getLibraryPatterns(final String[] libnames, + final LibraryTypeEnum libType) { + return OpenWatcomProcessor.getLibraryPatterns(libnames, libType); + } + + /** + * Get maximum command line length. + * @return int command line length + */ + public final int getMaximumCommandLength() { + return 1024; + } + + /** + * Get output file switch. + * @param outFile Output file name + * @return String[] command line switches + */ + public final String[] getOutputFileSwitch(final String outFile) { + return OpenWatcomProcessor.getOutputFileSwitch(outFile); + } + + /** + * Gets file name sensitivity of processors. + * @return boolean true if case sensitive. + */ + public final boolean isCaseSensitive() { + return OpenWatcomProcessor.isCaseSensitive(); + } + +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomProcessor.java b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomProcessor.java new file mode 100644 index 0000000..5845776 --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/OpenWatcomProcessor.java @@ -0,0 +1,169 @@ +/* + * + * Copyright 2002-2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.sf.antcontrib.cpptasks.openwatcom; + +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; + +/** + * A add-in class for OpenWatcom processors. + * + * + */ +public final class OpenWatcomProcessor { + /** + * Adds warning command line options. + * + * @param args Vector list of options + * @param level int value of WarningLevelEnum + */ + public static void addWarningSwitch(final Vector args, final int level) { + switch (level) { + case 0: + args.addElement("/w0"); + break; + case 1: + args.addElement("/w1"); + break; + case 2: + break; + case 3: + args.addElement("/w2"); + break; + case 4: + args.addElement("/w3"); + break; + case 5: + args.addElement("/we"); + break; + default: + args.addElement("/w1"); + break; + } + } + + /** + * Gets command line option to read from an option file. + * + * @param cmdFile String file name for option file + * @return String Command line option + */ + public static String getCommandFileSwitch(final String cmdFile) { + StringBuffer buf = new StringBuffer("@"); + if (cmdFile.indexOf(' ') >= 0) { + buf.append('\"'); + buf.append(cmdFile.replace('/', '\\')); + buf.append('\"'); + } else { + buf.append(cmdFile); + } + return buf.toString(); + } + + /** + * Creates a command line option to define a preprocessor macro. + * + * @param buffer StringBuffer destination buffer + * @param define String parameter to define + * @param value String value, may be null + */ + public static void getDefineSwitch(final StringBuffer buffer, + final String define, + final String value) { + buffer.append("/d"); + buffer.append(define); + if (value != null && value.length() > 0) { + buffer.append('='); + buffer.append(value); + } + } + + /** + * Create a command line option to add a directory to the include path. + * @param includeDir String directory + * @return String command line option + */ + public static String getIncludeDirSwitch(final String includeDir) { + return "/i=" + includeDir.replace('/', '\\'); + } + + /** + * Builds command line options to specify the output file names. + * + * @param outPath String path to output file + * @return String[] command line options + */ + public static String[] getOutputFileSwitch(final String outPath) { + StringBuffer buf = new StringBuffer("/fo="); + if (outPath.indexOf(' ') >= 0) { + buf.append('\"'); + buf.append(outPath); + buf.append('\"'); + } else { + buf.append(outPath); + } + String[] retval = new String[] { + buf.toString()}; + return retval; + } + + /** + * Get file selectors for specified libraries. + * @param libnames library names + * @param libType library type + * @return file selectors + */ + public static String[] getLibraryPatterns(final String[] libnames, + final LibraryTypeEnum libType) { + StringBuffer buf = new StringBuffer(); + String[] patterns = new String[libnames.length]; + for (int i = 0; i < libnames.length; i++) { + buf.setLength(0); + buf.append(libnames[i]); + buf.append(".lib"); + patterns[i] = buf.toString(); + } + return patterns; + } + + /** + * Builds a command line option to undefine a preprocessor macro. + * @param buffer StringBuffer destination + * @param define String macro to be undefined + */ + public static void getUndefineSwitch(final StringBuffer buffer, + final String define) { + buffer.append("/u"); + buffer.append(define); + } + + /** + * Gets whether processor tratement of file names is case-sensitive. + * @return boolean true if case sensitive + */ + public static boolean isCaseSensitive() { + return false; + } + + /** + * Private constructor. + */ + private OpenWatcomProcessor() { + } + +} diff --git a/src/net/sf/antcontrib/cpptasks/openwatcom/package.html b/src/net/sf/antcontrib/cpptasks/openwatcom/package.html new file mode 100644 index 0000000..3d9adab --- /dev/null +++ b/src/net/sf/antcontrib/cpptasks/openwatcom/package.html @@ -0,0 +1,27 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<!-- + +Copyright 2004 The Ant-Contrib project + + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy of + the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations under + the License. + +--> +</head> +<body bgcolor="white"> + +Adapters for OpenWatcom compilers and tools. +</body> +</html> + |