summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2007-07-06 19:06:29 +0000
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2007-07-06 19:06:29 +0000
commit2dac20493cf190fb56f04d1fe22f58c30eac1869 (patch)
treeebbcea6f539fbb3a474217c45502632f0c84289a /src
parent502ee6ac6df5cd8aa19c2c1f9db87861d763ac1b (diff)
downloadcpptasks-parallel-2dac20493cf190fb56f04d1fe22f58c30eac1869.tar.gz
cpptasks-parallel-2dac20493cf190fb56f04d1fe22f58c30eac1869.tar.bz2
cpptasks-parallel-2dac20493cf190fb56f04d1fe22f58c30eac1869.tar.xz
cpptasks-parallel-2dac20493cf190fb56f04d1fe22f58c30eac1869.zip
Fixed NARPLUGIN-106
Diffstat (limited to 'src')
-rw-r--r--src/cpptasks.types2
-rw-r--r--src/net/sf/antcontrib/cpptasks/CCTask.java26
-rw-r--r--src/net/sf/antcontrib/cpptasks/CUtil.java68
-rw-r--r--src/net/sf/antcontrib/cpptasks/CompilerEnum.java22
-rw-r--r--src/net/sf/antcontrib/cpptasks/LinkerDef.java4
-rw-r--r--src/net/sf/antcontrib/cpptasks/LinkerEnum.java17
-rw-r--r--src/net/sf/antcontrib/cpptasks/OutputTypeEnum.java3
-rw-r--r--src/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java8
-rw-r--r--src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java20
-rw-r--r--src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java6
-rw-r--r--src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java5
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java4
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java10
-rw-r--r--src/net/sf/antcontrib/cpptasks/compiler/LinkType.java19
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java3
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java16
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java1106
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java26
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java13
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java13
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java22
-rw-r--r--src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java66
-rw-r--r--src/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java6
-rw-r--r--src/net/sf/antcontrib/cpptasks/ide/ProjectDef.java17
-rw-r--r--src/net/sf/antcontrib/cpptasks/ide/ProjectWriterEnum.java16
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java5
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java2
-rw-r--r--src/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java4
-rw-r--r--src/net/sf/antcontrib/cpptasks/types/LibrarySet.java221
35 files changed, 1129 insertions, 633 deletions
diff --git a/src/cpptasks.types b/src/cpptasks.types
index a14401b..c37c17f 100644
--- a/src/cpptasks.types
+++ b/src/cpptasks.types
@@ -4,3 +4,5 @@ linker=net.sf.antcontrib.cpptasks.LinkerDef
targetplatform=net.sf.antcontrib.cpptasks.TargetDef
versioninfo=net.sf.antcontrib.cpptasks.VersionInfo
distributer=net.sf.antcontrib.cpptasks.DistributerDef
+syslibset=net.sf.antcontrib.cpptasks.types.SystemLibrarySet
+libset=net.sf.antcontrib.cpptasks.types.LibrarySet \ No newline at end of file
diff --git a/src/net/sf/antcontrib/cpptasks/CCTask.java b/src/net/sf/antcontrib/cpptasks/CCTask.java
index 60f7883..c38ba61 100644
--- a/src/net/sf/antcontrib/cpptasks/CCTask.java
+++ b/src/net/sf/antcontrib/cpptasks/CCTask.java
@@ -17,9 +17,11 @@
package net.sf.antcontrib.cpptasks;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.*;
+import java.util.List;
+import java.util.Vector;
import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
import net.sf.antcontrib.cpptasks.compiler.LinkType;
@@ -53,7 +55,7 @@ import org.apache.tools.ant.types.Environment;
*
*
* <p>
- * Copyright (c) 2001-2005, The Ant-Contrib project.
+ * Copyright (c) 2001-2006, The Ant-Contrib project.
* </p>
*
* <p>
@@ -73,9 +75,12 @@ import org.apache.tools.ant.types.Environment;
*
* To use:
* <ol>
- * <li>Place cpptasks.jar into the lib directory of Ant 1.5 or later.</li>
- * <li>Add &lt;taskdef resource="cpptasks.tasks"/&gt; and &lt;typedef
- * resource="cpptasks.types"/&gt; to build.xml.</li>
+ * <li>Place cpptasks.jar into Ant's classpath by placing in Ant's lib directory,
+ * adding to CLASSPATH environment variable or using the -lib command line option.</li>
+ * <li>Add type and task definitions in build file:
+ * <ul><li>Ant 1.6 or later: add xmlns:cpptasks="antlib:org.sf.net.antcontrib.cpptasks" to &lt;project&gt; element.</li>
+ * <li>Ant 1.5 or later: Add &lt;taskdef resource="cpptasks.tasks"/&gt; and &lt;typedef
+ * resource="cpptasks.types"/&gt; to body of &lt;project&gt; element.</li></ul></li>
* <li>Add &lt;cc/&gt;, &lt;compiler/&gt; and &lt;linker/&gt elements to
* project.</li>
* <li>Set path and environment variables to be able to run compiler from
@@ -763,11 +768,10 @@ public class CCTask extends Task {
//
File output = linkTarget.getOutput();
if (linkTarget.getRebuild()) {
- // FREEHEP
-// log("Starting link");
LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget
.getConfiguration();
- log("Starting link ("+linkConfig.getIdentifier()+")");
+// FREEHEP
+ log("Starting link {"+linkConfig.getIdentifier()+"}");
if (failOnError) {
linkConfig.link(this, linkTarget);
} else {
@@ -1073,11 +1077,11 @@ public class CCTask extends Task {
linkType.setOutputType(outputType);
}
-// FREEHEP added method to link with cpp
+// BEGINFREEHEP
public void setLinkCPP(boolean linkCPP) {
- linkType.setLinkCPP(linkCPP);
+ linkType.setLinkCPP(linkCPP);
}
-
+// ENDFREEHEP
/**
* Enables or disables generation of multithreaded code
*
diff --git a/src/net/sf/antcontrib/cpptasks/CUtil.java b/src/net/sf/antcontrib/cpptasks/CUtil.java
index 48fd1d1..2ac18e5 100644
--- a/src/net/sf/antcontrib/cpptasks/CUtil.java
+++ b/src/net/sf/antcontrib/cpptasks/CUtil.java
@@ -171,7 +171,7 @@ public class CUtil {
* Returns a relative path for the targetFile relative to the base
* directory.
*
- * @param canonicalBase
+ * @param base
* base directory as returned by File.getCanonicalPath()
* @param targetFile
* target file
@@ -180,26 +180,25 @@ public class CUtil {
*
* @author Curt Arnold
*/
- public static String getRelativePath(String base, File targetFile) {
+ public static String getRelativePath(final String base, final File targetFile) {
try {
//
// remove trailing file separator
//
String canonicalBase = base;
- if (base.charAt(base.length() - 1) == File.separatorChar) {
- canonicalBase = base.substring(0, base.length() - 1);
+ if (base.charAt(base.length() - 1) != File.separatorChar) {
+ canonicalBase = base + File.separatorChar;
}
//
- // get canonical name of target and remove trailing separator
+ // get canonical name of target
//
String canonicalTarget;
if (System.getProperty("os.name").equals("OS/400"))
canonicalTarget = targetFile.getPath();
else
canonicalTarget = targetFile.getCanonicalPath();
- if (canonicalTarget.charAt(canonicalTarget.length() - 1) == File.separatorChar) {
- canonicalTarget = canonicalTarget.substring(0, canonicalTarget
- .length() - 1);
+ if (canonicalBase.startsWith(canonicalTarget + File.separatorChar)) {
+ canonicalTarget = canonicalTarget + File.separator;
}
if (canonicalTarget.equals(canonicalBase)) {
return ".";
@@ -234,22 +233,20 @@ public class CUtil {
}
}
char separator = File.separatorChar;
- int lastSeparator = -1;
+ int lastCommonSeparator = -1;
int minLength = canonicalBase.length();
if (canonicalTarget.length() < minLength) {
minLength = canonicalTarget.length();
}
- int firstDifference = minLength + 1;
//
// walk to the shorter of the two paths
// finding the last separator they have in common
for (int i = 0; i < minLength; i++) {
if (canonicalTarget.charAt(i) == canonicalBase.charAt(i)) {
if (canonicalTarget.charAt(i) == separator) {
- lastSeparator = i;
+ lastCommonSeparator = i;
}
} else {
- firstDifference = lastSeparator + 1;
break;
}
}
@@ -258,24 +255,19 @@ public class CUtil {
// walk from the first difference to the end of the base
// adding "../" for each separator encountered
//
- if (canonicalBase.length() > firstDifference) {
- relativePath.append("..");
- for (int i = firstDifference; i < canonicalBase.length(); i++) {
- if (canonicalBase.charAt(i) == separator) {
+ for (int i = lastCommonSeparator + 1; i < canonicalBase.length(); i++) {
+ if (canonicalBase.charAt(i) == separator) {
+ if (relativePath.length() > 0) {
relativePath.append(separator);
- relativePath.append("..");
}
+ relativePath.append("..");
}
}
- if (canonicalTarget.length() > firstDifference) {
- //
- // append the rest of the target
- //
- //
+ if (canonicalTarget.length() > lastCommonSeparator + 1) {
if (relativePath.length() > 0) {
relativePath.append(separator);
}
- relativePath.append(canonicalTarget.substring(firstDifference));
+ relativePath.append(canonicalTarget.substring(lastCommonSeparator + 1));
}
return relativePath.toString();
} catch (IOException ex) {
@@ -443,19 +435,27 @@ public class CUtil {
*
*/
public static String xmlAttribEncode(String attrValue) {
- int quotePos = attrValue.indexOf('\"');
- if (quotePos < 0) {
- return attrValue;
+ StringBuffer buf = new StringBuffer (attrValue);
+ int quotePos;
+
+ for (quotePos = -1; (quotePos = buf.indexOf("\"", quotePos + 1)) >= 0;) {
+ buf.deleteCharAt(quotePos);
+ buf.insert (quotePos, "&quot;");
+ quotePos += 5;
+ }
+
+ for (quotePos = -1; (quotePos = buf.indexOf("<", quotePos + 1)) >= 0;) {
+ buf.deleteCharAt(quotePos);
+ buf.insert (quotePos, "&lt;");
+ quotePos += 3;
}
- int startPos = 0;
- StringBuffer buf = new StringBuffer(attrValue.length() + 20);
- while (quotePos >= 0) {
- buf.append(attrValue.substring(startPos, quotePos));
- buf.append("&quot;");
- startPos = quotePos + 1;
- quotePos = attrValue.indexOf('\"', startPos);
+
+ for (quotePos = -1; (quotePos = buf.indexOf(">", quotePos + 1)) >= 0;) {
+ buf.deleteCharAt(quotePos);
+ buf.insert (quotePos, "&gt;");
+ quotePos += 3;
}
- buf.append(attrValue.substring(startPos));
+
return buf.toString();
}
diff --git a/src/net/sf/antcontrib/cpptasks/CompilerEnum.java b/src/net/sf/antcontrib/cpptasks/CompilerEnum.java
index 9bfb35b..fec8e72 100644
--- a/src/net/sf/antcontrib/cpptasks/CompilerEnum.java
+++ b/src/net/sf/antcontrib/cpptasks/CompilerEnum.java
@@ -27,25 +27,23 @@ import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
import net.sf.antcontrib.cpptasks.hp.aCCCompiler;
import net.sf.antcontrib.cpptasks.ibm.VisualAgeCCompiler;
import net.sf.antcontrib.cpptasks.intel.IntelLinux32CCompiler;
-import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler;
-// FREEHEP
import net.sf.antcontrib.cpptasks.intel.IntelLinux32Compiler;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler;
import net.sf.antcontrib.cpptasks.intel.IntelLinux64Compiler;
import net.sf.antcontrib.cpptasks.intel.IntelWin32CCompiler;
import net.sf.antcontrib.cpptasks.intel.IntelWin64CCompiler;
import net.sf.antcontrib.cpptasks.mozilla.XpidlCompiler;
+import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomCCompiler;
+import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomFortranCompiler;
import net.sf.antcontrib.cpptasks.os390.OS390CCompiler;
import net.sf.antcontrib.cpptasks.os400.IccCompiler;
import net.sf.antcontrib.cpptasks.sun.C89CCompiler;
import net.sf.antcontrib.cpptasks.sun.ForteCCCompiler;
-// FREEHEP
import net.sf.antcontrib.cpptasks.sun.ForteCCompiler;
import net.sf.antcontrib.cpptasks.sun.ForteF77Compiler;
import net.sf.antcontrib.cpptasks.ti.ClxxCCompiler;
import net.sf.antcontrib.cpptasks.trolltech.MetaObjectCompiler;
import net.sf.antcontrib.cpptasks.trolltech.UserInterfaceCompiler;
-import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomCCompiler;
-import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomFortranCompiler;
import org.apache.tools.ant.types.EnumeratedAttribute;
/**
@@ -66,11 +64,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
* </tr>
* <tr>
* <td>g77</td>
- * <td>GNU FORTRAN 77 compiler</td>
- * </tr>
- * <tr>
- * <td>gfortran</td>
- * <td>GNU FORTRAN 95 compiler</td>
+ * <td>GNU FORTRAN compiler</td>
* </tr>
* <tr>
* <td>msvc</td>
@@ -190,8 +184,8 @@ public class CompilerEnum extends EnumeratedAttribute {
new ProcessorEnumValue("gcc", GccCCompiler.getInstance()),
new ProcessorEnumValue("g++", GccCCompiler.getGppInstance()),
new ProcessorEnumValue("c++", GccCCompiler.getCppInstance()),
-// FREEHEP
new ProcessorEnumValue("g77", GccCCompiler.getG77Instance()),
+// FREEHEP
new ProcessorEnumValue("gfortran", GccCCompiler.getGFortranInstance()),
new ProcessorEnumValue("msvc", DevStudioCCompiler.getInstance()),
new ProcessorEnumValue("bcc", BorlandCCompiler.getInstance()),
@@ -203,15 +197,17 @@ public class CompilerEnum extends EnumeratedAttribute {
new ProcessorEnumValue("midl", DevStudioMIDLCompiler.getInstance()),
new ProcessorEnumValue("icl", IntelWin32CCompiler.getInstance()),
new ProcessorEnumValue("ecl", IntelWin64CCompiler.getInstance()),
+// BEGINFREEHEP
new ProcessorEnumValue("icc", IntelLinux32CCompiler.getInstance()),
new ProcessorEnumValue("ecc", IntelLinux64CCompiler.getInstance()),
-// FREEHEP
new ProcessorEnumValue("icpc", IntelLinux32Compiler.getInstance()),
new ProcessorEnumValue("ecpc", IntelLinux64Compiler.getInstance()),
+// ENDFREEHEP
new ProcessorEnumValue("CC", ForteCCCompiler.getInstance()),
-// FREEHEP
+// BEGINFREEHEP
new ProcessorEnumValue("suncc", ForteCCompiler.getInstance()),
new ProcessorEnumValue("sunf77", ForteF77Compiler.getInstance()),
+// ENDFREEHEP
new ProcessorEnumValue("aCC", aCCCompiler.getInstance()),
new ProcessorEnumValue("os390", OS390CCompiler.getInstance()),
new ProcessorEnumValue("os400", IccCompiler.getInstance()),
diff --git a/src/net/sf/antcontrib/cpptasks/LinkerDef.java b/src/net/sf/antcontrib/cpptasks/LinkerDef.java
index a9a77bf..af1d307 100644
--- a/src/net/sf/antcontrib/cpptasks/LinkerDef.java
+++ b/src/net/sf/antcontrib/cpptasks/LinkerDef.java
@@ -156,9 +156,11 @@ public class LinkerDef extends ProcessorDef {
Vector libsets = new Vector();
for (int i = index; i < defaultProviders.length; i++) {
defaultProviders[i].addActiveUserLibrarySets(p, libsets);
- defaultProviders[i].addActiveSystemLibrarySets(p, libsets);
}
addActiveUserLibrarySets(p, libsets);
+ for (int i = index; i < defaultProviders.length; i++) {
+ defaultProviders[i].addActiveSystemLibrarySets(p, libsets);
+ }
addActiveSystemLibrarySets(p, libsets);
LibrarySet[] sets = new LibrarySet[libsets.size()];
libsets.copyInto(sets);
diff --git a/src/net/sf/antcontrib/cpptasks/LinkerEnum.java b/src/net/sf/antcontrib/cpptasks/LinkerEnum.java
index c5b47bc..90ee7ca 100644
--- a/src/net/sf/antcontrib/cpptasks/LinkerEnum.java
+++ b/src/net/sf/antcontrib/cpptasks/LinkerEnum.java
@@ -26,20 +26,20 @@ import net.sf.antcontrib.cpptasks.gcc.GppLinker;
import net.sf.antcontrib.cpptasks.gcc.LdLinker;
import net.sf.antcontrib.cpptasks.hp.aCCLinker;
import net.sf.antcontrib.cpptasks.ibm.VisualAgeLinker;
-// FREEHEP
-import net.sf.antcontrib.cpptasks.intel.IntelLinux32CLinker;
-import net.sf.antcontrib.cpptasks.intel.IntelLinux64CLinker;
import net.sf.antcontrib.cpptasks.intel.IntelLinux32Linker;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux32CLinker;
import net.sf.antcontrib.cpptasks.intel.IntelLinux64Linker;
+import net.sf.antcontrib.cpptasks.intel.IntelLinux64CLinker;
import net.sf.antcontrib.cpptasks.intel.IntelWin32Linker;
+import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomCLinker;
+import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomFortranLinker;
import net.sf.antcontrib.cpptasks.os390.OS390Linker;
import net.sf.antcontrib.cpptasks.os400.IccLinker;
import net.sf.antcontrib.cpptasks.sun.C89Linker;
import net.sf.antcontrib.cpptasks.sun.ForteCCLinker;
import net.sf.antcontrib.cpptasks.ti.ClxxLinker;
+
import org.apache.tools.ant.types.EnumeratedAttribute;
-import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomCLinker;
-import net.sf.antcontrib.cpptasks.openwatcom.OpenWatcomFortranLinker;
/**
* Enumeration of supported linkers
@@ -59,11 +59,12 @@ public class LinkerEnum extends EnumeratedAttribute {
.getInstance()),
new ProcessorEnumValue("icl", IntelWin32Linker.getInstance()),
new ProcessorEnumValue("ecl", IntelWin32Linker.getInstance()),
- new ProcessorEnumValue("icc", IntelLinux32Linker.getInstance()),
- new ProcessorEnumValue("ecc", IntelLinux64Linker.getInstance()),
-// FREEHEP
+// BEGINFREEHEP
+ new ProcessorEnumValue("icc", IntelLinux32CLinker.getInstance()),
+ new ProcessorEnumValue("ecc", IntelLinux64CLinker.getInstance()),
new ProcessorEnumValue("icpc", IntelLinux32Linker.getInstance()),
new ProcessorEnumValue("ecpc", IntelLinux64Linker.getInstance()),
+// ENDFREEHEP
new ProcessorEnumValue("CC", ForteCCLinker.getInstance()),
new ProcessorEnumValue("aCC", aCCLinker.getInstance()),
new ProcessorEnumValue("os390", OS390Linker.getInstance()),
diff --git a/src/net/sf/antcontrib/cpptasks/OutputTypeEnum.java b/src/net/sf/antcontrib/cpptasks/OutputTypeEnum.java
index 471ae82..62941b8 100644
--- a/src/net/sf/antcontrib/cpptasks/OutputTypeEnum.java
+++ b/src/net/sf/antcontrib/cpptasks/OutputTypeEnum.java
@@ -43,7 +43,8 @@ public class OutputTypeEnum extends EnumeratedAttribute {
"plugin", // plugin module
"shared", // dynamically linkable module
"static", // convenience library
- "jni" // FREEHEP Java Native Interface library
+// FREEHEP
+ "jni" // jni module
};
}
}
diff --git a/src/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java b/src/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
index 15c4f7e..c7e12d5 100644
--- a/src/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
@@ -27,12 +27,12 @@ import net.sf.antcontrib.cpptasks.compiler.Linker;
import org.apache.tools.ant.types.Environment;
/**
* Adapter for the ARM C Compilers
- *
+ *
* See Doc No: ARM DUI 0151A, Issued: Nov 2001 at
* http://www.arm.com/arm/User_Guides?OpenDocument
- *
+ *
* @author Curt Arnold
- *
+ *
*/
public class ADSCCompiler extends CommandLineCCompiler {
/**
@@ -80,7 +80,7 @@ public class ADSCCompiler extends CommandLineCCompiler {
* Singleton for ARM 16-bit C compiler
*/
public static ADSCCompiler getThumbCC() {
- return tcpp;
+ return tcc;
}
/**
* Singleton for ARM 16-bit C++ compiler
diff --git a/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java b/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
index 1b13e54..6ec9212 100644
--- a/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/borland/BorlandLibrarian.java
@@ -61,17 +61,11 @@ public class BorlandLibrarian extends CommandLineLinker {
}
protected String getCommandFileSwitch(String cmdFile) {
-
//
-
// tlib requires quotes around paths containing -
-
// ilink32 doesn't like them
-
StringBuffer buf = new StringBuffer("@");
-
BorlandProcessor.quoteFile(buf, cmdFile);
-
return buf.toString();
}
public File[] getLibraryPath() {
@@ -189,9 +183,7 @@ public class BorlandLibrarian extends CommandLineLinker {
throws IOException {
String[] cmdargs = BorlandProcessor.prepareResponseFile(outputFile, args, " & \n");
cmdargs[cmdargs.length - 1] = getCommandFileSwitch(cmdargs[cmdargs.length -1]);
-
return cmdargs;
-
}
/**
@@ -212,28 +204,16 @@ public class BorlandLibrarian extends CommandLineLinker {
super.link(task, outputFile, sourceFiles, config);
}
-
/**
-
* Encloses problematic file names within quotes.
-
* @param buf string buffer
-
* @param filename source file name
-
* @returns filename potentially enclosed in quotes.
-
*/
-
protected String quoteFilename(StringBuffer buf,String filename) {
-
buf.setLength(0);
-
BorlandProcessor.quoteFile(buf, filename);
-
return buf.toString();
-
}
-
}
diff --git a/src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java b/src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java
index 3dfef2d..6143bda 100644
--- a/src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java
+++ b/src/net/sf/antcontrib/cpptasks/borland/BorlandProcessor.java
@@ -23,7 +23,6 @@ import java.io.Reader;
import java.util.Vector;
import java.io.FileWriter;
-
import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
/**
@@ -158,11 +157,8 @@ public final class BorlandProcessor {
}
public static void quoteFile(StringBuffer buf, String outPath) {
if (outPath.charAt(0) != '\"'
-
&& (outPath.indexOf(' ') >= 0
-
|| outPath.indexOf('-') >= 0
-
|| outPath.indexOf('/') >= 0)) {
buf.append('\"');
buf.append(outPath);
@@ -212,9 +208,7 @@ public final class BorlandProcessor {
writer.close();
String[] execArgs = new String[2];
execArgs[0] = args[0];
-
//
-
// left for the caller to decorate
execArgs[1] = commandFile.toString();
return execArgs;
diff --git a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java
index fc4c4ce..ca3c3e3 100644
--- a/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java
@@ -115,7 +115,7 @@ public class CompaqVisualFortranCompiler extends CommandLineFortranCompiler {
}
protected String getIncludeDirSwitch(String includeDir) {
StringBuffer buf = new StringBuffer("/include:");
-// FREEHEP: quotes seems to confuse the compiler.
+// BEGINFREEHEP quotes seem to confuse the compiler
// if (includeDir.indexOf(' ') >= 0) {
// buf.append('"');
// buf.append(includeDir);
@@ -123,7 +123,8 @@ public class CompaqVisualFortranCompiler extends CommandLineFortranCompiler {
// } else {
buf.append(includeDir);
// }
- return buf.toString();
+// ENDFREEHEP
+ return buf.toString();
}
public Linker getLinker(LinkType type) {
return CompaqVisualFortranLinker.getInstance().getLinker(type);
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java b/src/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java
index 1412eee..f58ed8e 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+// BEGINFREEHEP, fully replaced with a runner with threads
package net.sf.antcontrib.cpptasks.compiler;
import java.io.BufferedReader;
@@ -97,7 +98,7 @@ public class CaptureStreamHandler implements ExecuteStreamHandler {
/**
* Reads concurrently both the process standard output and standard error.
* The standard error - if not empty - is copied to the output string array field. Otherwise
- * the stanard output is copied to the output field. The output field is set to an empty array
+ * the standard output is copied to the output field. The output field is set to an empty array
* in case of any error.
*/
public void gatherOutput() {
@@ -163,4 +164,5 @@ public class CaptureStreamHandler implements ExecuteStreamHandler {
*/
public void stop() {
}
+// ENDFREEHEP
}
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
index 77d8df5..96d85c0 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java
@@ -145,10 +145,10 @@ public abstract class CommandLineLinker extends AbstractLinker
String[] libnames = null;
LibrarySet[] libsets = specificDef.getActiveLibrarySets(defaultProviders,1);
- // FREEHEP: check if runtime was added without any present libs
- if (linkType.callAddLibrarySets || (libsets.length > 0)) {
+// FREEHEP call at all times
+// if (libsets.length > 0) {
libnames = addLibrarySets(task, libsets, preargs, midargs, endargs);
- }
+// }
StringBuffer buf = new StringBuffer(getIdentifier());
for (int i = 0; i < 3; i++) {
@@ -256,7 +256,7 @@ public abstract class CommandLineLinker extends AbstractLinker
//
// if command length exceeds maximum
- // (1024 for Windows) then create a temporary
+ // then create a temporary
// file containing everything but the command name
if(commandLength >= this.getMaximumCommandLength()) {
try {
@@ -336,7 +336,7 @@ public abstract class CommandLineLinker extends AbstractLinker
String outputDir, String sourceFile) {
String relativePath = CUtil.getRelativePath(outputDir,
new File(sourceFile));
- // FREEHEP - take the shortest of the two (Windows file length limitation)
+// FREEHEP, return the shortest
return quoteFilename(buf, sourceFile.length() > relativePath.length() ? relativePath : sourceFile);
}
diff --git a/src/net/sf/antcontrib/cpptasks/compiler/LinkType.java b/src/net/sf/antcontrib/cpptasks/compiler/LinkType.java
index 2ab5380..2b887ab 100644
--- a/src/net/sf/antcontrib/cpptasks/compiler/LinkType.java
+++ b/src/net/sf/antcontrib/cpptasks/compiler/LinkType.java
@@ -27,9 +27,10 @@ public class LinkType {
private OutputTypeEnum outputType = new OutputTypeEnum();
private boolean staticRuntime = false;
private SubsystemEnum subsystem = new SubsystemEnum();
+
// FREEHEP
private boolean linkCPP = true;
-
+
/**
* Constructor
*
@@ -47,12 +48,11 @@ public class LinkType {
String value = outputType.getValue();
return value.equals("executable");
}
-// FREEHEP
+
public boolean isJNIModule() {
String value = outputType.getValue();
- return value.equals("jni");
+ return value.equals("jni");
}
-
/**
* Gets whether the link should produce a plugin module.
*
@@ -158,15 +158,16 @@ public class LinkType {
public String getSubsystem() {
return subsystem.getValue();
}
-
+
+// BEGINFREEHEP
public void setLinkCPP(boolean linkCPP) {
- this.linkCPP = linkCPP;
+ this.linkCPP = linkCPP;
}
public boolean linkCPP() {
- return linkCPP;
+ return linkCPP;
}
+
+// ENDFREEHEP
- // FREEHEP: flag
- public boolean callAddLibrarySets = false;
}
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java
index 6b6c5b5..1281046 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java
@@ -45,6 +45,6 @@ public final class DevStudioCCompiler extends DevStudioCompatibleCCompiler {
return DevStudioLinker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
}
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java
index 0ac4f77..2502799 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java
@@ -58,7 +58,8 @@ public abstract class DevStudioCompatibleCCompiler
args.addElement("/c");
args.addElement("/nologo");
if (exceptions) {
- // FREEHEP changed /GX into /EHsc (for VC8, and backward compatible with VC7 and VC6)
+ // changed to eliminate warning on VC 2005, should support VC 6 and later
+ // use /GX to support VC5 - 2005 (with warning)
args.addElement("/EHsc");
}
int mindex = 0;
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
index a5e4b41..985dfcf 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java
@@ -61,7 +61,7 @@ public abstract class DevStudioCompatibleLibrarian extends CommandLineLinker {
return new String[0];
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
public String[] getOutputFileSwitch(String outFile) {
StringBuffer buf = new StringBuffer("/OUT:");
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
index 8b8e8a6..c21a6f6 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
@@ -63,12 +63,14 @@ public abstract class DevStudioCompatibleLinker extends CommandLineLinker {
if (linkType.isSharedLibrary()) {
args.addElement("/DLL");
}
- /*
- * if(linkType.isSubsystemGUI()) {
- * args.addElement("/SUBSYSTEM:WINDOWS"); } else {
- * if(linkType.isSubsystemConsole()) {
- * args.addElement("/SUBSYSTEM:CONSOLE"); } }
- */
+ //
+ // The following lines were commented out
+ // from v 1.5 to v 1.12 with no explanation
+ //
+ if(linkType.isSubsystemGUI()) {
+ args.addElement("/SUBSYSTEM:WINDOWS"); } else {
+ if(linkType.isSubsystemConsole()) {
+ args.addElement("/SUBSYSTEM:CONSOLE"); } }
}
protected void addIncremental(boolean incremental, Vector args) {
if (incremental) {
@@ -115,7 +117,7 @@ public abstract class DevStudioCompatibleLinker extends CommandLineLinker {
return patterns;
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
public String[] getOutputFileSwitch(String outputFile) {
return new String[]{"/OUT:" + outputFile};
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
index 4a7463d..fa2e414 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
@@ -94,7 +94,7 @@ public final class DevStudioMIDLCompiler extends CommandLineCompiler {
return DevStudioLinker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
protected int getMaximumInputFilesPerCommand() {
return 1;
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
index e8c8662..6f8360b 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
@@ -99,7 +99,7 @@ public final class DevStudioResourceCompiler extends CommandLineCompiler {
return DevStudioLinker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
protected int getMaximumInputFilesPerCommand() {
return 1;
diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java b/src/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java
index 9e6072c..898503e 100644
--- a/src/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java
+++ b/src/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2004-2005 The Ant-Contrib project
+ * Copyright 2004-2006 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.
@@ -16,25 +16,14 @@
*/
package net.sf.antcontrib.cpptasks.devstudio;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.TargetInfo;
import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
-import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
import net.sf.antcontrib.cpptasks.ide.ProjectDef;
import net.sf.antcontrib.cpptasks.ide.ProjectWriter;
-
import org.apache.tools.ant.BuildException;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.Serializer;
@@ -43,367 +32,806 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
/**
* Writes a Visual Studio.NET project file.
- * (Visual Studio 5 and 6 project writer is substantially more
-* complete at this point).
- * @author curta
*
+ * @author curta
*/
public final class VisualStudioNETProjectWriter
- implements ProjectWriter {
- /**
- * Version of VisualStudio.NET.
- */
- private String version;
-
- /**
- * Constructor.
- * @param versionArg String VisualStudio.NET version
- */
- public VisualStudioNETProjectWriter(final String versionArg) {
- this.version = versionArg;
- }
+ implements ProjectWriter {
+ /**
+ * Version of VisualStudio.NET.
+ */
+ private final String version;
+
+ /**
+ * Literal to represent a true value.
+ */
+ private final String trueLiteral;
+
+ /**
+ * Literal to represent a false value.
+ */
+ private final String falseLiteral;
+
+ /**
+ * Constructor.
+ *
+ * @param versionArg String VisualStudio.NET version
+ * @param trueArg literal to represent true, "true" in VC 2005.
+ * @param falseArg literal to represent false, "false" in VC 2005.
+ */
+ public VisualStudioNETProjectWriter(final String versionArg,
+ final String trueArg,
+ final String falseArg) {
+ if (versionArg == null) {
+ throw new IllegalArgumentException("versionArg");
+ }
+ if (trueArg == null) {
+ throw new IllegalArgumentException("trueArg");
+ }
+ if (falseArg == null) {
+ throw new IllegalArgumentException("falseArg");
+ }
+ this.version = versionArg;
+ this.trueLiteral = trueArg;
+ this.falseLiteral = falseArg;
+ }
+
+ /**
+ * Get configuration name.
+ * @param task cc task, may not be null.
+ * @return configuration name.
+ */
+ private String getConfigurationName(final CCTask task) {
+ if (task.getDebug()) {
+ return "Debug|Win32";
+ }
+ return "Release|Win32";
+ }
+
+ /**
+ * Gets the configuration type.
+ *
+ * @param task cc task, may not be null.
+ * @return configuration type
+ */
+ private String getConfigurationType(final CCTask task) {
+ String outputType = task.getOuttype();
+ String targtype = "2"; // Win32 (x86) Dynamic-Link Library";
+ if ("executable".equals(outputType)) {
+ targtype = "1"; // "Win32 (x86) Console Application";
+ } else if ("static".equals(outputType)) {
+ targtype = "4"; //"Win32 (x86) Static Library";
+ }
+ return targtype;
+ }
- /**
- * Writes a project definition file.
- *
- * @param fileName
- * project name for file, should has .cbx extension
- * @param task
- * cc task for which to write project
- * @param projectDef
- * project element
- * @param sources source files
- * @param targets compilation targets
- * @param linkTarget link target
- * @throws IOException if I/O error
- * @throws SAXException if XML serialization error
- */
- public void writeProject(final File fileName,
- final CCTask task,
- final ProjectDef projectDef,
- final List sources,
- final Hashtable targets,
- final TargetInfo linkTarget) throws
- IOException,
- SAXException {
-
- boolean isDebug = task.getDebug();
-
- String projectName = projectDef.getName();
- if (projectName == null) {
- projectName = fileName.getName();
+ /**
+ * Get output directory.
+ * @param basePath path to parent of project file.
+ * @param task cc task, may not be null.
+ * @return output directory relative path.
+ */
+ private String getOutputDirectory(final String basePath,
+ final CCTask task) {
+ File outFile = task.getOutfile();
+ File buildDir = outFile.getParentFile();
+ return CUtil.getRelativePath(basePath, buildDir);
+ }
+
+ /**
+ * Get object file directory.
+ * @param basePath path to parent of project file.
+ * @param task cc task, may not be null.
+ * @return object file directory relative path.
+ */
+ private String getIntermediateDirectory(final String basePath,
+ final CCTask task) {
+ File objDir = task.getObjdir();
+ return CUtil.getRelativePath(basePath, objDir);
}
- File dspFile = new File(fileName + ".dsp");
- if (!projectDef.getOverwrite() && dspFile.exists()) {
- throw new BuildException("Not allowed to overwrite project file "
- + dspFile.toString());
+ /**
+ * Get character set for Windows API.
+ * @param compilerConfig compiler configuration, may not be null.
+ * @return "1" is TCHAR is unicode, "0" if TCHAR is multi-byte.
+ */
+ private String getCharacterSet(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String[] args = compilerConfig.getPreArguments();
+ String charset = "0";
+ for (int i = 0; i < args.length; i++) {
+ if ("/D_UNICODE".equals(args[i]) || "/DUNICODE".equals(args[i])) {
+ charset = "1";
+ }
+ if ("/D_MBCS".equals(args[i])) {
+ charset = "2";
+ }
+ }
+ return charset;
}
- File dswFile = new File(fileName + ".dsw");
- if (!projectDef.getOverwrite() && dswFile.exists()) {
- throw new BuildException("Not allowed to overwrite project file "
- + dswFile.toString());
- }
-
- CommandLineCompilerConfiguration compilerConfig =
- getBaseCompilerConfiguration(targets);
- if (compilerConfig == null) {
- throw new BuildException(
- "Unable to generate Visual Studio.NET project "
- + "when Microsoft C++ is not used.");
+
+ /**
+ * Write the start tag of the Configuration element.
+ * @param content serialization content handler.
+ * @param basePath path of directory containing project file.
+ * @param task cc task.
+ * @param compilerConfig compiler configuration.
+ * @throws SAXException thrown if serialization error.
+ */
+ private void writeConfigurationStartTag(final ContentHandler content,
+ final String basePath,
+ final CCTask task,
+ final CommandLineCompilerConfiguration compilerConfig)
+ throws SAXException {
+ AttributesImpl attributes = new AttributesImpl();
+ addAttribute(attributes, "Name",
+ getConfigurationName(task));
+ addAttribute(attributes, "OutputDirectory",
+ getOutputDirectory(basePath, task));
+ addAttribute(attributes, "IntermediateDirectory",
+ getIntermediateDirectory(basePath, task));
+ addAttribute(attributes, "ConfigurationType",
+ getConfigurationType(task));
+ addAttribute(attributes, "CharacterSet",
+ getCharacterSet(compilerConfig));
+ content.startElement(null,
+ "Configuration", "Configuration", attributes);
+ }
+
+ /**
+ * Get value of Optimization property.
+ * @param compilerConfig compiler configuration, may not be null.
+ * @return value of Optimization property.
+ */
+ private String getOptimization(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String[] args = compilerConfig.getPreArguments();
+ String opt = "0";
+ for (int i = 0; i < args.length; i++) {
+ if ("/Od".equals(args[i])) {
+ opt = "0";
+ }
+ if ("/O1".equals(args[i])) {
+ opt = "1";
+ }
+ if ("/O2".equals(args[i])) {
+ opt = "2";
+ }
+ if ("/Ox".equals(args[i])) {
+ opt = "3";
+ }
+ }
+ return opt;
}
- OutputStream outStream = new FileOutputStream(fileName + ".vcproj");
- OutputFormat format = new OutputFormat("xml", "UTF-8", true);
- Serializer serializer = new XMLSerializer(outStream, format);
- ContentHandler content = serializer.asContentHandler();
- String basePath = fileName.getParentFile().getAbsolutePath();
- content.startDocument();
- AttributesImpl emptyAttrs = new AttributesImpl();
- startElement(content, "VisualStudioProject", new String[] {"ProjectType",
- "Version", "Name", "SccProjectName", "SccLocalPath"}
- ,
- new String[] {"Visual C++", this.version, projectName,
- "", ""});
- content.startElement(null, "Platforms", "Platforms", emptyAttrs);
- startElement(content, "Platform", new String[] {"Name"}
- , new String[] {"Win32"});
- content.endElement(null, "Platform", "Platform");
- content.endElement(null, "Platforms", "Platforms");
- content.startElement(null, "Configurations", "Configurations", emptyAttrs);
-
- String[] configValues = new String[] {
- "Debug|Win32",
- ".\\Debug",
- ".\\Debug",
- "2",
- "0",
- "FALSE"};
- if (!isDebug) {
- configValues[0] = "Release|Win32";
+ /**
+ * Get value of AdditionalIncludeDirectories property.
+ * @param compilerConfig compiler configuration.
+ * @return value of AdditionalIncludeDirectories property.
+ */
+ private String getAdditionalIncludeDirectories(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ StringBuffer includeDirs = new StringBuffer();
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("/I")) {
+ includeDirs.append(args[i].substring(2));
+ includeDirs.append(';');
+ }
+ }
+
+ if (includeDirs.length() > 0) {
+ includeDirs.setLength(includeDirs.length() - 1);
+ }
+ return includeDirs.toString();
}
- startElement(content, "Configuration",
- new String[] {"Name", "OutputDirectory",
- "IntermediateDirectory", "ConfigurationType", "UseOfMFC",
- "ATLMinimizeCRunTimeLibraryUsage"}
- , configValues);
- String[] clValues = new String[] {
- "VCCLCompilerTool", "0", null, null,
- "1", "2", ".\\Debug\\testdllproh.pch", ".\\Debug/",
- ".\\Debug/", ".\\Debug/", "3", "TRUE", "4"};
- StringBuffer includeDirs = new StringBuffer();
- StringBuffer defines = new StringBuffer();
- String[] args = compilerConfig.getPreArguments();
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("/I")) {
- includeDirs.append(args[i].substring(2));
- includeDirs.append(';');
- }
- if (args[i].startsWith("/D")) {
- defines.append(args[i].substring(2));
- defines.append(";");
- }
+ /**
+ * Get value of PreprocessorDefinitions property.
+ * @param compilerConfig compiler configuration.
+ * @return value of PreprocessorDefinitions property.
+ */
+ private String getPreprocessorDefinitions(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ StringBuffer defines = new StringBuffer();
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("/D")) {
+ defines.append(args[i].substring(2));
+ defines.append(";");
+ }
+ }
+
+ if (defines.length() > 0) {
+ defines.setLength(defines.length() - 1);
+ }
+ return defines.toString();
}
- if (includeDirs.length() > 0) {
- includeDirs.setLength(includeDirs.length() - 1);
+ /**
+ * Get value of RuntimeLibrary property.
+ * @param compilerConfig compiler configuration.
+ * @return value of RuntimeLibrary property.
+ */
+ private String getRuntimeLibrary(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String rtl = null;
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/MT".equals(args[i])) {
+ rtl = "0";
+ }
+ if ("/MTd".equals(args[i])) {
+ rtl = "1";
+ }
+ if ("/MD".equals(args[i])) {
+ rtl = "2";
+ }
+ if ("/MDd".equals(args[i])) {
+ rtl = "3";
+ }
+ }
+ return rtl;
}
- if (defines.length() > 0) {
- defines.setLength(defines.length() - 1);
+
+ /**
+ * Get value of UsePrecompiledHeader property.
+ * @param compilerConfig compiler configuration.
+ * @return value of UsePrecompiledHeader property.
+ */
+ private String getUsePrecompiledHeader(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String usePCH = "0";
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/Yc".equals(args[i])) {
+ usePCH = "1";
+ }
+ if ("/Yu".equals(args[i])) {
+ usePCH = "2";
+ }
+ }
+ return usePCH;
}
- clValues[2] = includeDirs.toString();
- clValues[3] = defines.toString();
-
- startElement(content, "Tool",
- new String[] {"Name", "Optimization",
- "AdditionalIncludeDirectories",
- "PreprocessorDefinitions", "RuntimeLibrary",
- "UsePrecompiledHeaders", "PrecompiledHeaderFile",
- "AssemblerListingLocation", "ObjectFile", "WarningLevel",
- "SuppressStartupBanner", "DebugInformationFormat"}
- , clValues);
- content.endElement(null, "Tool", "Tool");
-
-
- String[] linkerValues = new String[] {"VCLinkerTool", null,
- ".\\Debug/testdllproj.dll", "1",
- "TRUE", "TRUE", ".\\Debug\\testdllproh.pdb", "2",
- ".\\Debug/testdllproj.lib", "1"};
-
- if (!isDebug) {
- linkerValues[5] = "FALSE";
+
+ /**
+ * Get value of PrecompiledHeaderFile property.
+ * @param compilerConfig compiler configuration.
+ * @return value of PrecompiledHeaderFile property.
+ */
+ private String getPrecompiledHeaderFile(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String pch = null;
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("/Fp")) {
+ pch = args[i].substring(3);
+ }
+ }
+ return pch;
}
- ProcessorConfiguration config = linkTarget.getConfiguration();
- if (config instanceof CommandLineLinkerConfiguration) {
- CommandLineLinkerConfiguration linkConfig =
- (CommandLineLinkerConfiguration) config;
- File[] linkSources = linkTarget.getAllSources();
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < linkSources.length; i++) {
- //
- // if file was not compiled or otherwise generated
- //
- if (targets.get(linkSources[i].getName()) == null) {
- String relPath = CUtil.getRelativePath(basePath, linkSources[i]);
+ /**
+ * Get value of MinimalRebuild property.
+ * @param compilerConfig compiler configuration.
+ * @return value of MinimalRebuild property.
+ */
+ private String getMinimalRebuild(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ return trueLiteral;
+ }
+
+ /**
+ * Get value of BasicRuntimeChecks property.
+ * @param compilerConfig compiler configuration.
+ * @return value of BasicRuntimeChecks property.
+ */
+ private String getBasicRuntimeChecks(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String checks = "0";
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/RTCs".equals(args[i])) {
+ checks = "1";
+ }
+ if ("/RTCu".equals(args[i])) {
+ checks = "2";
+ }
+ if ("/RTC1".equals(args[i]) || "/GZ".equals(args[i])) {
+ checks = "3";
+ }
+ }
+ return checks;
+ }
+
+ /**
+ * Get value of WarningLevel property.
+ * @param compilerConfig compiler configuration.
+ * @return value of WarningLevel property.
+ */
+ private String getWarningLevel(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String warn = null;
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/W0".equals(args[i])) {
+ warn = "0";
+ }
+ if ("/W1".equals(args[i])) {
+ warn = "1";
+ }
+ if ("/W2".equals(args[i])) {
+ warn = "2";
+ }
+ if ("/W3".equals(args[i])) {
+ warn = "3";
+ }
+ }
+ return warn;
+ }
+
+ /**
+ * Get value of Detect64BitPortabilityProblems property.
+ * @param compilerConfig compiler configuration.
+ * @return value of Detect64BitPortabilityProblems property.
+ */
+ private String getDetect64BitPortabilityProblems(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String warn64 = null;
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/Wp64".equals(args[i])) {
+ warn64 = trueLiteral;
+ }
+ }
+ return warn64;
+ }
+
+ /**
+ * Get value of DebugInformationFormat property.
+ * @param compilerConfig compiler configuration.
+ * @return value of DebugInformationFormat property.
+ */
+ private String getDebugInformationFormat(
+ final CommandLineCompilerConfiguration compilerConfig) {
+ String format = "0";
+ String[] args = compilerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/Z7".equals(args[i])) {
+ format = "1";
+ }
+ if ("/Zi".equals(args[i])) {
+ format = "3";
+ }
+ if ("/ZI".equals(args[i])) {
+ format = "4";
+ }
+ }
+ return format;
+ }
+
+ /**
+ * write the Compiler element.
+ * @param content serialization content handler.
+ * @param compilerConfig compiler configuration.
+ * @throws SAXException thrown if error during serialization.
+ */
+ private void writeCompilerElement(final ContentHandler content,
+ final CommandLineCompilerConfiguration compilerConfig)
+ throws SAXException {
+ AttributesImpl attributes = new AttributesImpl();
+ addAttribute(attributes, "Name", "VCCLCompilerTool");
+ addAttribute(attributes, "Optimization",
+ getOptimization(compilerConfig));
+ addAttribute(attributes, "AdditionalIncludeDirectories",
+ getAdditionalIncludeDirectories(compilerConfig));
+ addAttribute(attributes, "PreprocessorDefinitions",
+ getPreprocessorDefinitions(compilerConfig));
+ addAttribute(attributes, "MinimalRebuild",
+ getMinimalRebuild(compilerConfig));
+ addAttribute(attributes, "BasicRuntimeChecks",
+ getBasicRuntimeChecks(compilerConfig));
+ addAttribute(attributes, "RuntimeLibrary",
+ getRuntimeLibrary(compilerConfig));
+ addAttribute(attributes, "UsePrecompiledHeader",
+ getUsePrecompiledHeader(compilerConfig));
+ addAttribute(attributes, "PrecompiledHeaderFile",
+ getPrecompiledHeaderFile(compilerConfig));
+ addAttribute(attributes, "WarningLevel",
+ getWarningLevel(compilerConfig));
+ addAttribute(attributes, "Detect64BitPortabilityProblems",
+ getDetect64BitPortabilityProblems(compilerConfig));
+ addAttribute(attributes, "DebugInformationFormat",
+ getDebugInformationFormat(compilerConfig));
+ content.startElement(null, "Tool", "Tool", attributes);
+ content.endElement(null, "Tool", "Tool");
+
+ }
+
+
+ /**
+ * Get value of LinkIncremental property.
+ * @param linkerConfig linker configuration.
+ * @return value of LinkIncremental property
+ */
+ private String getLinkIncremental(
+ final CommandLineLinkerConfiguration linkerConfig) {
+ String incremental = "0";
+ String[] args = linkerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/INCREMENTAL:NO".equals(args[i])) {
+ incremental = "1";
+ }
+ if ("/INCREMENTAL:YES".equals(args[i])) {
+ incremental = "2";
+ }
+ }
+ return incremental;
+ }
+
+ /**
+ * Get value of GenerateDebugInformation property.
+ * @param linkerConfig linker configuration.
+ * @return value of GenerateDebugInformation property
+ */
+ private String getGenerateDebugInformation(
+ final CommandLineLinkerConfiguration linkerConfig) {
+ String debug = falseLiteral;
+ String[] args = linkerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/DEBUG".equals(args[i])) {
+ debug = trueLiteral;
+ }
+ }
+ return debug;
+ }
+
+ /**
+ * Get value of Subsystem property.
+ * @param linkerConfig linker configuration.
+ * @return value of Subsystem property
+ */
+ private String getSubsystem(
+ final CommandLineLinkerConfiguration linkerConfig) {
+ String subsystem = "0";
+ String[] args = linkerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/SUBSYSTEM:CONSOLE".equals(args[i])) {
+ subsystem = "1";
+ }
+ if ("/SUBSYSTEM:WINDOWS".equals(args[i])) {
+ subsystem = "2";
+ }
+ if ("/SUBSYSTEM:WINDOWSCE".equals(args[i])) {
+ subsystem = "9";
+ }
+ }
+ return subsystem;
+ }
+
+ /**
+ * Get value of TargetMachine property.
+ * @param linkerConfig linker configuration.
+ * @return value of TargetMachine property
+ */
+ private String getTargetMachine(
+ final CommandLineLinkerConfiguration linkerConfig) {
+ String subsystem = "0";
+ String[] args = linkerConfig.getPreArguments();
+ for (int i = 0; i < args.length; i++) {
+ if ("/MACHINE:X86".equals(args[i])) {
+ subsystem = "1";
+ }
+ }
+ return subsystem;
+ }
+
+ /**
+ * Get value of AdditionalDependencies property.
+ * @param linkTarget link target.
+ * @param targets all targets.
+ * @param basePath path to directory containing project file.
+ * @return value of AdditionalDependencies property.
+ */
+ private String getAdditionalDependencies(final TargetInfo linkTarget,
+ final Map targets,
+ final String basePath) {
+ String dependencies = null;
+ File[] linkSources = linkTarget.getAllSources();
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < linkSources.length; i++) {
+ //
+ // if file was not compiled or otherwise generated
//
- // if path has an embedded space then
- // must quote
- if (relPath.indexOf(' ') > 0) {
- buf.append('\"');
- buf.append(relPath);
- buf.append('\"');
- } else {
- buf.append(relPath);
+ if (targets.get(linkSources[i].getName()) == null) {
+ String relPath = CUtil.getRelativePath(basePath, linkSources[i]);
+ //
+ // if path has an embedded space then
+ // must quote
+ if (relPath.indexOf(' ') > 0) {
+ buf.append('\"');
+ buf.append(relPath);
+ buf.append('\"');
+ } else {
+ buf.append(relPath);
+ }
+ buf.append(';');
}
- buf.append(';');
}
- }
- if (buf.length() > 0) {
- buf.setLength(buf.length() - 1);
- linkerValues[1] = buf.toString();
- }
+ if (buf.length() > 0) {
+ buf.setLength(buf.length() - 1);
+ dependencies = buf.toString();
+ }
+ return dependencies;
+
}
- startElement(content, "Tool",
- new String[] {"Name",
- "AdditionalDependencies",
- "OutputFile",
- "LinkIncremental",
- "SuppressStartupBanner",
- "GenerateDebugInformation",
- "ProgramDatabaseFile",
- "SubSystem",
- "ImportLibrary",
- "TargetMachine"}
- , linkerValues);
- content.endElement(null, "Tool", "Tool");
- content.endElement(null, "Configuration", "Configuration");
- content.endElement(null, "Configurations", "Configurations");
- content.startElement(null, "References", "References", emptyAttrs);
- content.endElement(null, "References", "References");
- content.startElement(null, "Files", "Files", emptyAttrs);
-
-
- File[] sortedSources = new File[sources.size()];
- sources.toArray(sortedSources);
- Arrays.sort(sortedSources, new Comparator() {
- public int compare(final Object o1, final Object o2) {
- return ((File) o1).getName().compareTo(((File) o2).getName());
- }
- });
-
- writeFilteredSources("Source Files",
- "cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx",
- basePath, sortedSources, content);
-
- writeFilteredSources("Header Files", "h;hpp;hxx;hm;inl;inc;xsd",
- basePath, sortedSources, content);
-
- writeFilteredSources("Resource Files",
- "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx",
- basePath, sortedSources, content);
-
- content.endElement(null, "Files", "Files");
- content.startElement(null, "Globals", "Globals", emptyAttrs);
- content.endElement(null, "Globals", "Globals");
- content.endElement(null, "VisualStudioProject", "VisualStudioProject");
- content.endDocument();
- }
+ /**
+ * Write Tool element for linker.
+ * @param content serialization content handler.
+ * @param basePath path to directory containing project file.
+ * @param linkTarget link target.
+ * @param targets all targets.
+ * @throws SAXException thrown if error during serialization.
+ */
+ private void writeLinkerElement(final ContentHandler content,
+ final String basePath,
+ final TargetInfo linkTarget,
+ final Map targets) throws SAXException {
+ AttributesImpl attributes = new AttributesImpl();
+ addAttribute(attributes, "Name", "VCLinkerTool");
+
+ ProcessorConfiguration config = linkTarget.getConfiguration();
+ if (config instanceof CommandLineLinkerConfiguration) {
+ CommandLineLinkerConfiguration linkerConfig =
+ (CommandLineLinkerConfiguration) config;
+ if (linkerConfig.getLinker() instanceof DevStudioCompatibleLinker) {
+ addAttribute(attributes, "LinkIncremental",
+ getLinkIncremental(linkerConfig));
+ addAttribute(attributes, "GenerateDebugInformation",
+ getGenerateDebugInformation(linkerConfig));
+ addAttribute(attributes, "SubSystem",
+ getSubsystem(linkerConfig));
+ addAttribute(attributes, "TargetMachine",
+ getTargetMachine(linkerConfig));
+ }
+ }
+ addAttribute(attributes, "AdditionalDependencies",
+ getAdditionalDependencies(linkTarget, targets, basePath));
+ content.startElement(null, "Tool", "Tool", attributes);
+ content.endElement(null, "Tool", "Tool");
+ }
- /**
- * Writes a cluster of source files to the project.
- * @param name name of filter
- * @param filter file extensions
- * @param basePath base path for files
- * @param sortedSources array of source files
- * @param content generated project
- * @throws SAXException if invalid content
- */
- private void writeFilteredSources(final String name, final String filter,
- final String basePath,
- final File[] sortedSources,
- final ContentHandler content)
- throws SAXException {
- AttributesImpl filterAttrs = new AttributesImpl();
- filterAttrs.addAttribute(null, "Name", "Name", "#PCDATA", name);
- filterAttrs.addAttribute(null, "Filter", "Filter", "#PCDATA", filter);
- content.startElement(null, "Filter", "Filter", filterAttrs);
-
-
- AttributesImpl fileAttrs = new AttributesImpl();
- fileAttrs.addAttribute(null, "RelativePath", "RelativePath",
- "#PCDATA", "");
-
- AttributesImpl fileConfigAttrs = new AttributesImpl();
- fileConfigAttrs.addAttribute(null, "Name", "Name",
- "#PCDATA", "Debug|Win32");
-
- AttributesImpl toolAttrs = new AttributesImpl();
- toolAttrs.addAttribute(null, "Name", "Name",
- "#PCDATA", "VCCLCompilerTool");
- toolAttrs.addAttribute(null, "Optimization", "Optimization",
- "#PCDATA", "0");
- toolAttrs.addAttribute(null, "PreprocessorDefinitions",
- "PreprocessorDefinitions", "#PCDATA",
- "WIN32;_DEBUG;_WINDOWS;$(NoInherit}");
-
- for (int i = 0; i < sortedSources.length; i++) {
- if (isGroupMember(filter, sortedSources[i])) {
- String relativePath = CUtil.getRelativePath(basePath,
- sortedSources[i]);
- fileAttrs.setValue(0, relativePath);
- content.startElement(null, "File", "File", fileAttrs);
- content.startElement(null, "FileConfiguration", "FileConfiguration",
- fileConfigAttrs);
- content.startElement(null, "Tool", "Tool", toolAttrs);
- content.endElement(null, "Tool", "Tool");
- content.endElement(null, "FileConfiguration", "FileConfiguration");
- content.endElement(null, "File", "File");
- }
- }
- content.endElement(null, "Filter", "Filter");
+ /**
+ * Writes a project definition file.
+ *
+ * @param fileName project name for file, should has .cbx extension
+ * @param task cc task for which to write project
+ * @param projectDef project element
+ * @param sources source files
+ * @param targets compilation targets
+ * @param linkTarget link target
+ * @throws IOException if I/O error
+ * @throws SAXException if XML serialization error
+ */
+ public void writeProject(final File fileName,
+ final CCTask task,
+ final ProjectDef projectDef,
+ final List sources,
+ final Hashtable targets,
+ final TargetInfo linkTarget) throws
+ IOException,
+ SAXException {
+
+ String projectName = projectDef.getName();
+ if (projectName == null) {
+ projectName = fileName.getName();
+ }
- }
- /**
- * Returns true if the file has an extension that appears in the group filter.
- * @param filter String group filter
- * @param candidate File file
- * @return boolean true if member of group
- */
- private boolean isGroupMember(final String filter, final File candidate) {
- String fileName = candidate.getName();
- int lastDot = fileName.lastIndexOf('.');
- if (lastDot >= 0 && lastDot < fileName.length() - 1) {
- String extension =
- ";" + fileName.substring(lastDot + 1).toLowerCase() + ";";
- String semiFilter = ";" + filter + ";";
- return semiFilter.indexOf(extension) >= 0;
+ File vcprojFile = new File(fileName + ".vcproj");
+ if (!projectDef.getOverwrite() && vcprojFile.exists()) {
+ throw new BuildException("Not allowed to overwrite project file "
+ + vcprojFile.toString());
+ }
+ File slnFile = new File(fileName + ".sln");
+ if (!projectDef.getOverwrite() && slnFile.exists()) {
+ throw new BuildException("Not allowed to overwrite project file "
+ + slnFile.toString());
+ }
+
+ CommandLineCompilerConfiguration compilerConfig =
+ getBaseCompilerConfiguration(targets);
+ if (compilerConfig == null) {
+ throw new BuildException(
+ "Unable to generate Visual Studio.NET project "
+ + "when Microsoft C++ is not used.");
+ }
+
+ OutputStream outStream = new FileOutputStream(fileName + ".vcproj");
+ OutputFormat format = new OutputFormat("xml", "UTF-8", true);
+ Serializer serializer = new XMLSerializer(outStream, format);
+ ContentHandler content = serializer.asContentHandler();
+ String basePath = fileName.getParentFile().getAbsolutePath();
+ content.startDocument();
+ AttributesImpl emptyAttrs = new AttributesImpl();
+
+ AttributesImpl attributes = new AttributesImpl();
+ addAttribute(attributes, "ProjectType", "Visual C++");
+ addAttribute(attributes, "Version", version);
+ addAttribute(attributes, "Name", projectName);
+ content.startElement(null, "VisualStudioProject",
+ "VisualStudioProject", attributes);
+
+ content.startElement(null, "Platforms", "Platforms", emptyAttrs);
+ attributes.clear();
+ addAttribute(attributes, "Name", "Win32");
+ content.startElement(null, "Platform", "Platform", attributes);
+ content.endElement(null, "Platform", "Platform");
+ content.endElement(null, "Platforms", "Platforms");
+ content.startElement(null, "Configurations",
+ "Configurations", emptyAttrs);
+
+ writeConfigurationStartTag(content, basePath, task, compilerConfig);
+
+ writeCompilerElement(content, compilerConfig);
+
+ writeLinkerElement(content, basePath, linkTarget, targets);
+
+ content.endElement(null, "Configuration", "Configuration");
+ content.endElement(null, "Configurations", "Configurations");
+ content.startElement(null, "References", "References", emptyAttrs);
+ content.endElement(null, "References", "References");
+ content.startElement(null, "Files", "Files", emptyAttrs);
+
+
+ File[] sortedSources = new File[sources.size()];
+ sources.toArray(sortedSources);
+ Arrays.sort(sortedSources, new Comparator() {
+ public int compare(final Object o1, final Object o2) {
+ return ((File) o1).getName().compareTo(((File) o2).getName());
+ }
+ });
+
+ writeFilteredSources("Source Files",
+ "cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx",
+ basePath, sortedSources, content);
+
+ writeFilteredSources("Header Files", "h;hpp;hxx;hm;inl;inc;xsd",
+ basePath, sortedSources, content);
+
+ writeFilteredSources("Resource Files",
+ "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx",
+ basePath, sortedSources, content);
+
+ content.endElement(null, "Files", "Files");
+ content.startElement(null, "Globals", "Globals", emptyAttrs);
+ content.endElement(null, "Globals", "Globals");
+ content.endElement(null, "VisualStudioProject", "VisualStudioProject");
+ content.endDocument();
}
- return false;
- }
+ /**
+ * Writes a cluster of source files to the project.
+ *
+ * @param name name of filter
+ * @param filter file extensions
+ * @param basePath base path for files
+ * @param sortedSources array of source files
+ * @param content generated project
+ * @throws SAXException if invalid content
+ */
+ private void writeFilteredSources(final String name, final String filter,
+ final String basePath,
+ final File[] sortedSources,
+ final ContentHandler content)
+ throws SAXException {
+ AttributesImpl filterAttrs = new AttributesImpl();
+ filterAttrs.addAttribute(null, "Name", "Name", "#PCDATA", name);
+ filterAttrs.addAttribute(null, "Filter", "Filter", "#PCDATA", filter);
+ content.startElement(null, "Filter", "Filter", filterAttrs);
+
+
+ AttributesImpl fileAttrs = new AttributesImpl();
+ fileAttrs.addAttribute(null, "RelativePath", "RelativePath",
+ "#PCDATA", "");
+
+
+ for (int i = 0; i < sortedSources.length; i++) {
+ if (isGroupMember(filter, sortedSources[i])) {
+ String relativePath = CUtil.getRelativePath(basePath,
+ sortedSources[i]);
+ fileAttrs.setValue(0, relativePath);
+ content.startElement(null, "File", "File", fileAttrs);
+ content.endElement(null, "File", "File");
+ }
+ }
+ content.endElement(null, "Filter", "Filter");
+
+ }
- /**
- * Start an element.
- * @param content ContentHandler content handler
- * @param tagName String tag name
- * @param attributeNames String[] attribute names
- * @param attributeValues String[] attribute values
- * @throws SAXException if error writing element
- */
- private void startElement(final ContentHandler content,
- final String tagName,
- final String[] attributeNames,
- final String[] attributeValues)
- throws SAXException {
- AttributesImpl attributes = new AttributesImpl();
- for (int i = 0; i < attributeNames.length; i++) {
- if (attributeValues[i] != null) {
- attributes.addAttribute(null, attributeNames[i],
- attributeNames[i], "#PCDATA", attributeValues[i]);
+ /**
+ * Returns true if the file has an extension that
+ * appears in the group filter.
+ *
+ * @param filter String group filter
+ * @param candidate File file
+ * @return boolean true if member of group
+ */
+ private boolean isGroupMember(final String filter, final File candidate) {
+ String fileName = candidate.getName();
+ int lastDot = fileName.lastIndexOf('.');
+ if (lastDot >= 0 && lastDot < fileName.length() - 1) {
+ String extension =
+ ";" + fileName.substring(lastDot + 1).toLowerCase() + ";";
+ String semiFilter = ";" + filter + ";";
+ return semiFilter.indexOf(extension) >= 0;
}
+ return false;
}
- content.startElement(null, tagName, tagName, attributes);
- }
- /**
- * Gets the first recognized compiler from the
- * compilation targets.
- * @param targets compilation targets
- * @return representative (hopefully) compiler configuration
- */
- private CommandLineCompilerConfiguration
- getBaseCompilerConfiguration(final Hashtable targets) {
- //
- // find first target with an DevStudio C compilation
- //
- CommandLineCompilerConfiguration compilerConfig = null;
- //
- // get the first target and assume that it is representative
- //
- Iterator targetIter = targets.values().iterator();
- while (targetIter.hasNext()) {
- TargetInfo targetInfo = (TargetInfo) targetIter.next();
- ProcessorConfiguration config = targetInfo.getConfiguration();
- String identifier = config.getIdentifier();
- //
- // for the first cl compiler
- //
- if (config instanceof CommandLineCompilerConfiguration) {
- compilerConfig = (CommandLineCompilerConfiguration) config;
- if (compilerConfig.getCompiler() instanceof DevStudioCCompiler) {
- return compilerConfig;
- }
- }
+
+ /**
+ * Adds an non-namespace-qualified attribute to attribute list.
+ * @param attributes list of attributes.
+ * @param attrName attribute name, may not be null.
+ * @param attrValue attribute value, if null attribute is not added.
+ */
+ private static void addAttribute(final AttributesImpl attributes,
+ final String attrName,
+ final String attrValue) {
+ if (attrName == null) {
+ throw new IllegalArgumentException("attrName");
+ }
+ if (attrValue != null) {
+ attributes.addAttribute(null, attrName, attrName,
+ "#PCDATA", attrValue);
+ }
}
- return null;
- }
+ /**
+ * Gets the first recognized compiler from the
+ * compilation targets.
+ * @param targets compilation targets
+ * @return representative (hopefully) compiler configuration
+ */
+ private CommandLineCompilerConfiguration
+ getBaseCompilerConfiguration(final Hashtable targets) {
+ //
+ // get the first target and assume that it is representative
+ //
+ Iterator targetIter = targets.values().iterator();
+ while (targetIter.hasNext()) {
+ TargetInfo targetInfo = (TargetInfo) targetIter.next();
+ ProcessorConfiguration config = targetInfo.getConfiguration();
+ //
+ // for the first cl compiler
+ //
+ if (config instanceof CommandLineCompilerConfiguration) {
+ CommandLineCompilerConfiguration compilerConfig =
+ (CommandLineCompilerConfiguration) config;
+ if (compilerConfig.getCompiler()
+ instanceof DevStudioCCompiler) {
+ return compilerConfig;
+ }
+ }
+ }
+ return null;
+ }
}
+
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
index 27cbfa5..5b743d3 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java
@@ -55,17 +55,18 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
args.addElement("-g");
}
if (isDarwin()) {
- if (linkType.isPluginModule()) {
+ if (linkType.isPluginModule()) {
args.addElement("-bundle");
-// FREEHEP
+// BEGINFREEHEP
} else if (linkType.isJNIModule()) {
args.addElement("-dynamic");
args.addElement("-bundle");
+// ENDFREEHEP
} else {
if (linkType.isSharedLibrary()) {
-// No longer needed for 10.4 and up.
-// args.addElement("-prebind");
- args.addElement("-dynamiclib");
+// FREEHEP no longer needed for 10.4+
+// args.addElement("-prebind");
+ args.addElement("-dynamiclib");
}
}
} else {
@@ -120,14 +121,15 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
//
if (set.getType() != previousLibraryType) {
if (set.getType() != null && "static".equals(set.getType().getValue())) {
- // FREEHEP
- if (!isDarwin()) {
+// BEGINFREEHEP not on MacOS X
+ if (!isDarwin()) {
endargs.addElement("-Bstatic");
previousLibraryType = set.getType();
- }
+ }
+//ENDFREEHEP
} else {
- // FREEHEP FIXME, recheck this, works on MacOSX
- if (set.getType() == null &&
+// FREEHEP not on MacOS X, recheck this!
+ if (set.getType() == null ||
!"framework".equals(set.getType().getValue()) &&
!isDarwin()) {
endargs.addElement("-Bdynamic");
@@ -140,8 +142,8 @@ public abstract class AbstractLdLinker extends CommandLineLinker {
"framework".equals(set.getType().getValue()) &&
isDarwin()) {
buf.setLength(0);
-// buf.append("-framework ");
- endargs.addElement("-framework");
+// FREEHEP
+ endargs.addElement("-framework ");
}
int initialLength = buf.length();
for (int j = 0; j < libs.length; j++) {
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
index 49a3e35..409655b 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java
@@ -84,13 +84,14 @@ public final class GccCCompiler extends GccCompatibleCCompiler {
public static GccCCompiler getG77Instance() {
return g77Instance;
}
-// FREEHEP
/**
- * Gets g95 adapter
+ * Gets g77 adapter
*/
+// FREEHEPBEGIN
public static GccCCompiler getGFortranInstance() {
return gfortranInstance;
}
+// FREEHEPEND
/**
* Gets gpp adapter
*/
@@ -130,10 +131,12 @@ public final class GccCCompiler extends GccCompatibleCCompiler {
if (isPICMeaningful && linkType.isSharedLibrary()) {
args.addElement("-fPIC");
}
- // FREEHEP -fno-rtti only valid for g++ and c++
- if (!getCommand().equals("g77") && !getCommand().equals("gcc") && (rtti != null) && !rtti.booleanValue()) {
- args.addElement("-fno-rtti");
+// BEGINFREEHEP
+ // Add -fno_rtti only for g++ and c++
+ if (!getCommand().equals("g77") && !getCommand().equals("gcc") && (rtti != null) && (!rtti.booleanValue())) {
+ args.addElement("-fno_rtti");
}
+// ENDFREEHEP
}
public Processor changeEnvironment(boolean newEnvironment, Environment env) {
if (newEnvironment || env != null) {
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java b/src/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
index ea42faf..fa134f0 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java
@@ -98,15 +98,16 @@ public abstract class GccCompatibleCCompiler extends CommandLineCCompiler {
args.addElement("-mwindows");
}
}
-// FREEHEP, moved to GccCCompiler
+// BEGINFREEHEP
+ if (!exceptions) {
+ args.addElement("-fno-exceptions");
+ }
+// ENDFREEHEP
+// BEGINFREEHEP moved to GccCCompiler
// if (rtti != null && !rtti.booleanValue()) {
// args.addElement("-fno-rtti");
// }
-// FREEHEP
- if (!exceptions) {
- args.addElement("-fno-exceptions");
- }
-
+// ENDFREEHEP
}
/**
* Adds an include path to the command.
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
index 4c82743..ed1a052 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
@@ -33,7 +33,9 @@ public class GccLinker extends AbstractLdLinker {
private static final String[] libtoolObjFiles = new String[]{".fo", ".a",
".lib", ".dll", ".so", ".sl"};
private static String[] linkerOptions = new String[]{"-bundle",
- "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
+// FREEHEP
+ "-dynamic",
+ "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s",
"-static", "-shared", "-symbolic", "-Xlinker",
"--export-all-symbols", "-static-libgcc",};
private static final GccLinker dllLinker = new GccLinker("gcc", objFiles,
@@ -43,11 +45,10 @@ public class GccLinker extends AbstractLdLinker {
discardFiles, "", "", false, null);
private static final GccLinker machBundleLinker = new GccLinker("gcc",
objFiles, discardFiles, "lib", ".bundle", false, null);
-// FREEHEP
- private static final GccLinker machJNILinker = new GccLinker("gcc",
- objFiles, discardFiles, "lib", ".jnilib", false, null);
private static final GccLinker machDllLinker = new GccLinker("gcc",
objFiles, discardFiles, "lib", ".dylib", false, null);
+ private static final GccLinker machJNILinker = new GccLinker("gcc",
+ objFiles, discardFiles, "lib", ".jnilib", false, null);
public static GccLinker getInstance() {
return instance;
}
@@ -194,14 +195,15 @@ public class GccLinker extends AbstractLdLinker {
if (type.isStaticLibrary()) {
return GccLibrarian.getInstance();
}
-// FREEHEP
+// BEGINFREEHEP
if (type.isJNIModule()) {
- if (isDarwin()) {
- return machJNILinker;
- } else {
- return dllLinker;
- }
+ if (isDarwin()) {
+ return machJNILinker;
+ } else {
+ return dllLinker;
+ }
}
+// ENDFREEHEP
if (type.isPluginModule()) {
if (isDarwin()) {
return machBundleLinker;
diff --git a/src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
index 7b9af5f..9a70451 100644
--- a/src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
+++ b/src/net/sf/antcontrib/cpptasks/gcc/GppLinker.java
@@ -48,16 +48,17 @@ public class GppLinker extends AbstractLdLinker {
discardFiles, "", "", false, null);
private static final GppLinker machDllLinker = new GppLinker("gcc",
objFiles, discardFiles, "lib", ".dylib", false, null);
-// FREEHEP
- private static final GppLinker machJNILinker = new GppLinker("gcc",
- objFiles, discardFiles, "lib", ".jnilib", false, null);
private static final GppLinker machPluginLinker = new GppLinker("gcc",
objFiles, discardFiles, "lib", ".bundle", false, null);
+// FREEHEP
+ private static final GppLinker machJNILinker = new GppLinker("gcc",
+ objFiles, discardFiles, "lib", ".jnilib", false, null);
public static GppLinker getInstance() {
return instance;
}
private File[] libDirs;
private String runtimeLibrary;
+// FREEEHEP
private String gccLibrary;
protected GppLinker(String command, String[] extensions,
String[] ignoredExtensions, String outputPrefix,
@@ -75,34 +76,34 @@ public class GppLinker extends AbstractLdLinker {
args.addElement("-mwindows");
}
}
-// FREEHEP, avoid stdc++ if requested
+// BEGINFREEHEP link or not with libstdc++
runtimeLibrary = null;
gccLibrary = null;
if (linkType.linkCPP()) {
- if (linkType.isStaticRuntime()) {
- String[] cmdin = new String[]{"g++", "-print-file-name=libstdc++.a"};
- String[] cmdout = CaptureStreamHandler.run(cmdin);
- if (cmdout.length > 0) {
- runtimeLibrary = cmdout[0];
- } else {
- runtimeLibrary = null;
- }
- gccLibrary = "-static-libgcc";
- } else {
- runtimeLibrary = "-lstdc++";
-// FIXME, needed to add exceptions here for MacOS X.
- gccLibrary = "-fexceptions";
- }
+ if (linkType.isStaticRuntime()) {
+ String[] cmdin = new String[]{"g++", "-print-file-name=libstdc++.a"};
+ String[] cmdout = CaptureStreamHandler.run(cmdin);
+ if (cmdout.length > 0) {
+ runtimeLibrary = cmdout[0];
+ } else {
+ runtimeLibrary = null;
+ }
+ gccLibrary = "-static-libgcc";
+ } else {
+ runtimeLibrary = "-lstdc++";
+ // NOTE: added -fexceptions here for MacOS X
+ gccLibrary = "-fexceptions";
+ }
} else {
- if (linkType.isStaticRuntime()) {
- gccLibrary = "-static-libgcc";
- } else {
- gccLibrary = "-shared-libgcc";
- }
+ if (linkType.isStaticRuntime()) {
+ gccLibrary = "-static-libgcc";
+ } else {
+ gccLibrary = "-shared-libgcc";
+ }
}
- // FREEHEP: set flag
- linkType.callAddLibrarySets = true;
+// ENDFREEHEP
}
+
public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,
Vector preargs, Vector midargs, Vector endargs) {
String[] rs = super.addLibrarySets(task, libsets, preargs, midargs,
@@ -110,9 +111,11 @@ public class GppLinker extends AbstractLdLinker {
if (runtimeLibrary != null) {
endargs.addElement(runtimeLibrary);
}
+// BEGINFREEHEP
if (gccLibrary != null) {
endargs.addElement(gccLibrary);
}
+// ENDFREEHEP
return rs;
}
/**
@@ -209,14 +212,15 @@ public class GppLinker extends AbstractLdLinker {
if (type.isStaticLibrary()) {
return GccLibrarian.getInstance();
}
-// FREEHEP
+// BEGINFREEHEP
if (type.isJNIModule()) {
- if (isDarwin()) {
- return machJNILinker;
- } else {
- return dllLinker;
- }
+ if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
+ return machJNILinker;
+ } else {
+ return dllLinker;
+ }
}
+// ENDFREEHEP
if (type.isPluginModule()) {
if (GccProcessor.getMachine().indexOf("darwin") >= 0) {
return machPluginLinker;
diff --git a/src/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java b/src/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java
index b603e1d..e556e6b 100644
--- a/src/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/hp/aCCCompiler.java
@@ -59,7 +59,11 @@ public final class aCCCompiler extends GccCompatibleCCompiler {
/*
* if (multithreaded) { args.addElement("-mt"); }
*/
- if (linkType.isSharedLibrary()) {
+
+ //
+ // per patch 1193690
+ //
+ if (linkType.isSharedLibrary() && (! args.contains("+Z"))) {
args.addElement("+z");
}
}
diff --git a/src/net/sf/antcontrib/cpptasks/ide/ProjectDef.java b/src/net/sf/antcontrib/cpptasks/ide/ProjectDef.java
index 53ad254..df0177c 100644
--- a/src/net/sf/antcontrib/cpptasks/ide/ProjectDef.java
+++ b/src/net/sf/antcontrib/cpptasks/ide/ProjectDef.java
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2004-2005 The Ant-Contrib project
+ * Copyright 2004-2006 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.
@@ -16,19 +16,18 @@
*/
package net.sf.antcontrib.cpptasks.ide;
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.Hashtable;
-import java.util.List;
-
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.TargetInfo;
-
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Requests the creation of an IDE project file. Experimental.
*
@@ -117,6 +116,10 @@ public final class ProjectDef
* <td>Microsoft Visual C++.NET 2003</td>
* </tr>
* <tr>
+ * <td>msvc8</td>
+ * <td>Microsoft Visual C++ 2005</td>
+ * </tr>
+ * <tr>
* <td>xcode</td>
* <td>Apple Xcode</td>
* </tr>
diff --git a/src/net/sf/antcontrib/cpptasks/ide/ProjectWriterEnum.java b/src/net/sf/antcontrib/cpptasks/ide/ProjectWriterEnum.java
index 43d3af6..e100dbc 100644
--- a/src/net/sf/antcontrib/cpptasks/ide/ProjectWriterEnum.java
+++ b/src/net/sf/antcontrib/cpptasks/ide/ProjectWriterEnum.java
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2004 The Ant-Contrib project
+ * Copyright 2004-2006 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
@@ -16,11 +16,11 @@
*/
package net.sf.antcontrib.cpptasks.ide;
-import org.apache.tools.ant.types.EnumeratedAttribute;
import net.sf.antcontrib.cpptasks.apple.XcodeProjectWriter;
import net.sf.antcontrib.cpptasks.borland.CBuilderXProjectWriter;
import net.sf.antcontrib.cpptasks.devstudio.DevStudioProjectWriter;
import net.sf.antcontrib.cpptasks.devstudio.VisualStudioNETProjectWriter;
+import org.apache.tools.ant.types.EnumeratedAttribute;
/**
* Enumeration of supported project file generators.
@@ -47,6 +47,10 @@ import net.sf.antcontrib.cpptasks.devstudio.VisualStudioNETProjectWriter;
* <td>Microsoft Visual C++.NET 2003</td>
* </tr>
* <tr>
+ * <td>msvc8</td>
+ * <td>Microsoft Visual C++ 2005</td>
+ * </tr>
+ * <tr>
* <td>xcode</td>
* <td>Apple Xcode</td>
* </tr>
@@ -62,7 +66,7 @@ public final class ProjectWriterEnum
*/
private static String[] values = new String[] {
"cbuilderx", "msvc5",
- "msvc6", "msvc7", "msvc71", "xcode"};
+ "msvc6", "msvc7", "msvc71", "msvc8", "xcode"};
/**
* Project writers associated with enumeration values.
@@ -70,8 +74,9 @@ public final class ProjectWriterEnum
private static ProjectWriter[] writers = new ProjectWriter[] {
new CBuilderXProjectWriter(), new DevStudioProjectWriter("5.00"),
new DevStudioProjectWriter("6.00"),
- new VisualStudioNETProjectWriter("7.00"),
- new VisualStudioNETProjectWriter("7.10"),
+ new VisualStudioNETProjectWriter("7.00", "TRUE", "FALSE"),
+ new VisualStudioNETProjectWriter("7.10", "TRUE", "FALSE"),
+ new VisualStudioNETProjectWriter("8.00", "true", "false"),
new XcodeProjectWriter()};
/**
@@ -92,3 +97,4 @@ public final class ProjectWriterEnum
return (String[]) values.clone();
}
}
+
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java b/src/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java
index 1513f23..085d61e 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java
@@ -50,7 +50,7 @@ public final class IntelLinux32CCompiler extends GccCompatibleCCompiler {
return this;
}
public Linker getLinker(LinkType type) {
- // FREEHEP
+// FREEHEP
return IntelLinux32CLinker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java
index e006af2..80ade19 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32CCompiler.java
@@ -19,7 +19,6 @@ import net.sf.antcontrib.cpptasks.compiler.LinkType;
import net.sf.antcontrib.cpptasks.compiler.Linker;
import net.sf.antcontrib.cpptasks.compiler.Processor;
import net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleCCompiler;
-
import org.apache.tools.ant.types.Environment;
/**
* Adapter for the Intel (r) C++ compiler for 32-bit applications
@@ -36,7 +35,7 @@ public final class IntelWin32CCompiler extends DevStudioCompatibleCCompiler {
return instance;
}
private IntelWin32CCompiler(boolean newEnvironment, Environment env) {
- super("icl", null, newEnvironment, env);
+ super("icl", "-help", newEnvironment, env);
}
public Processor changeEnvironment(boolean newEnvironment, Environment env) {
if (newEnvironment || env != null) {
@@ -48,6 +47,6 @@ public final class IntelWin32CCompiler extends DevStudioCompatibleCCompiler {
return IntelWin32Linker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
}
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java
index 39353d4..e9473d5 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Librarian.java
@@ -30,7 +30,7 @@ public class IntelWin32Librarian extends DevStudioCompatibleLibrarian {
return instance;
}
protected IntelWin32Librarian() {
- super("xilib", "/bogus");
+ super("xilib", "-qv");
}
public Linker getLinker(LinkType type) {
return IntelWin32Linker.getInstance().getLinker(type);
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
index fe0642f..66009f0 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelWin32Linker.java
@@ -32,7 +32,7 @@ public final class IntelWin32Linker extends DevStudioCompatibleLinker {
return instance;
}
private IntelWin32Linker(String outputSuffix) {
- super("xilink", "/bogus", outputSuffix);
+ super("xilink", "-qv", outputSuffix);
}
public Linker getLinker(LinkType type) {
if (type.isStaticLibrary()) {
diff --git a/src/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java b/src/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java
index 5927d0f..6344022 100644
--- a/src/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java
+++ b/src/net/sf/antcontrib/cpptasks/intel/IntelWin64CCompiler.java
@@ -33,7 +33,7 @@ public final class IntelWin64CCompiler extends DevStudioCompatibleCCompiler {
return instance;
}
private IntelWin64CCompiler(boolean newEnvironment, Environment env) {
- super("ecl", null, newEnvironment, env);
+ super("ecl", "-help", newEnvironment, env);
}
public Processor changeEnvironment(boolean newEnvironment, Environment env) {
if (newEnvironment || env != null) {
@@ -48,6 +48,6 @@ public final class IntelWin64CCompiler extends DevStudioCompatibleCCompiler {
return IntelWin32Linker.getInstance().getLinker(type);
}
public int getMaximumCommandLength() {
- return 1024;
+ return 32767;
}
}
diff --git a/src/net/sf/antcontrib/cpptasks/types/LibrarySet.java b/src/net/sf/antcontrib/cpptasks/types/LibrarySet.java
index b623654..acac911 100644
--- a/src/net/sf/antcontrib/cpptasks/types/LibrarySet.java
+++ b/src/net/sf/antcontrib/cpptasks/types/LibrarySet.java
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2001-2004 The Ant-Contrib project
+ * Copyright 2001-2006 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.
@@ -24,7 +24,7 @@ import net.sf.antcontrib.cpptasks.compiler.Linker;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
/**
@@ -42,7 +42,7 @@ import org.apache.tools.ant.types.PatternSet;
* @author Adam Murdoch
* @author Curt Arnold
*/
-public class LibrarySet extends ProjectComponent {
+public class LibrarySet extends DataType {
private String dataset;
private boolean explicitCaseSensitive;
private String ifCond;
@@ -63,15 +63,31 @@ public class LibrarySet extends ProjectComponent {
* @return Returns a String
*/
public String getDataset() {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.getDataset();
+ }
return dataset;
}
- public File getDir(Project project) {
+ public File getDir(final Project project) {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.getDir(project);
+ }
return set.getDir(project);
}
protected FileSet getFileSet() {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.getFileSet();
+ }
return set;
}
public String[] getLibs() {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.getLibs();
+ }
String[] retval = (String[]) libnames.clone();
return retval;
}
@@ -82,13 +98,17 @@ public class LibrarySet extends ProjectComponent {
* @return library type, may be null.
*/
public LibraryTypeEnum getType() {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.getType();
+ }
return libraryType;
}
/**
* Returns true if the define's if and unless conditions (if any) are
* satisfied.
*/
- public boolean isActive(org.apache.tools.ant.Project p) {
+ public boolean isActive(final org.apache.tools.ant.Project p) {
if (p == null) {
throw new NullPointerException("p");
}
@@ -121,6 +141,10 @@ public class LibrarySet extends ProjectComponent {
return false;
}
}
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ return master.isActive(project);
+ }
if (libnames.length == 0) {
p.log("libnames not specified or empty.", Project.MSG_WARN);
return false;
@@ -135,7 +159,10 @@ public class LibrarySet extends ProjectComponent {
* "true"|"on"|"yes" if file system is case sensitive,
* "false"|"off"|"no" when not.
*/
- public void setCaseSensitive(boolean isCaseSensitive) {
+ public void setCaseSensitive(final boolean isCaseSensitive) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
explicitCaseSensitive = true;
set.setCaseSensitive(isCaseSensitive);
}
@@ -145,7 +172,10 @@ public class LibrarySet extends ProjectComponent {
* @param dataset
* The dataset to set
*/
- public void setDataset(String dataset) {
+ public void setDataset(final String dataset) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
this.dataset = dataset;
}
/**
@@ -155,7 +185,10 @@ public class LibrarySet extends ProjectComponent {
* library directory
*
*/
- public void setDir(File dir) throws BuildException {
+ public void setDir(final File dir) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
set.setDir(dir);
}
/**
@@ -178,33 +211,18 @@ public class LibrarySet extends ProjectComponent {
* "lib", or extensions, such as ".so" or ".a".
*
*/
- public void setLibs(CUtil.StringArrayBuilder libs) throws BuildException {
- libnames = libs.getValue();
- // If this is not active.. then it's ok if the lib names are invalid.
- // so we can do a: <libset if="x.lib" dir="." libs="${x.lib}"/>
- if (!isActive(getProject()))
- return;
- for (int i = 0; i < libnames.length; i++) {
- int lastDot = libnames[i].lastIndexOf('.');
- if (lastDot >= 0) {
- String extension = libnames[i].substring(lastDot);
- if (extension.equalsIgnoreCase(".lib")
- || extension.equalsIgnoreCase(".so")
- || extension.equalsIgnoreCase(".a")) {
- getProject().log(
- "Suspicious library name ending with \""
- + extension + "\": " + libnames[i]);
- }
- }
- if (libnames[i].length() >= 3
- && libnames[i].substring(0, 3).equalsIgnoreCase("lib")) {
- getProject().log(
- "Suspicious library name starting with \"lib\": "
- + libnames[i]);
- }
+ public void setLibs(final CUtil.StringArrayBuilder libs) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
}
+ libnames = libs.getValue();
+ //
+ // earlier implementations would warn of suspicious library names
+ // (like libpthread for pthread or kernel.lib for kernel).
+ // visitLibraries now provides better feedback and ld type linkers
+ // should provide adequate feedback so the check here is not necessary.
}
- public void setProject(Project project) {
+ public void setProject(final Project project) {
set.setProject(project);
super.setProject(project);
}
@@ -228,63 +246,102 @@ public class LibrarySet extends ProjectComponent {
* Sets the preferred library type. Supported values "shared", "static", and
* "framework". "framework" is equivalent to "shared" on non-Darwin platforms.
*/
- public void setType(LibraryTypeEnum type) {
+ public void setType(final LibraryTypeEnum type) {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
this.libraryType = type;
}
- public void visitLibraries(Project project, Linker linker, File[] libpath,
- FileVisitor visitor) throws BuildException {
- FileSet localSet = (FileSet) set.clone();
- //
- // unless explicitly set
- // will default to the linker case sensitivity
- //
- if (!explicitCaseSensitive) {
- boolean linkerCaseSensitive = linker.isCaseSensitive();
- localSet.setCaseSensitive(linkerCaseSensitive);
+ public void visitLibraries(final Project project,
+ final Linker linker,
+ final File[] libpath,
+ final FileVisitor visitor) throws BuildException {
+ if (isReference()) {
+ LibrarySet master = ((LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet"));
+ master.visitLibraries(project, linker, libpath, visitor);
}
//
// if there was a libs attribute then
// add the corresponding patterns to the FileSet
//
- if (libnames != null && libnames.length > 0) {
- String[] patterns = linker.getLibraryPatterns(libnames, libraryType);
- //
- // if no patterns, then linker does not support libraries
- //
- if (patterns.length > 0) {
- for (int i = 0; i < patterns.length; i++) {
- PatternSet.NameEntry entry = localSet.createInclude();
- entry.setName(patterns[i]);
- }
- //
- // if there was no specified directory then
- // run through the libpath backwards
- //
- if (localSet.getDir(project) == null) {
- //
- // scan libpath in reverse order
- // to give earlier entries priority
- //
- for (int j = libpath.length - 1; j >= 0; j--) {
- FileSet clone = (FileSet) localSet.clone();
- clone.setDir(libpath[j]);
- DirectoryScanner scanner = clone.getDirectoryScanner(project);
- File basedir = scanner.getBasedir();
- String[] files = scanner.getIncludedFiles();
- for (int k = 0; k < files.length; k++) {
- visitor.visit(basedir, files[k]);
- }
- }
- } else {
- DirectoryScanner scanner = localSet.getDirectoryScanner(project);
- File basedir = scanner.getBasedir();
- String[] files = scanner.getIncludedFiles();
- for (int k = 0; k < files.length; k++) {
- visitor.visit(basedir, files[k]);
- }
- }
- }
+ if (libnames != null) {
+ for (int i = 0; i < libnames.length; i++) {
+ String[] patterns = linker.getLibraryPatterns(new String[] { libnames[i] }, libraryType);
+ if (patterns.length > 0) {
+ FileSet localSet = (FileSet) set.clone();
+ //
+ // unless explicitly set
+ // will default to the linker case sensitivity
+ //
+ if (!explicitCaseSensitive) {
+ boolean linkerCaseSensitive = linker.isCaseSensitive();
+ localSet.setCaseSensitive(linkerCaseSensitive);
+ }
+ //
+ // add all the patterns for this libname
+ //
+ for (int j = 0; j < patterns.length; j++) {
+ PatternSet.NameEntry entry = localSet.createInclude();
+ entry.setName(patterns[j]);
+ }
+ int matches = 0;
+ //
+ // if there was no specified directory then
+ // run through the libpath backwards
+ //
+ if (localSet.getDir(project) == null) {
+ //
+ // scan libpath in reverse order
+ // to give earlier entries priority
+ //
+ for (int j = libpath.length - 1; j >= 0; j--) {
+ FileSet clone = (FileSet) localSet.clone();
+ clone.setDir(libpath[j]);
+ DirectoryScanner scanner = clone.getDirectoryScanner(project);
+ File basedir = scanner.getBasedir();
+ String[] files = scanner.getIncludedFiles();
+ matches += files.length;
+ for (int k = 0; k < files.length; k++) {
+ visitor.visit(basedir, files[k]);
+ }
+ }
+ } else {
+ DirectoryScanner scanner = localSet.getDirectoryScanner(project);
+ File basedir = scanner.getBasedir();
+ String[] files = scanner.getIncludedFiles();
+ matches += files.length;
+ for (int k = 0; k < files.length; k++) {
+ visitor.visit(basedir, files[k]);
+ }
+ }
+ //
+ // TODO: following section works well for Windows
+ // style linkers but unnecessary fails
+ // Unix style linkers. Will need to revisit.
+ //
+ if (matches == 0 && false) {
+ StringBuffer msg = new StringBuffer("No file matching ");
+ if (patterns.length == 1) {
+ msg.append("pattern (");
+ msg.append(patterns[0]);
+ msg.append(")");
+ } else {
+ msg.append("patterns (\"");
+ msg.append(patterns[0]);
+ for (int k = 1; k < patterns.length; k++) {
+ msg.append(", ");
+ msg.append(patterns[k]);
+ }
+ msg.append(")");
+ }
+ msg.append(" for library name \"");
+ msg.append(libnames[i]);
+ msg.append("\" was found.");
+ throw new BuildException(msg.toString());
+ }
+ }
+ }
}
}
}