diff options
Diffstat (limited to 'src')
50 files changed, 1219 insertions, 272 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java index 2e6adab..ab40e95 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java @@ -16,10 +16,15 @@ */ package net.sf.antcontrib.cpptasks; import java.io.File; +import java.io.FileFilter; import java.io.IOException; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashSet; import java.util.Hashtable; -import java.util.*; +import java.util.List; +import java.util.Set; +import java.util.Vector; import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; @@ -120,6 +125,12 @@ import org.apache.tools.ant.types.Environment; * @author Curt Arnold */ public class CCTask extends Task { + + + + + + private static class SystemLibraryCollector implements FileVisitor { private Hashtable libraries; private Linker linker; @@ -180,6 +191,8 @@ public class CCTask extends Task { } return targetsByConfig; } + // FREEHEP + private int maxCores = 0; /** The compiler definitions. */ private Vector _compilers = new Vector(); /** The output file type. */ @@ -706,6 +719,11 @@ public class CCTask extends Task { } } } + // BEGINFREEHEP + Progress progress = new Progress(getObjdir(), rebuildCount); + progress.start(); + // ENDFREEHEP + for (int i = 0; i < targetVectors.length; i++) { // // get the targets for this configuration @@ -719,6 +737,100 @@ public class CCTask extends Task { // // prepare the list of source files // + + // BEGINFREEHEP + int noOfCores = Runtime.getRuntime().availableProcessors(); + log("Found "+noOfCores+" processors available"); + if (maxCores > 0) { + noOfCores = Math.min(maxCores, noOfCores); + log("Limited processors to "+noOfCores); + } + int noOfFiles = targetsForConfig.size(); + if (noOfFiles < noOfCores) { + noOfCores = noOfFiles; + log("Limited used processors to "+noOfCores); + } + + Set[] sourceFiles = new HashSet[noOfCores]; + for (int j = 0; j < sourceFiles.length; j++) { + sourceFiles[j] = new HashSet(noOfFiles + / sourceFiles.length); + } + Enumeration targetsEnum = targetsForConfig.elements(); + index = 0; + while (targetsEnum.hasMoreElements()) { + TargetInfo targetInfo = ((TargetInfo) targetsEnum + .nextElement()); + sourceFiles[index++].add(targetInfo.getSources()[0] + .toString()); + index %= sourceFiles.length; + } + + // setup cores/cpus + Core[] cores = new Core[noOfCores]; + for (int j = 0; j < cores.length; j++) { + cores[j] = new Core(this, j, config, _objDir, sourceFiles[j], + relentless, monitor); + log("\nStarting Core " + j + " with " + + sourceFiles[j].size() + " source files..."); + } + + // starting cores + for (int j = 0; j < cores.length; j++) { + cores[j].start(); + } + + // checking cores + boolean alive = false; + try { + do { + alive = false; + for (int j = 0; j < cores.length; j++) { + if (cores[j] != null) { + if (cores[j].isAlive()) { + alive = true; + } else { + Exception exception = cores[j].getException(); + if (exception != null) { + if ((compileException == null) && (exception instanceof BuildException)) { + compileException = (BuildException)exception; + } else { + log(cores[j].getName()+" "+exception+" ", Project.MSG_ERR); + } + if (!relentless) { + cores[j] = null; + alive = false; + break; + } + } + cores[j] = null; + } + } + } + if (alive) { + // wait for a maximum of 5 seconds or #files*2 seconds. + Thread.sleep(Math.min(5000, sourceFiles[0].size()*2000)); + } + } while (alive); + } catch (InterruptedException e) { + break; + } + + // killing leftovers + for (int j = 0; j < cores.length; j++) { + if (cores[j] != null) { + cores[j].interrupt(); + log(cores[j].getName()+" interrupted "); + } + } + + if ((!relentless) && (compileException != null)) { + break; + } + // ENDFREEHEP + + + /* OLD CODE String[] sourceFiles = new String[targetsForConfig.size()]; Enumeration targetsEnum = targetsForConfig.elements(); index = 0; @@ -738,7 +850,17 @@ public class CCTask extends Task { if (!relentless) break; } + */ } + + // BEGINFREEHEP + progress.exit(); + try { + progress.join(); + } catch (InterruptedException ex) { + } + // ENDFREEHEP + // // save the details of the object file compilation // settings to disk for dependency analysis @@ -796,9 +918,12 @@ public class CCTask extends Task { // File output = linkTarget.getOutput(); if (linkTarget.getRebuild()) { - log("Starting link"); LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget .getConfiguration(); + // BEGINFREEHEP + log("Linking..."); + log("Starting link {" + linkConfig.getIdentifier() + "}"); + // ENDFREEHEP if (failOnError) { linkConfig.link(this, linkTarget); } else { @@ -825,6 +950,101 @@ public class CCTask extends Task { } } } + + // BEGINFREEHEP + class Core extends Thread { + private CCTask task; + private CompilerConfiguration config; + private File objDir; + private Set sourceFiles; + private boolean relentless; + private CCTaskProgressMonitor monitor; + private Exception compileException; + + Core(CCTask task, int coreNo, CompilerConfiguration config, File objDir, + Set set, boolean relentless, + CCTaskProgressMonitor monitor) { + super("Core "+coreNo); + this.task = task; + this.config = config; + this.objDir = objDir; + this.sourceFiles = set; + this.relentless = relentless; + this.monitor = monitor; + } + + public Exception getException() { + return compileException; + } + + public void run() { + super.run(); + try { + String[] sources = new String[sourceFiles.size()]; + sources = (String[]) sourceFiles.toArray(sources); + config.compile(task, objDir, sources, relentless, monitor); + } catch (Exception ex) { + if (compileException == null) { + compileException = ex; + } + } + } + } + + // ENDFREEHEP + + // BEGINFREEHEP + class Progress extends Thread { + + private boolean stop = false; + private File objDir; + private int rebuildCount; + + public Progress(File objDir, int rebuildCount) { + this.objDir = objDir; + this.rebuildCount = rebuildCount; + } + + public void run() { + if (rebuildCount < 10) + return; + try { + FileFilter updatedFiles = new FileFilter() { + private long startTime = System.currentTimeMillis(); + + public boolean accept(File file) { + return file.lastModified() > startTime + && !file.getName().endsWith(".xml"); + } + }; + while (!stop) { + System.err.print("\r" + + objDir.listFiles(updatedFiles).length + " / " + + rebuildCount + " files compiled..."); + System.err.print("\r"); + System.err.flush(); + if (!stop) { + Thread.sleep(5000); + } + } + } catch (InterruptedException e) { + } + System.err + .print("\r "); + System.err.print("\r"); + System.err.flush(); + log(Integer.toString(rebuildCount) + " files were compiled."); + } + + public void exit() { + stop = true; + } + + } + + // ENDFREEHEP + + /** * Gets the dataset. * @@ -1103,6 +1323,18 @@ public class CCTask extends Task { public void setLink(OutputTypeEnum outputType) { linkType.setOutputType(outputType); } + + // BEGINFREEHEP + public void setLinkCPP(boolean linkCPP) { + linkType.setLinkCPP(linkCPP); + } + + public void setLinkFortran(boolean linkFortran) { + linkType.setLinkFortran(linkFortran); + } + + // ENDFREEHEP + /** * Enables or disables generation of multithreaded code * @@ -1372,7 +1604,18 @@ public class CCTask extends Task { public void setWarnings(WarningLevelEnum level) { compilerDef.setWarnings(level); } - + + // BEGINFREEHEP + public void setMaxCores(int maxCores) { + this.maxCores = maxCores; + } + + public int getMaxCores() { + return maxCores; + } + + // ENDFREEHEP + /** * Indicates whether the build will continue * even if there are compilation errors; defaults to true. @@ -1436,5 +1679,4 @@ public class CCTask extends Task { newVersionInfo.setProject(this.getProject()); versionInfos.addElement(newVersionInfo); } - } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CompilerEnum.java b/src/main/java/net/sf/antcontrib/cpptasks/CompilerEnum.java index 0233050..9e00744 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/CompilerEnum.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/CompilerEnum.java @@ -21,27 +21,32 @@ import net.sf.antcontrib.cpptasks.borland.BorlandResourceCompiler; import net.sf.antcontrib.cpptasks.compaq.CompaqVisualFortranCompiler; import net.sf.antcontrib.cpptasks.compiler.Compiler; import net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler; -import net.sf.antcontrib.cpptasks.devstudio.DevStudio2005CCompiler; import net.sf.antcontrib.cpptasks.devstudio.DevStudioMIDLCompiler; +import net.sf.antcontrib.cpptasks.devstudio.DevStudio2005CCompiler; import net.sf.antcontrib.cpptasks.devstudio.DevStudioResourceCompiler; import net.sf.antcontrib.cpptasks.gcc.GccCCompiler; import net.sf.antcontrib.cpptasks.gcc.WindresResourceCompiler; 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.IntelLinux32Compiler; import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler; +import net.sf.antcontrib.cpptasks.intel.IntelLinux64Compiler; +import net.sf.antcontrib.cpptasks.intel.IntelLinuxFortranCompiler; 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; +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; /** @@ -105,6 +110,10 @@ import org.apache.tools.ant.types.EnumeratedAttribute; * <td>Intel C++ compiler for Linux (IA-32)</td> * </tr> * <tr> + * <td>ifort</td> + * <td>Intel Fortran compiler for Linux (IA-32)</td> + * </tr> + * <tr> * <td>ecc</td> * <td>Intel C++ compiler for Linux (IA-64)</td> * </tr> @@ -191,6 +200,8 @@ public class CompilerEnum extends EnumeratedAttribute { new ProcessorEnumValue("g++", GccCCompiler.getGppInstance()), new ProcessorEnumValue("c++", GccCCompiler.getCppInstance()), new ProcessorEnumValue("g77", GccCCompiler.getG77Instance()), +// FREEHEP + new ProcessorEnumValue("gfortran", GccCCompiler.getGFortranInstance()), new ProcessorEnumValue("msvc", DevStudioCCompiler.getInstance()), new ProcessorEnumValue("msvc8", DevStudio2005CCompiler.getInstance()), new ProcessorEnumValue("bcc", BorlandCCompiler.getInstance()), @@ -202,9 +213,18 @@ 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()), + new ProcessorEnumValue("icpc", IntelLinux32Compiler.getInstance()), + new ProcessorEnumValue("ecpc", IntelLinux64Compiler.getInstance()), + new ProcessorEnumValue("ifort", IntelLinuxFortranCompiler.getInstance()), +// ENDFREEHEP new ProcessorEnumValue("CC", ForteCCCompiler.getInstance()), +// 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/main/java/net/sf/antcontrib/cpptasks/DependencyInfo.java b/src/main/java/net/sf/antcontrib/cpptasks/DependencyInfo.java index a04105f..d14966e 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/DependencyInfo.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/DependencyInfo.java @@ -26,12 +26,15 @@ public final class DependencyInfo { * Not persisted since almost any change could invalidate it. Initialized * to long.MIN_VALUE on construction. */ - private long compositeLastModified; +// FREEHEP +// private long compositeLastModified; private/* final */String includePathIdentifier; private/* final */String[] includes; private/* final */String source; private/* final */long sourceLastModified; private/* final */String[] sysIncludes; +// FREEHEP + private Object tag = null; public DependencyInfo(String includePathIdentifier, String source, long sourceLastModified, Vector includes, Vector sysIncludes) { if (source == null) { @@ -44,25 +47,34 @@ public final class DependencyInfo { this.sourceLastModified = sourceLastModified; this.includePathIdentifier = includePathIdentifier; this.includes = new String[includes.size()]; - if (includes.size() == 0) { - compositeLastModified = sourceLastModified; - } else { - includes.copyInto(this.includes); - compositeLastModified = Long.MIN_VALUE; - } +// BEGINFREEHEP +// if (includes.size() == 0) { +// compositeLastModified = sourceLastModified; +// } else { +// includes.copyInto(this.includes); +// compositeLastModified = Long.MIN_VALUE; +// } +// ENDFREEHEP this.sysIncludes = new String[sysIncludes.size()]; +// FREEHEP + includes.copyInto(this.includes); sysIncludes.copyInto(this.sysIncludes); } /** * Returns the latest modification date of the source or anything that it * depends on. * - * @return the composite lastModified time, returns Long.MIN_VALUE if not + * @returns the composite lastModified time, returns Long.MIN_VALUE if not * set */ - public long getCompositeLastModified() { - return compositeLastModified; +// BEGINFREEHEP +// public long getCompositeLastModified() { +// return compositeLastModified; +// } + public void setTag(Object t) { + tag = t; } +// ENDFREEHEP public String getIncludePathIdentifier() { return includePathIdentifier; } @@ -80,7 +92,19 @@ public final class DependencyInfo { String[] sysIncludesClone = (String[]) sysIncludes.clone(); return sysIncludesClone; } - public void setCompositeLastModified(long lastMod) { - compositeLastModified = lastMod; +// BEGINFREEHEP + /** + * Returns true, if dependency info is tagged with object t. + * + * @param t object to compare with + * + * @return boolean, true, if tagged with t, otherwise false + */ + public boolean hasTag(Object t) { + return tag == t; } +// public void setCompositeLastModified(long lastMod) { +// compositeLastModified = lastMod; +// } +// ENDFREEHEP } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java b/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java index 48a7278..aaa3881 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java @@ -178,29 +178,35 @@ public final class DependencyTable { return !noNeedToRebuild; } public boolean preview(DependencyInfo parent, DependencyInfo[] children) { - int withCompositeTimes = 0; - long parentCompositeLastModified = parent.getSourceLastModified(); - for (int i = 0; i < children.length; i++) { +// BEGINFREEHEP +// int withCompositeTimes = 0; +// long parentCompositeLastModified = parent.getSourceLastModified(); +// ENDFREEHEP + for (int i = 0; i < children.length; i++) { if (children[i] != null) { // // expedient way to determine if a child forces us to // rebuild // visit(children[i]); - long childCompositeLastModified = children[i] - .getCompositeLastModified(); - if (childCompositeLastModified != Long.MIN_VALUE) { - withCompositeTimes++; - if (childCompositeLastModified > parentCompositeLastModified) { - parentCompositeLastModified = childCompositeLastModified; - } - } +// BEGINFREEHEP +// long childCompositeLastModified = children[i] +// .getCompositeLastModified(); +// if (childCompositeLastModified != Long.MIN_VALUE) { +// withCompositeTimes++; +// if (childCompositeLastModified > parentCompositeLastModified) { +// parentCompositeLastModified = childCompositeLastModified; +// } +// } +// ENDFREEHEP } } - if (withCompositeTimes == children.length) { - parent.setCompositeLastModified(parentCompositeLastModified); - } - // +// BEGINFREEHEP +// if (withCompositeTimes == children.length) { +// parent.setCompositeLastModified(parentCompositeLastModified); +// } +// ENDFREEHEP + // // may have been changed by an earlier call to visit() // return noNeedToRebuild; @@ -212,8 +218,9 @@ public final class DependencyTable { } public boolean visit(DependencyInfo dependInfo) { if (noNeedToRebuild) { - if (CUtil.isSignificantlyAfter(dependInfo.getSourceLastModified(), outputLastModified) - || CUtil.isSignificantlyAfter(dependInfo.getCompositeLastModified(), outputLastModified)) { + if (CUtil.isSignificantlyAfter(dependInfo.getSourceLastModified(), outputLastModified)) { +//FREEHEP +// || CUtil.isSignificantlyAfter(dependInfo.getCompositeLastModified(), outputLastModified)) { noNeedToRebuild = false; } } @@ -222,8 +229,9 @@ public final class DependencyTable { // it has not yet been determined whether // we need to rebuild and the composite modified time // has not been determined for this file - return noNeedToRebuild - && dependInfo.getCompositeLastModified() == Long.MIN_VALUE; + return noNeedToRebuild; +// FREEHEP +// && dependInfo.getCompositeLastModified() == Long.MIN_VALUE; } } private/* final */File baseDir; @@ -466,35 +474,43 @@ public final class DependencyTable { public void walkDependencies(CCTask task, DependencyInfo dependInfo, CompilerConfiguration compiler, DependencyInfo[] stack, DependencyVisitor visitor) throws BuildException { +// BEGINFREEHEP + if (dependInfo.hasTag(visitor)) { + return; + } + dependInfo.setTag(visitor); +// ENDFREEHEP // // visit this node // if visit returns true then // visit the referenced include and sysInclude dependencies // if (visitor.visit(dependInfo)) { - // - // find first null entry on stack - // - int stackPosition = -1; - for (int i = 0; i < stack.length; i++) { - if (stack[i] == null) { - stackPosition = i; - stack[i] = dependInfo; - break; - } else { - // - // if we have appeared early in the calling history - // then we didn't exceed the criteria - if (stack[i] == dependInfo) { - return; - } - } - } - if (stackPosition == -1) { - visitor.stackExhausted(); - return; - } - // +// BEGINFREEHEP +// // +// // find first null entry on stack +// // +// int stackPosition = -1; +// for (int i = 0; i < stack.length; i++) { +// if (stack[i] == null) { +// stackPosition = i; +// stack[i] = dependInfo; +// break; +// } else { +// // +// // if we have appeared early in the calling history +// // then we didn't exceed the criteria +// if (stack[i] == dependInfo) { +// return; +// } +// } +// } +// if (stackPosition == -1) { +// visitor.stackExhausted(); +// return; +// } +// ENDFREEHEP + // // locate dependency infos // String[] includes = dependInfo.getIncludes(); @@ -544,7 +560,8 @@ public final class DependencyTable { } } } - stack[stackPosition] = null; +// FREEHEP +// stack[stackPosition] = null; } } private void writeDependencyInfo(BufferedWriter writer, StringBuffer buf, diff --git a/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java b/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java index cde8837..92595bd 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java @@ -23,7 +23,6 @@ import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.LinkType; import net.sf.antcontrib.cpptasks.compiler.Linker; import net.sf.antcontrib.cpptasks.compiler.Processor; -import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration; import net.sf.antcontrib.cpptasks.gcc.GccLinker; import net.sf.antcontrib.cpptasks.types.FlexLong; import net.sf.antcontrib.cpptasks.types.LibrarySet; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/LinkerEnum.java b/src/main/java/net/sf/antcontrib/cpptasks/LinkerEnum.java index df96723..460860a 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/LinkerEnum.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/LinkerEnum.java @@ -15,6 +15,8 @@ * limitations under the License. */ package net.sf.antcontrib.cpptasks; +import org.apache.tools.ant.types.EnumeratedAttribute; + import net.sf.antcontrib.cpptasks.arm.ADSLinker; import net.sf.antcontrib.cpptasks.borland.BorlandLinker; import net.sf.antcontrib.cpptasks.compaq.CompaqVisualFortranLinker; @@ -27,16 +29,17 @@ import net.sf.antcontrib.cpptasks.gcc.LdLinker; import net.sf.antcontrib.cpptasks.hp.aCCLinker; import net.sf.antcontrib.cpptasks.ibm.VisualAgeLinker; 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 @@ -56,8 +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()), +// 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/main/java/net/sf/antcontrib/cpptasks/OutputTypeEnum.java b/src/main/java/net/sf/antcontrib/cpptasks/OutputTypeEnum.java index 873a99c..77092fa 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/OutputTypeEnum.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/OutputTypeEnum.java @@ -42,7 +42,9 @@ public class OutputTypeEnum extends EnumeratedAttribute { return new String[]{"executable", // executable program "plugin", // plugin module "shared", // dynamically linkable module - "static" // convenience library + "static", +// FREEHEP + "jni" // jni module }; } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/SubsystemEnum.java b/src/main/java/net/sf/antcontrib/cpptasks/SubsystemEnum.java index 19dd207..24dac1b 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/SubsystemEnum.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/SubsystemEnum.java @@ -26,7 +26,8 @@ public final class SubsystemEnum extends EnumeratedAttribute { private final static String[] values = new String[]{"gui", "console", "other"}; public SubsystemEnum() { - setValue("gui"); +// FREEHEP changed from gui into console + setValue("console"); } public String[] getValues() { return (String[]) values.clone(); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/TargetHistoryTable.java b/src/main/java/net/sf/antcontrib/cpptasks/TargetHistoryTable.java index bdab94c..1a6eda1 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/TargetHistoryTable.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/TargetHistoryTable.java @@ -323,7 +323,8 @@ public final class TargetHistoryTable { markForRebuild((TargetInfo) targetInfoEnum.nextElement()); } } - public void markForRebuild(TargetInfo targetInfo) { + // FREEHEP added synchronized + public synchronized void markForRebuild(TargetInfo targetInfo) { // // if it must already be rebuilt, no need to check further // @@ -382,7 +383,8 @@ public final class TargetHistoryTable { } } } - private void update(String configId, String outputName, String[] sources) { +// FREEHEP added synchronized + private synchronized void update(String configId, String outputName, String[] sources) { File outputFile = new File(outputDir, outputName); // // if output file doesn't exist or predates the start of the @@ -407,7 +409,8 @@ public final class TargetHistoryTable { history.put(outputName, newHistory); } } - public void update(TargetInfo linkTarget) { + // FREEHEP added synchronized + public synchronized void update(TargetInfo linkTarget) { File outputFile = linkTarget.getOutput(); String outputName = outputFile.getName(); // diff --git a/src/main/java/net/sf/antcontrib/cpptasks/VersionInfo.java b/src/main/java/net/sf/antcontrib/cpptasks/VersionInfo.java index 92cfeb0..4ddcd14 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/VersionInfo.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/VersionInfo.java @@ -212,7 +212,7 @@ public final class VersionInfo extends DataType { /** * Returns a VersionInfo that reflects any inherited version information. * @return merged version information. - */ +\ */ public VersionInfo merge() { if (isReference()) { VersionInfo refVersion = (VersionInfo) diff --git a/src/main/java/net/sf/antcontrib/cpptasks/antlib.xml b/src/main/java/net/sf/antcontrib/cpptasks/antlib.xml new file mode 100644 index 0000000..5f8af42 --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/antlib.xml @@ -0,0 +1,22 @@ +<?xml version="1.0"?> + <!-- + * + * Copyright 2004 The Ant-Contrib project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + --> + <antlib> + <taskdef resource="cpptasks.tasks" /> + <typedef resource="cpptasks.types" /> + </antlib> +
\ No newline at end of file diff --git a/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java b/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java index c3a6807..6a3c410 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java @@ -16,22 +16,22 @@ */ package net.sf.antcontrib.cpptasks.apple; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -import javax.xml.transform.Result; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.io.File; -import java.io.IOException; -import java.io.FileOutputStream; + +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.sax.SAXTransformerFactory; +import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; + +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; /** * Static class that provides methods to serialize diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java index 1595ae1..ca3c3e3 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compaq/CompaqVisualFortranCompiler.java @@ -115,14 +115,16 @@ public class CompaqVisualFortranCompiler extends CommandLineFortranCompiler { } protected String getIncludeDirSwitch(String includeDir) { StringBuffer buf = new StringBuffer("/include:"); - if (includeDir.indexOf(' ') >= 0) { - buf.append('"'); +// BEGINFREEHEP quotes seem to confuse the compiler +// if (includeDir.indexOf(' ') >= 0) { +// buf.append('"'); +// buf.append(includeDir); +// buf.append('"'); +// } else { buf.append(includeDir); - buf.append('"'); - } 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/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java index d0cd77b..045f1ff 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/AbstractProcessor.java @@ -123,6 +123,13 @@ public abstract class AbstractProcessor implements Processor, Cloneable { String osName = getOSName(); return "Mac OS X".equals(osName); } +// BEGINFREEHEP + protected boolean isWindows() { + String osName = getOSName(); + return (osName != null) && osName.startsWith("Windows"); + } +// ENDFREEHEP + public final String toString() { return getIdentifier(); } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java index 83c59f7..24a0193 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CaptureStreamHandler.java @@ -14,7 +14,9 @@ * 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; import java.io.IOException; import java.io.InputStream; @@ -31,92 +33,135 @@ import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; * @author Curt Arnold */ public class CaptureStreamHandler implements ExecuteStreamHandler { - /** - * Runs an executable and captures the output in a String array - * - * @param cmdline - * command line arguments - * @return output of process - */ - public static String[] run(String[] cmdline) { - CaptureStreamHandler handler = new CaptureStreamHandler(); - Execute exec = new Execute(handler); - exec.setCommandline(cmdline); - try { - int status = exec.execute(); - } catch (IOException ex) { - } - return handler.getOutput(); - } - private InputStream errorStream; - private InputStream fromProcess; - public CaptureStreamHandler() { - } - public String[] getOutput() { - String[] output; - if (fromProcess != null) { - Vector lines = new Vector(10); - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader(errorStream)); - for (int i = 0; i < 2; i++) { - for (int j = 0; j < 100; j++) { - String line = reader.readLine(); - if (line == null) { - reader = new BufferedReader(new InputStreamReader( - fromProcess)); - break; - } - lines.addElement(line); - } - } - } catch (IOException ex) { - } - output = new String[lines.size()]; - lines.copyInto(output); - return output; - } - output = new String[0]; - return output; - } - /** - * Install a handler for the error stream of the subprocess. - * - * @param is - * input stream to read from the error stream from the - * subprocess - */ - public void setProcessErrorStream(InputStream is) throws IOException { - errorStream = is; - } - /** - * Install a handler for the input stream of the subprocess. - * - * @param os - * output stream to write to the standard input stream of the - * subprocess - */ - public void setProcessInputStream(OutputStream os) throws IOException { - os.close(); - } - /** - * Install a handler for the output stream of the subprocess. - * - * @param is - * input stream to read from the error stream from the - * subprocess - */ - public void setProcessOutputStream(InputStream is) throws IOException { - fromProcess = is; - } - /** - * Start handling of the streams. - */ - public void start() throws IOException { - } - /** - * Stop handling of the streams - will not be restarted. - */ - public void stop() { - } + + String[] output; + + /** + * Runs an executable and captures the output in a String array + * + * @param cmdline + * command line arguments + * @return output of process + */ + public static String[] run(String[] cmdline) { + CaptureStreamHandler handler = new CaptureStreamHandler(); + Execute exec = new Execute(handler); + exec.setCommandline(cmdline); + try { + int status = exec.execute(); + } catch (IOException ex) { + } + return handler.getOutput() != null ? handler.getOutput() : new String[0]; + } + + private InputStream processErrorStream; + + private InputStream processOutputStream; + + public CaptureStreamHandler() { + } + + public String[] getOutput() { + return output; + } + + static class Copier extends Thread { + InputStream is; + + Vector lines; + + Copier(InputStream is) { + this.is = is; + lines = new Vector(10); + } + + public void run() { + try { + BufferedReader reader = new BufferedReader( new InputStreamReader(is) ); + while ( true ) { + String line = reader.readLine(); + if ( line == null ) + break; + lines.addElement( line ); + } + } catch (IOException e) { + // Ignore + } + } + + public Vector getLines() { + return lines; + } + } + + /** + * 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 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() { + try { + Copier errorCopier = new Copier(processErrorStream); + Copier outputCopier = new Copier(processOutputStream); + errorCopier.start(); + outputCopier.start(); + errorCopier.join(); + outputCopier.join(); + if (errorCopier.getLines().size() > 0) { + output = new String[errorCopier.getLines().size()]; + errorCopier.getLines().copyInto(output); + } else { + output = new String[outputCopier.getLines().size()]; + outputCopier.getLines().copyInto(output); + } + } catch (Exception e) { + output = new String[0]; + } + } + + /** + * Install a handler for the error stream of the subprocess. + * + * @param is + * input stream to read from the error stream from the subprocess + */ + public void setProcessErrorStream(InputStream is) throws IOException { + processErrorStream = is; + } + + /** + * Install a handler for the input stream of the subprocess. + * + * @param os + * output stream to write to the standard input stream of the + * subprocess + */ + public void setProcessInputStream(OutputStream os) throws IOException { + os.close(); + } + + /** + * Install a handler for the output stream of the subprocess. + * + * @param is + * input stream to read from the error stream from the subprocess + */ + public void setProcessOutputStream(InputStream is) throws IOException { + processOutputStream = is; + } + + /** + * Start handling of the streams. + */ + public void start() throws IOException { + gatherOutput(); + } + + /** + * Stop handling of the streams - will not be restarted. + */ + public void stop() { + } +// ENDFREEHEP } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java index 86594fa..93c3e1e 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java @@ -145,9 +145,10 @@ public abstract class CommandLineLinker extends AbstractLinker String[] libnames = null; LibrarySet[] libsets = specificDef.getActiveLibrarySets(defaultProviders,1); - if (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++) { @@ -336,7 +337,10 @@ public abstract class CommandLineLinker extends AbstractLinker String outputDir, String sourceFile) { String relativePath = CUtil.getRelativePath(outputDir, new File(sourceFile)); - return quoteFilename(buf,relativePath); +// FREEHEP, return the shortest +// return quoteFilename(buf, sourceFile.length() > relativePath.length() ? relativePath : sourceFile); +// FREEHEP trying with always absolute paths, as Windows relPaths have a tighter restriction on length than absPaths... + return quoteFilename(buf, sourceFile); } /** diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java index 70ee93f..67d7e6b 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java @@ -27,6 +27,12 @@ public class LinkType { private OutputTypeEnum outputType = new OutputTypeEnum(); private boolean staticRuntime = false; private SubsystemEnum subsystem = new SubsystemEnum(); + +// BEGINFREEHEP + private boolean linkCPP = true; + private boolean linkFortran = false; +// ENDFREEHEP + /** * Constructor * @@ -44,6 +50,11 @@ public class LinkType { String value = outputType.getValue(); return value.equals("executable"); } + + public boolean isJNIModule() { + String value = outputType.getValue(); + return value.equals("jni"); + } /** * Gets whether the link should produce a plugin module. * @@ -60,7 +71,8 @@ public class LinkType { */ public boolean isSharedLibrary() { String value = outputType.getValue(); - return value.equals("shared") || value.equals("plugin"); +// FREEHEP + return value.equals("shared") || value.equals("plugin") || value.equals("jni"); } /** * Gets whether the link should produce a static library. @@ -147,4 +159,23 @@ public class LinkType { public String getSubsystem() { return subsystem.getValue(); } + +// BEGINFREEHEP + public void setLinkCPP(boolean linkCPP) { + this.linkCPP = linkCPP; + } + + public boolean linkCPP() { + return linkCPP; + } + + public void setLinkFortran(boolean linkFortran) { + this.linkFortran = linkFortran; + } + + public boolean linkFortran() { + return linkFortran; + } +// ENDFREEHEP + } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java index 1281046..d0b8b95 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java @@ -45,6 +45,7 @@ public final class DevStudioCCompiler extends DevStudioCompatibleCCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on safe side + return 32000; // 32767; } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java index 5f37855..cc4493d 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java @@ -108,6 +108,7 @@ public abstract class DevStudioCompatibleCCompiler String lastInclude) { String[] additionalArgs = new String[]{ "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yc"}; + // FREEHEP FIXME we may need /Yd here, but only in debug mode, how do we find out? return new CommandLineCompilerConfiguration(baseConfig, additionalArgs, null, true); } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java index 985dfcf..de006d8 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java @@ -61,7 +61,8 @@ public abstract class DevStudioCompatibleLibrarian extends CommandLineLinker { return new String[0]; } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } public String[] getOutputFileSwitch(String outFile) { StringBuffer buf = new StringBuffer("/OUT:"); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java index 80d2aac..987948b 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java @@ -117,7 +117,8 @@ public abstract class DevStudioCompatibleLinker extends CommandLineLinker { return patterns; } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } public String[] getOutputFileSwitch(String outputFile) { return new String[]{"/OUT:" + outputFile}; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java index fa2e414..effd883 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java @@ -94,7 +94,8 @@ public final class DevStudioMIDLCompiler extends CommandLineCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } protected int getMaximumInputFilesPerCommand() { return 1; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java index 6f8360b..3d9b83e 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java @@ -99,7 +99,8 @@ public final class DevStudioResourceCompiler extends CommandLineCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } protected int getMaximumInputFilesPerCommand() { return 1; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java index 75ddcc7..f1eb2d7 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java @@ -55,11 +55,17 @@ public abstract class AbstractLdLinker extends CommandLineLinker { args.addElement("-g"); } if (isDarwin()) { - if (linkType.isPluginModule()) { + if (linkType.isPluginModule()) { + args.addElement("-bundle"); +// BEGINFREEHEP + } else if (linkType.isJNIModule()) { + args.addElement("-dynamic"); args.addElement("-bundle"); +// ENDFREEHEP } else { if (linkType.isSharedLibrary()) { - args.addElement("-prebind"); +// FREEHEP no longer needed for 10.4+ +// args.addElement("-prebind"); args.addElement("-dynamiclib"); } } @@ -121,11 +127,16 @@ public abstract class AbstractLdLinker extends CommandLineLinker { // if (set.getType() != previousLibraryType) { if (set.getType() != null && "static".equals(set.getType().getValue())) { +// BEGINFREEHEP not on MacOS X + if (!isDarwin()) { endargs.addElement(getStaticLibFlag()); previousLibraryType = set.getType(); + } +//ENDFREEHEP } else { +// FREEHEP not on MacOS X, recheck this! if (set.getType() == null || - !"framework".equals(set.getType().getValue()) || + !"framework".equals(set.getType().getValue()) && !isDarwin()) { endargs.addElement(getDynamicLibFlag()); previousLibraryType = set.getType(); @@ -137,7 +148,8 @@ public abstract class AbstractLdLinker extends CommandLineLinker { "framework".equals(set.getType().getValue()) && isDarwin()) { buf.setLength(0); - buf.append("-framework "); +// FREEHEP, added as endarg w/o trailing space to avoid quoting! + endargs.addElement("-framework"); } int initialLength = buf.length(); for (int j = 0; j < libs.length; j++) { @@ -154,6 +166,13 @@ public abstract class AbstractLdLinker extends CommandLineLinker { endargs.addElement(buf.toString()); } } + +// BEGINFREEHEP if last was -Bstatic reset it to -Bdynamic so that libc and libm can be found as shareables + if ((previousLibraryType != null) && previousLibraryType.getValue().equals("static") && !isDarwin()) { + endargs.addElement(getDynamicLibFlag()); + } +// ENDFREEHEP + String rc[] = new String[libnames.size()]; for (int i = 0; i < libnames.size(); i++) { rc[i] = (String) libnames.elementAt(i); @@ -239,7 +258,8 @@ public abstract class AbstractLdLinker extends CommandLineLinker { return patterns; } public int getMaximumCommandLength() { - return Integer.MAX_VALUE; +// FREEHEP + return isWindows() ? 20000 : Integer.MAX_VALUE; } public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { String[] baseNames = super.getOutputFileNames(baseName, versionInfo); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java index 999ccf7..f9e4c0b 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java @@ -59,6 +59,11 @@ public final class GccCCompiler extends GccCompatibleCCompiler { sourceExtensions, headerExtensions, false, new GccCCompiler("g77", sourceExtensions, headerExtensions, true, null, false, null), false, null); +// FREEHEP + private static final GccCCompiler gfortranInstance = new GccCCompiler("gfortran", + sourceExtensions, headerExtensions, false, + new GccCCompiler("gfortran", sourceExtensions, headerExtensions, true, + null, false, null), false, null); private static final GccCCompiler gppInstance = new GccCCompiler("g++", sourceExtensions, headerExtensions, false, new GccCCompiler("g++", sourceExtensions, headerExtensions, true, @@ -80,6 +85,14 @@ public final class GccCCompiler extends GccCompatibleCCompiler { return g77Instance; } /** + * Gets g77 adapter + */ +// FREEHEPBEGIN + public static GccCCompiler getGFortranInstance() { + return gfortranInstance; + } +// FREEHEPEND + /** * Gets gpp adapter */ public static GccCCompiler getGppInstance() { @@ -118,6 +131,12 @@ public final class GccCCompiler extends GccCompatibleCCompiler { if (isPICMeaningful && linkType.isSharedLibrary()) { args.addElement("-fPIC"); } +// 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) { @@ -237,6 +256,6 @@ public final class GccCCompiler extends GccCompatibleCCompiler { return GccLinker.getInstance().getLinker(linkType); } public int getMaximumCommandLength() { - return Integer.MAX_VALUE; + return isWindows() ? 20000 : Integer.MAX_VALUE; } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java index 0485fba..fc7bbfc 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java @@ -98,10 +98,16 @@ public abstract class GccCompatibleCCompiler extends CommandLineCCompiler { args.addElement("-mwindows"); } } - if (rtti != null && !rtti.booleanValue()) { - args.addElement("-fno-rtti"); +// BEGINFREEHEP, tests have been modified + if (!exceptions) { + args.addElement("-fno-exceptions"); } - +// ENDFREEHEP +// BEGINFREEHEP moved to GccCCompiler +// if (rtti != null && !rtti.booleanValue()) { +// args.addElement("-fno-rtti"); +// } +// ENDFREEHEP } /** * Adds an include path to the command. diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java index c4720c8..a551bfa 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccLinker.java @@ -33,10 +33,13 @@ 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", +// 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, +// FREEHEP refactored dllLinker to soLinker + private static final GccLinker soLinker = new GccLinker("gcc", objFiles, discardFiles, "lib", ".so", false, new GccLinker("gcc", objFiles, discardFiles, "lib", ".so", true, null)); private static final GccLinker instance = new GccLinker("gcc", objFiles, @@ -45,6 +48,11 @@ public class GccLinker extends AbstractLdLinker { objFiles, discardFiles, "lib", ".bundle", 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); +// FREEHEP added dllLinker for windows + private static final GccLinker dllLinker = new GccLinker("gcc", + objFiles, discardFiles, "", ".dll", false, null); public static GccLinker getInstance() { return instance; } @@ -191,20 +199,17 @@ public class GccLinker extends AbstractLdLinker { if (type.isStaticLibrary()) { return GccLibrarian.getInstance(); } +// BEGINFREEHEP + if (type.isJNIModule()) { + return isDarwin() ? machJNILinker : isWindows() ? dllLinker : soLinker; + } if (type.isPluginModule()) { - if (isDarwin()) { - return machBundleLinker; - } else { - return dllLinker; - } + return isDarwin() ? machBundleLinker : isWindows() ? dllLinker : soLinker; } if (type.isSharedLibrary()) { - if (isDarwin()) { - return machDllLinker; - } else { - return dllLinker; - } + return isDarwin() ? machDllLinker : isWindows() ? dllLinker : soLinker; } +// ENDFREEHEP return instance; } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java index f3bc174..043720d 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java @@ -33,7 +33,8 @@ public class GppLinker extends AbstractLdLinker { protected static final String[] discardFiles = new String[0]; protected static final String[] objFiles = new String[]{".o", ".a", ".lib", ".dll", ".so", ".sl"}; - private static final GppLinker dllLinker = new GppLinker("gcc", objFiles, + // FREEHEP refactored dllLinker into soLinker + private static final GppLinker soLinker = new GppLinker("gcc", objFiles, discardFiles, "lib", ".so", false, new GppLinker("gcc", objFiles, discardFiles, "lib", ".so", true, null)); private final static String libPrefix = "libraries: ="; @@ -41,18 +42,29 @@ public class GppLinker extends AbstractLdLinker { ".lib", ".dll", ".so", ".sl"}; private static String[] linkerOptions = new String[]{"-bundle", "-dylib", "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib", - "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker"}; + "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker", + // FREEHEP + "-static-libgcc", "-shared-libgcc" }; private static final GppLinker instance = new GppLinker("gcc", objFiles, discardFiles, "", "", false, null); private static final GppLinker machDllLinker = new GppLinker("gcc", objFiles, discardFiles, "lib", ".dylib", 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); + // FREEHEP added dllLinker for windows + private static final GppLinker dllLinker = new GppLinker("gcc", objFiles, + discardFiles, "", ".dll", false, null); public static GppLinker getInstance() { return instance; } private File[] libDirs; private String runtimeLibrary; + // FREEEHEP + private String gccLibrary, gfortranLibrary; + protected GppLinker(String command, String[] extensions, String[] ignoredExtensions, String outputPrefix, String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) { @@ -69,22 +81,66 @@ public class GppLinker extends AbstractLdLinker { args.addElement("-mwindows"); } } - 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]; + // BEGINFREEHEP link or not with libstdc++ + // for MacOS X see: + // http://developer.apple.com/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/LibCPPDeployment.html + gfortranLibrary = null; + if (linkType.linkFortran()) { + if (linkType.isStaticRuntime()) { + String[] cmdin = new String[] { "gfortran", + "-print-file-name=libgfortran.a" }; + String[] cmdout = CaptureStreamHandler.run(cmdin); + if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) { + gfortranLibrary = cmdout[0]; + } + } else { + gfortranLibrary = "-lgfortran"; + } + } + + runtimeLibrary = null; + if (linkType.linkCPP()) { + if (linkType.isStaticRuntime()) { + if (isDarwin()) { + runtimeLibrary = "-lstdc++-static"; + } else { + String[] cmdin = new String[] { "g++", + "-print-file-name=libstdc++.a" }; + String[] cmdout = CaptureStreamHandler.run(cmdin); + if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) { + runtimeLibrary = cmdout[0]; + } + } } else { - runtimeLibrary = null; + runtimeLibrary = "-lstdc++"; } + } + + gccLibrary = null; + if (linkType.isStaticRuntime()) { + gccLibrary = "-static-libgcc"; } else { - runtimeLibrary = "-lstdc++"; + if (linkType.linkCPP()) { + // NOTE: added -fexceptions here for MacOS X + gccLibrary = "-fexceptions"; + } else { + gccLibrary = "-shared-libgcc"; + } } + // ENDFREEHEP } public String[] addLibrarySets(CCTask task, LibrarySet[] libsets, Vector preargs, Vector midargs, Vector endargs) { String[] rs = super.addLibrarySets(task, libsets, preargs, midargs, endargs); + // BEGINFREEHEP + if (gfortranLibrary != null) { + endargs.addElement(gfortranLibrary); + } + if (gccLibrary != null) { + endargs.addElement(gccLibrary); + } + // ENDFREEHEP if (runtimeLibrary != null) { endargs.addElement(runtimeLibrary); } @@ -184,20 +240,20 @@ public class GppLinker extends AbstractLdLinker { if (type.isStaticLibrary()) { return GccLibrarian.getInstance(); } + // BEGINFREEHEP + if (type.isJNIModule()) { + return isDarwin() ? machJNILinker : isWindows() ? dllLinker + : soLinker; + } if (type.isPluginModule()) { - if (GccProcessor.getMachine().indexOf("darwin") >= 0) { - return machPluginLinker; - } else { - return dllLinker; - } + return isDarwin() ? machPluginLinker : isWindows() ? dllLinker + : soLinker; } if (type.isSharedLibrary()) { - if (GccProcessor.getMachine().indexOf("darwin") >= 0) { - return machDllLinker; - } else { - return dllLinker; - } + return isDarwin() ? machDllLinker : isWindows() ? dllLinker + : soLinker; } + // ENDFREEHEP return instance; } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/ide/CommentDef.java b/src/main/java/net/sf/antcontrib/cpptasks/ide/CommentDef.java index 2221aba..3a6f19f 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/ide/CommentDef.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/ide/CommentDef.java @@ -16,11 +16,6 @@ */ package net.sf.antcontrib.cpptasks.ide; -import org.apache.tools.ant.util.StringUtils; - -import java.io.File; -import java.util.Collections; -import java.util.List; /** * Defines a comment to place in the generated project files. diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java index 12fd5bd..085d61e 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CCompiler.java @@ -50,7 +50,8 @@ public final class IntelLinux32CCompiler extends GccCompatibleCCompiler { return this; } public Linker getLinker(LinkType type) { - return IntelLinux32Linker.getInstance().getLinker(type); +// FREEHEP + return IntelLinux32CLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { return Integer.MAX_VALUE; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CLinker.java new file mode 100644 index 0000000..49a8a57 --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32CLinker.java @@ -0,0 +1,35 @@ +// FREEHEP +package net.sf.antcontrib.cpptasks.intel; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker; +import net.sf.antcontrib.cpptasks.gcc.GccLibrarian; +public final class IntelLinux32CLinker extends AbstractLdLinker { + private static final String[] discardFiles = new String[0]; + private static final String[] libtoolObjFiles = new String[]{".fo", ".a", + ".lib", ".dll", ".so", ".sl"}; + private static final String[] objFiles = new String[]{".o", ".a", ".lib", + ".dll", ".so", ".sl"}; + private static final IntelLinux32CLinker dllLinker = new IntelLinux32CLinker( + "lib", ".so", false, new IntelLinux32CLinker("lib", ".so", true, + null)); + private static final IntelLinux32CLinker instance = new IntelLinux32CLinker( + "", "", false, null); + public static IntelLinux32CLinker getInstance() { + return instance; + } + private IntelLinux32CLinker(String outputPrefix, String outputSuffix, + boolean isLibtool, IntelLinux32CLinker libtoolLinker) { + super("icc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, + isLibtool, libtoolLinker); + } + public Linker getLinker(LinkType type) { + if (type.isStaticLibrary()) { + return GccLibrarian.getInstance(); + } + if (type.isSharedLibrary()) { + return dllLinker; + } + return instance; + } +} diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Compiler.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Compiler.java new file mode 100644 index 0000000..d4feac3 --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Compiler.java @@ -0,0 +1,36 @@ +// FREEHEP +package net.sf.antcontrib.cpptasks.intel; +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.gcc.GccCompatibleCCompiler; + +import org.apache.tools.ant.types.Environment; + +public final class IntelLinux32Compiler extends GccCompatibleCCompiler { + private static final IntelLinux32Compiler instance = new IntelLinux32Compiler( + false, new IntelLinux32Compiler(true, null, false, null), false, + null); + public static IntelLinux32Compiler getInstance() { + return instance; + } + private IntelLinux32Compiler(boolean isLibtool, + IntelLinux32Compiler libtoolCompiler, boolean newEnvironment, + Environment env) { + super("icpc", "-V", isLibtool, libtoolCompiler, newEnvironment, env); + } + public Processor changeEnvironment(boolean newEnvironment, Environment env) { + if (newEnvironment || env != null) { + return new IntelLinux32Compiler(getLibtool(), + (IntelLinux32Compiler) getLibtoolCompiler(), + newEnvironment, env); + } + return this; + } + public Linker getLinker(LinkType type) { + return IntelLinux32Linker.getInstance().getLinker(type); + } + public int getMaximumCommandLength() { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java index 9bed915..e6ddee1 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux32Linker.java @@ -40,7 +40,8 @@ public final class IntelLinux32Linker extends AbstractLdLinker { } private IntelLinux32Linker(String outputPrefix, String outputSuffix, boolean isLibtool, IntelLinux32Linker libtoolLinker) { - super("icc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, +// FREEHEP + super("icpc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, isLibtool, libtoolLinker); } public Linker getLinker(LinkType type) { diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java index 9ed6393..1d9f6c5 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CCompiler.java @@ -50,7 +50,8 @@ public final class IntelLinux64CCompiler extends GccCompatibleCCompiler { return this; } public Linker getLinker(LinkType type) { - return IntelLinux64Linker.getInstance().getLinker(type); +// FREEHEP + return IntelLinux64CLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { return Integer.MAX_VALUE; diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CLinker.java new file mode 100644 index 0000000..ec25e9e --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64CLinker.java @@ -0,0 +1,36 @@ +// FREEHEP +package net.sf.antcontrib.cpptasks.intel; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker; +import net.sf.antcontrib.cpptasks.gcc.GccLibrarian; + +public final class IntelLinux64CLinker extends AbstractLdLinker { + private static final String[] discardFiles = new String[0]; + private static final String[] libtoolObjFiles = new String[]{".fo", ".a", + ".lib", ".dll", ".so", ".sl"}; + private static final String[] objFiles = new String[]{".o", ".a", ".lib", + ".dll", ".so", ".sl"}; + private static final IntelLinux64CLinker dllLinker = new IntelLinux64CLinker( + "lib", ".so", false, new IntelLinux64CLinker("lib", ".so", true, + null)); + private static final IntelLinux64CLinker instance = new IntelLinux64CLinker( + "", "", false, null); + public static IntelLinux64CLinker getInstance() { + return instance; + } + private IntelLinux64CLinker(String outputPrefix, String outputSuffix, + boolean isLibtool, IntelLinux64CLinker libtoolLinker) { + super("ecc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, + isLibtool, libtoolLinker); + } + public Linker getLinker(LinkType type) { + if (type.isStaticLibrary()) { + return GccLibrarian.getInstance(); + } + if (type.isSharedLibrary()) { + return dllLinker; + } + return instance; + } +} diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Compiler.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Compiler.java new file mode 100644 index 0000000..531de0c --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Compiler.java @@ -0,0 +1,36 @@ +// FREEHEP +package net.sf.antcontrib.cpptasks.intel; +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.gcc.GccCompatibleCCompiler; + +import org.apache.tools.ant.types.Environment; + +public final class IntelLinux64Compiler extends GccCompatibleCCompiler { + private static final IntelLinux64Compiler instance = new IntelLinux64Compiler( + false, new IntelLinux64Compiler(true, null, false, null), false, + null); + public static IntelLinux64Compiler getInstance() { + return instance; + } + private IntelLinux64Compiler(boolean isLibtool, + IntelLinux64Compiler libtoolCompiler, boolean newEnvironment, + Environment env) { + super("ecpc", "-V", isLibtool, libtoolCompiler, newEnvironment, env); + } + public Processor changeEnvironment(boolean newEnvironment, Environment env) { + if (newEnvironment || env != null) { + return new IntelLinux64Compiler(getLibtool(), + (IntelLinux64Compiler) this.getLibtoolCompiler(), + newEnvironment, env); + } + return this; + } + public Linker getLinker(LinkType type) { + return IntelLinux64Linker.getInstance().getLinker(type); + } + public int getMaximumCommandLength() { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java index d712e5b..6798c3f 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinux64Linker.java @@ -40,7 +40,8 @@ public final class IntelLinux64Linker extends AbstractLdLinker { } private IntelLinux64Linker(String outputPrefix, String outputSuffix, boolean isLibtool, IntelLinux64Linker libtoolLinker) { - super("ecc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, +// FREEHEP + super("ecpc", "-V", objFiles, discardFiles, outputPrefix, outputSuffix, isLibtool, libtoolLinker); } public Linker getLinker(LinkType type) { diff --git a/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinuxFortranCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinuxFortranCompiler.java new file mode 100644 index 0000000..b9e4467 --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/intel/IntelLinuxFortranCompiler.java @@ -0,0 +1,37 @@ +// BEGINFREEHEP +package net.sf.antcontrib.cpptasks.intel; +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.gcc.GccCompatibleCCompiler; + +import org.apache.tools.ant.types.Environment; + +public final class IntelLinuxFortranCompiler extends GccCompatibleCCompiler { + private static final IntelLinuxFortranCompiler instance = new IntelLinuxFortranCompiler( + false, new IntelLinuxFortranCompiler(true, null, false, null), false, + null); + public static IntelLinuxFortranCompiler getInstance() { + return instance; + } + private IntelLinuxFortranCompiler(boolean isLibtool, + IntelLinuxFortranCompiler libtoolCompiler, boolean newEnvironment, + Environment env) { + super("ifort", "-V", isLibtool, libtoolCompiler, newEnvironment, env); + } + public Processor changeEnvironment(boolean newEnvironment, Environment env) { + if (newEnvironment || env != null) { + return new IntelLinuxFortranCompiler(getLibtool(), + (IntelLinuxFortranCompiler) getLibtoolCompiler(), + newEnvironment, env); + } + return this; + } + public Linker getLinker(LinkType type) { + return IntelLinux32Linker.getInstance().getLinker(type); + } + public int getMaximumCommandLength() { + return Integer.MAX_VALUE; + } +} +// ENDFREEHEP
\ No newline at end of file diff --git a/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java index 47d2155..91ec3d1 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java @@ -51,7 +51,8 @@ public final class ForteCCLinker extends AbstractLdLinker { args.addElement("-g"); } if (linkType.isStaticRuntime()) { - args.addElement("-static"); +// FREEHEP changed -static + args.addElement("-staticlib=%all"); } if (linkType.isSharedLibrary()) { args.addElement("-G"); diff --git a/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCompiler.java new file mode 100644 index 0000000..9fb43da --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteCCompiler.java @@ -0,0 +1,98 @@ +/* FREEHEP + */ +package net.sf.antcontrib.cpptasks.sun; +import java.io.File; +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler; +import net.sf.antcontrib.cpptasks.OptimizationEnum; +/** + * Adapter for the Sun (r) Forte (tm) C compiler + * + * @author Mark Donszelmann + */ +public final class ForteCCompiler extends GccCompatibleCCompiler { + private static final ForteCCompiler instance = new ForteCCompiler("cc"); + /** + * Gets singleton instance of this class + */ + public static ForteCCompiler getInstance() { + return instance; + } + private String identifier; + private File[] includePath; + /** + * Private constructor. Use ForteCCompiler.getInstance() to get singleton + * instance of this class. + */ + private ForteCCompiler(String command) { + super(command, "-V", false, null, false, null); + } + public void addImpliedArgs(final Vector args, + final boolean debug, + final boolean multithreaded, + final boolean exceptions, + final LinkType linkType, + final Boolean rtti, + final OptimizationEnum optimization) { + args.addElement("-c"); + if (debug) { + args.addElement("-g"); + } + if (optimization != null) { + if (optimization.isSpeed()) { + args.addElement("-xO2"); + } + } + if (multithreaded) { + args.addElement("-mt"); + } + if (linkType.isSharedLibrary()) { + args.addElement("-KPIC"); + } + + } + public void addWarningSwitch(Vector args, int level) { + switch (level) { + case 0 : + args.addElement("-w"); + break; + case 1 : + case 2 : + args.addElement("+w"); + break; + case 3 : + case 4 : + case 5 : + args.addElement("+w2"); + break; + } + } + public File[] getEnvironmentIncludePath() { + if (includePath == null) { + File ccLoc = CUtil.getExecutableLocation("cc"); + if (ccLoc != null) { + File compilerIncludeDir = new File( + new File(ccLoc, "../include").getAbsolutePath()); + if (compilerIncludeDir.exists()) { + includePath = new File[2]; + includePath[0] = compilerIncludeDir; + } + } + if (includePath == null) { + includePath = new File[1]; + } + includePath[includePath.length - 1] = new File("/usr/include"); + } + return includePath; + } + public Linker getLinker(LinkType linkType) { + return ForteCCLinker.getInstance().getLinker(linkType); + } + public int getMaximumCommandLength() { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteF77Compiler.java b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteF77Compiler.java new file mode 100644 index 0000000..2230b66 --- /dev/null +++ b/src/main/java/net/sf/antcontrib/cpptasks/sun/ForteF77Compiler.java @@ -0,0 +1,98 @@ +/* FREEHEP + */ +package net.sf.antcontrib.cpptasks.sun; +import java.io.File; +import java.util.Vector; + +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler; +import net.sf.antcontrib.cpptasks.OptimizationEnum; +/** + * Adapter for the Sun (r) Forte (tm) F77 compiler + * + * @author Mark Donszelmann + */ +public final class ForteF77Compiler extends GccCompatibleCCompiler { + private static final ForteF77Compiler instance = new ForteF77Compiler("f77"); + /** + * Gets singleton instance of this class + */ + public static ForteF77Compiler getInstance() { + return instance; + } + private String identifier; + private File[] includePath; + /** + * Private constructor. Use ForteF77Compiler.getInstance() to get singleton + * instance of this class. + */ + private ForteF77Compiler(String command) { + super(command, "-V", false, null, false, null); + } + public void addImpliedArgs(final Vector args, + final boolean debug, + final boolean multithreaded, + final boolean exceptions, + final LinkType linkType, + final Boolean rtti, + final OptimizationEnum optimization) { + args.addElement("-c"); + if (debug) { + args.addElement("-g"); + } + if (optimization != null) { + if (optimization.isSpeed()) { + args.addElement("-xO2"); + } + } + if (multithreaded) { + args.addElement("-mt"); + } + if (linkType.isSharedLibrary()) { + args.addElement("-KPIC"); + } + + } + public void addWarningSwitch(Vector args, int level) { + switch (level) { + case 0 : + args.addElement("-w"); + break; + case 1 : + case 2 : + args.addElement("+w"); + break; + case 3 : + case 4 : + case 5 : + args.addElement("+w2"); + break; + } + } + public File[] getEnvironmentIncludePath() { + if (includePath == null) { + File f77Loc = CUtil.getExecutableLocation("f77"); + if (f77Loc != null) { + File compilerIncludeDir = new File( + new File(f77Loc, "../include").getAbsolutePath()); + if (compilerIncludeDir.exists()) { + includePath = new File[2]; + includePath[0] = compilerIncludeDir; + } + } + if (includePath == null) { + includePath = new File[1]; + } + includePath[includePath.length - 1] = new File("/usr/include"); + } + return includePath; + } + public Linker getLinker(LinkType linkType) { + return ForteCCLinker.getInstance().getLinker(linkType); + } + public int getMaximumCommandLength() { + return Integer.MAX_VALUE; + } +} diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE index 340dceb..70964f8 100644 --- a/src/main/resources/META-INF/NOTICE +++ b/src/main/resources/META-INF/NOTICE @@ -2,3 +2,5 @@ This product includes software developed by The Ant-Contrib project (http://ant-contrib.sourceforge.net) This product includes software developed by The Apache Software Foundation (http://www.apache.org/). +This product was changed by FreeHEP + The FreeHEP project (http://java.freehep.org/). diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java index 12e1967..017dc02 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCompilerDef.java @@ -225,7 +225,8 @@ public final class TestCompilerDef CompilerDef extendedLinker = (CompilerDef) createExtendedProcessorDef( baseLinker); String[] preArgs = getPreArguments(extendedLinker); - assertEquals(2, preArgs.length); + // FREEHEP, passes extra option + assertEquals(3, preArgs.length); assertEquals("/base", preArgs[0]); } @@ -244,8 +245,10 @@ public final class TestCompilerDef CompilerDef extendedCompiler = (CompilerDef) createExtendedProcessorDef( baseCompiler); String[] preArgs = getPreArguments(extendedCompiler); - assertEquals(2, preArgs.length); - assertEquals("-Dfoo=bar", preArgs[1]); + // BEGINFREEHEP, passes extra option + assertEquals(3, preArgs.length); + assertEquals("-Dfoo=bar", preArgs[2]); + // ENDFREEHEP } /** @@ -259,8 +262,10 @@ public final class TestCompilerDef IncludePath path = baseCompiler.createIncludePath(); path.setPath("/tmp"); String[] preArgs = getPreArguments(extendedCompiler); - assertEquals(2, preArgs.length); - assertEquals("-I", preArgs[1].substring(0, 2)); + // BEGINFREEHEP, passes extra option + assertEquals(3, preArgs.length); + assertEquals("-I", preArgs[2].substring(0, 2)); + // ENDFREEHEP } /** @@ -274,8 +279,10 @@ public final class TestCompilerDef SystemIncludePath path = baseCompiler.createSysIncludePath(); path.setPath("/tmp"); String[] preArgs = getPreArguments(extendedCompiler); - assertEquals(2, preArgs.length); - assertEquals("-I", preArgs[1].substring(0, 2)); + // BEGINFREEHEP, passes extra option + assertEquals(3, preArgs.length); + assertEquals("-I", preArgs[2].substring(0, 2)); + // ENDFREEHEP } /** diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java index 994b068..e35c5e6 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java @@ -243,7 +243,8 @@ public final class TestLinkerDef setLinkerName(extendedLinker, "msvc"); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/BASE:0x2710", preArgs[3]); } @@ -260,7 +261,8 @@ public final class TestLinkerDef setLinkerName(extendedLinker, "msvc"); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/STACK:0x2710", preArgs[3]); } @@ -291,7 +293,8 @@ public final class TestLinkerDef setLinkerName(extendedLinker, "msvc"); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/FIXED", preArgs[3]); } @@ -308,7 +311,8 @@ public final class TestLinkerDef setLinkerName(extendedLinker, "msvc"); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:YES", preArgs[2]); } @@ -324,7 +328,8 @@ public final class TestLinkerDef setLinkerName(extendedLinker, "msvc"); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/MAP", preArgs[3]); } @@ -349,7 +354,8 @@ public final class TestLinkerDef extendedLinker.setBase(new FlexLong("10000")); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/BASE:0x2710", preArgs[3]); } @@ -367,7 +373,8 @@ public final class TestLinkerDef extendedLinker.setBase(new FlexLong("10000")); String[] preArgs = getPreArguments(extendedLinker); assertEquals("/NOLOGO", preArgs[0]); - assertEquals("/SUBSYSTEM:WINDOWS", preArgs[1]); + // FREEHEP changed from WINDOWS into CONSOLE + assertEquals("/SUBSYSTEM:CONSOLE", preArgs[1]); assertEquals("/INCREMENTAL:NO", preArgs[2]); assertEquals("/BASE:0x2710", preArgs[3]); } diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java index c4e2905..8bce7ec 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestProcessorDef.java @@ -257,7 +257,8 @@ public abstract class TestProcessorDef baseLinker.setDebug(true); ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); String[] preArgs = getPreArguments(extendedLinker); - assertEquals("-g", preArgs[preArgs.length - 1]); + // FREEHEP, passes (sometimes) extra option + assertEquals("-g", preArgs[Math.max(preArgs.length - 2, 0)]); } /** diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java index dccb986..8f6903e 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudio2005CCompiler.java @@ -18,8 +18,6 @@ package net.sf.antcontrib.cpptasks.devstudio; import java.util.Vector; import junit.framework.TestCase; - -import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; /** * Test Microsoft C/C++ compiler adapter * diff --git a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java index eeeec14..0e546e9 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/devstudio/TestDevStudioCCompiler.java @@ -18,8 +18,6 @@ package net.sf.antcontrib.cpptasks.devstudio; import java.util.Vector; import junit.framework.TestCase; - -import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; /** * Test Microsoft C/C++ compiler adapter * diff --git a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java index 63996c5..958f93b 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/gcc/TestAbstractLdLinker.java @@ -73,9 +73,11 @@ public class TestAbstractLdLinker extends TestCase { pluginOutType.setValue("shared"); pluginType.setOutputType(pluginOutType); linker.addImpliedArgs(false, pluginType, args); - assertEquals(2, args.size()); - assertEquals("-prebind", args.elementAt(0)); - assertEquals("-dynamiclib", args.elementAt(1)); + // FIXME NAR-103 + // BEGINFREEHEP + assertEquals(1, args.size()); + assertEquals("-dynamiclib", args.elementAt(0)); + // ENDFREEHEP } /** * Checks for proper arguments for plugin generation on Darwin @@ -168,11 +170,14 @@ public class TestAbstractLdLinker extends TestCase { String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, endargs); assertEquals("-L", ((String) endargs.elementAt(0)).substring(0, 2)); - assertEquals("-Bdynamic", (String) endargs.elementAt(1)); - assertEquals("-lbart", (String) endargs.elementAt(2)); - assertEquals("-lcart", (String) endargs.elementAt(3)); - assertEquals("-ldart", (String) endargs.elementAt(4)); - assertEquals(endargs.size(), 5); +// FIXME NAR-103 +// BEGINFREEHEP +// assertEquals("-Bdynamic", (String) endargs.elementAt(1)); + assertEquals("-lbart", (String) endargs.elementAt(1)); + assertEquals("-lcart", (String) endargs.elementAt(2)); + assertEquals("-ldart", (String) endargs.elementAt(3)); + assertEquals(endargs.size(), 4); + // ENDFREEHEP } public void testAddLibrarySetLibFrameworkDarwin() { System.setProperty("os.name", "Mac OS X"); @@ -191,11 +196,22 @@ public class TestAbstractLdLinker extends TestCase { Vector endargs = new Vector(); String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, endargs); +// FIXME NAR-103 +// BEGINFREEHEP + /* assertEquals("-F", ((String) endargs.elementAt(0)).substring(0, 2)); assertEquals("-framework bart", (String) endargs.elementAt(1)); assertEquals("-framework cart", (String) endargs.elementAt(2)); assertEquals("-framework dart", (String) endargs.elementAt(3)); assertEquals(endargs.size(), 4); + */ + assertEquals("-F", ((String) endargs.elementAt(0)).substring(0, 2)); + assertEquals("-framework", (String) endargs.elementAt(1)); + assertEquals("bart", (String) endargs.elementAt(2)); + assertEquals("cart", (String) endargs.elementAt(3)); + assertEquals("dart", (String) endargs.elementAt(4)); + assertEquals(endargs.size(), 5); +// ENDFREEHEP } public void testAddLibraryStatic() { AbstractLdLinker linker = getLinker(); @@ -219,12 +235,22 @@ public class TestAbstractLdLinker extends TestCase { Vector endargs = new Vector(); String[] rc = linker.addLibrarySets(task, sets, preargs, midargs, endargs); + for (int i=0; i<endargs.size(); i++) System.err.println(endargs.get( i )); +// NAR-103 +// BEGINFREEHEP + /* assertEquals("-lbart", (String) endargs.elementAt(0)); assertEquals("-Bstatic", (String) endargs.elementAt(1)); assertEquals("-lcart", (String) endargs.elementAt(2)); assertEquals("-Bdynamic", (String) endargs.elementAt(3)); assertEquals("-ldart", (String) endargs.elementAt(4)); assertEquals(endargs.size(), 5); + */ + assertEquals("-lbart", (String) endargs.elementAt(0)); + assertEquals("-lcart", (String) endargs.elementAt(1)); + assertEquals("-ldart", (String) endargs.elementAt(2)); + assertEquals(endargs.size(), 3); +// ENDFREEHEP } public void testLibReturnValue() { AbstractLdLinker linker = getLinker(); diff --git a/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java index 073463e..6c3a8b5 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/hp/TestaCCCompiler.java @@ -15,10 +15,7 @@ * limitations under the License. */ package net.sf.antcontrib.cpptasks.hp; -import java.util.Vector; - import junit.framework.TestCase; - import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; /** * Test HP aCC compiler adapter diff --git a/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java b/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java index 62a513e..87e7020 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/ibm/TestVisualAgeCCompiler.java @@ -15,10 +15,7 @@ * limitations under the License. */ package net.sf.antcontrib.cpptasks.ibm; -import java.util.Vector; - import junit.framework.TestCase; - import net.sf.antcontrib.cpptasks.compiler.AbstractProcessor; /** * Test IBM Visual Age compiler adapter |