Index: samples/cppunit.ant =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/samples/cppunit.ant,v retrieving revision 1.1 diff -u -r1.1 cppunit.ant --- samples/cppunit.ant 19 Apr 2004 04:21:48 -0000 1.1 +++ samples/cppunit.ant 20 Apr 2004 04:07:46 -0000 @@ -29,6 +29,8 @@ + + @@ -46,16 +48,32 @@ - + + + + + + + + + + + + + + + + + - + if="do-autogen"> @@ -63,14 +81,14 @@ + depends="run-autogen" + if="do-configure"> - + @@ -86,6 +104,15 @@ + + + + + + + + + @@ -93,7 +120,7 @@ - + - + - + - + - + @@ -153,7 +180,7 @@ - + @@ -173,7 +200,7 @@ - + @@ -263,7 +290,7 @@ excludes="DllPlugInTesterTest.cpp"/> - + @@ -286,7 +313,7 @@ excludes="DllPlugInTester.cpp"/> - + @@ -311,11 +338,11 @@ includes="*.cpp"/> - + - + @@ -337,11 +364,11 @@ includes="*.cpp"/> - + - + @@ -371,11 +398,11 @@ - + - + @@ -413,7 +440,7 @@ - + Index: src/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java,v retrieving revision 1.15 diff -u -r1.15 BorlandCCompiler.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java 28 Feb 2004 20:00:01 -0000 1.15 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandCCompiler.java 20 Apr 2004 04:07:46 -0000 @@ -42,7 +42,7 @@ return instance; } private BorlandCCompiler(boolean newEnvironment, Environment env) { - super("bcc32", "-?", sourceExtensions, headerExtensions, ".obj", false, + super("bcc32", "--version", sourceExtensions, headerExtensions, ".obj", false, null, newEnvironment, env); } protected void addImpliedArgs(Vector args, boolean debug, Index: src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java,v retrieving revision 1.15 diff -u -r1.15 BorlandLibrarian.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java 28 Feb 2004 20:00:01 -0000 1.15 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java 20 Apr 2004 04:07:46 -0000 @@ -16,12 +16,17 @@ */ package net.sf.antcontrib.cpptasks.borland; import java.io.File; +import java.io.IOException; import java.util.Vector; +import org.apache.tools.ant.BuildException; import net.sf.antcontrib.cpptasks.CUtil; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.LinkType; import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; + /** * Adapter for the Borland(r) tlib Librarian * @@ -33,7 +38,7 @@ return instance; } private BorlandLibrarian() { - super("tlib", null, new String[]{".obj"}, new String[0], ".lib", false, + super("tlib", "--version", new String[]{".obj"}, new String[0], ".lib", false, null); } protected void addBase(long base, Vector args) { @@ -69,4 +74,120 @@ public boolean isCaseSensitive() { return BorlandProcessor.isCaseSensitive(); } + /** + * Gets identifier for the linker. + * + * TLIB will lockup when attempting to get version + * information. Since the Librarian version isn't critical + * just return a stock response. + */ + public String getIdentifier() { + return "TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation"; + } + + /** + * Prepares argument list for exec command. + * + * @param outputFile + * linker output file + * @param sourceFiles + * linker input files (.obj, .o, .res) + * @param args + * linker arguments + * @return arguments for runTask + */ + protected String[] prepareArguments( + CCTask task, + String outputDir, + String outputName, + String[] sourceFiles, + 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]); + } + + // + // add a place-holder for page size + // + int pageSizeIndex = execArgs.size(); + execArgs.addElement(null); + + 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")) { + } else { + if (last4.equals(".res")) { + } else { + if (last4.equals(".lib")) { + } else { + 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); + + int minPageSize = objBytes >> 16; + int pageSize = 0; + for(int i = 4; i <= 15; i++) { + pageSize = 1 << i; + if (pageSize > minPageSize) break; + } + execArguments[pageSizeIndex] = "/P" + Integer.toString(pageSize); + + return execArguments; + } + + /** + * Prepares argument list to execute the linker using a response file. + * + * @param outputFile + * linker output file + * @param args + * output of prepareArguments + * @return arguments for runTask + */ + protected String[] prepareResponseFile(File outputFile, String[] args) + throws IOException { + return BorlandProcessor.prepareResponseFile(outputFile, args, " & \n"); + } + + /** + * Builds a library + * + */ + public void link(CCTask task, + File outputFile, + String[] sourceFiles, + CommandLineLinkerConfiguration config) + throws BuildException + { + // + // delete any existing library + outputFile.delete(); + // + // build a new library + super.link(task, outputFile, sourceFiles, config); + } + } Index: src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java,v retrieving revision 1.17 diff -u -r1.17 BorlandLinker.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java 28 Feb 2004 20:00:01 -0000 1.17 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java 20 Apr 2004 04:07:46 -0000 @@ -16,12 +16,11 @@ */ package net.sf.antcontrib.cpptasks.borland; import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.util.Enumeration; import java.util.Vector; -import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.CCTask; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; @@ -61,6 +60,7 @@ } if (linkType.isSharedLibrary()) { args.addElement("/Tpd"); + args.addElement("/Gi"); } } protected void addIncremental(boolean incremental, Vector args) { @@ -130,8 +130,12 @@ * linker arguments * @return arguments for runTask */ - protected String[] prepareArguments(String outputDir, String outputName, - String[] sourceFiles, CommandLineLinkerConfiguration config) { + protected String[] prepareArguments( + CCTask task, + String outputDir, + String outputName, + String[] sourceFiles, + CommandLineLinkerConfiguration config) { String[] preargs = config.getPreArguments(); String[] endargs = config.getEndArguments(); Vector execArgs = new Vector(preargs.length + endargs.length + 10 @@ -204,10 +208,24 @@ // add all the libraries // Enumeration libEnum = libFiles.elements(); + boolean hasImport32 = false; + boolean hasCw32 = false; while (libEnum.hasMoreElements()) { String libName = (String) libEnum.nextElement(); + if (libName.equalsIgnoreCase("import32.lib")) { + hasImport32 = true; + } + if (libName.equalsIgnoreCase("cw32.lib")) { + hasImport32 = true; + } execArgs.addElement(quoteFilename(buf, libName)); } + if (!hasCw32) { + execArgs.addElement(quoteFilename(buf, "cw32.lib")); + } + if (!hasImport32) { + execArgs.addElement(quoteFilename(buf, "import32.lib")); + } if (defFile == null) { execArgs.addElement(",,"); } else { @@ -233,34 +251,6 @@ */ protected String[] prepareResponseFile(File outputFile, String[] args) throws IOException { - String baseName = CUtil.getBasename(outputFile); - File commandFile = new File(outputFile.getParent(), baseName + ".lnk"); - FileWriter writer = new FileWriter(commandFile); - for (int i = 1; i < args.length - 1; i++) { - writer.write(args[i]); - // - // if either the current argument ends with - // or next argument starts with a comma then - // don't split the line - if (args[i].endsWith(",") || args[i + 1].startsWith(",")) { - writer.write(' '); - } else { - // - // split the line to make it more readable - // - writer.write(" + \n"); - } - } - // - // write the last argument - // - if (args.length > 1) { - writer.write(args[args.length - 1]); - } - writer.close(); - String[] execArgs = new String[2]; - execArgs[0] = args[0]; - execArgs[1] = getCommandFileSwitch(commandFile.toString()); - return execArgs; + return BorlandProcessor.prepareResponseFile(outputFile, args, " + \n"); } } Index: src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java,v retrieving revision 1.15 diff -u -r1.15 BorlandProcessor.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java 28 Feb 2004 20:00:01 -0000 1.15 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java 20 Apr 2004 04:07:46 -0000 @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.Reader; import java.util.Vector; +import java.io.FileWriter; import net.sf.antcontrib.cpptasks.CUtil; /** @@ -167,6 +168,51 @@ buf.append(outPath); } } + + /** + * Prepares argument list to execute the linker using a response file. + * + * @param outputFile + * linker output file + * @param args + * output of prepareArguments + * @return arguments for runTask + */ + public static String[] prepareResponseFile(File outputFile, + String[] args, + String continuation) + throws IOException { + String baseName = CUtil.getBasename(outputFile); + File commandFile = new File(outputFile.getParent(), baseName + ".lnk"); + FileWriter writer = new FileWriter(commandFile); + for (int i = 1; i < args.length - 1; i++) { + writer.write(args[i]); + // + // if either the current argument ends with + // or next argument starts with a comma then + // don't split the line + if (args[i].endsWith(",") || args[i + 1].startsWith(",")) { + writer.write(' '); + } else { + // + // split the line to make it more readable + // + writer.write(continuation); + } + } + // + // write the last argument + // + if (args.length > 1) { + writer.write(args[args.length - 1]); + } + writer.close(); + String[] execArgs = new String[2]; + execArgs[0] = args[0]; + execArgs[1] = getCommandFileSwitch(commandFile.toString()); + return execArgs; + } + private BorlandProcessor() { } }