Index: build.xml =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/build.xml,v retrieving revision 1.44 diff -u -r1.44 build.xml --- build.xml 5 May 2004 03:50:45 -0000 1.44 +++ build.xml 11 May 2004 04:43:46 -0000 @@ -363,6 +363,7 @@ + @@ -375,6 +376,7 @@ + Index: samples/cppunit.ant =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/samples/cppunit.ant,v retrieving revision 1.4 diff -u -r1.4 cppunit.ant --- samples/cppunit.ant 26 Apr 2004 03:01:16 -0000 1.4 +++ samples/cppunit.ant 11 May 2004 04:43:46 -0000 @@ -56,7 +56,12 @@ --> + productversion="1.9.14" + compatibilityversion="1" + legalcopyright="Copyright © 1996-2000 by Michael Feathers <mfeathers@objectmentor.com>" + productname="cppunit" + companyname="Cppunit project <http://cppunit.sourceforge.net>" + /> @@ -85,6 +90,9 @@ + + + + + - + @@ -176,12 +186,14 @@ rtti="true" optimize="speed" name="${compiler}"> + + - + @@ -197,13 +209,15 @@ optimize="speed" name="${compiler}" outputfileproperty="test.exe"> + + - + @@ -219,6 +233,8 @@ rtti="true" optimize="speed" outputfileproperty="test.exe"> + + @@ -226,7 +242,7 @@ - + @@ -251,31 +267,7 @@ - - - - - - - - - - - - - - - - - - - - - + + + - + + + @@ -295,7 +291,7 @@ - + @@ -311,6 +307,8 @@ optimize="speed" name="${compiler}" debug="${debug}"> + + @@ -319,7 +317,7 @@ - + @@ -339,11 +337,13 @@ includes="*.cpp" excludes="DllPlugInTester.cpp"/> + + - + @@ -362,6 +362,8 @@ rtti="true" optimize="speed" debug="${debug}"> + + @@ -369,7 +371,7 @@ - + @@ -389,6 +391,8 @@ rtti="true" optimize="speed" debug="${debug}"> + + @@ -396,7 +400,7 @@ - + @@ -422,6 +426,8 @@ rtti="true" objdir="${obj.dir}/simple" debug="${debug}"> + + @@ -431,7 +437,7 @@ - + @@ -462,6 +468,8 @@ optimize="speed" rtti="true" debug="${debug}"> + + Index: src/net/sf/antcontrib/cpptasks/CCTask.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CCTask.java,v retrieving revision 1.55 diff -u -r1.55 CCTask.java --- src/net/sf/antcontrib/cpptasks/CCTask.java 5 May 2004 03:50:45 -0000 1.55 +++ src/net/sf/antcontrib/cpptasks/CCTask.java 11 May 2004 04:43:46 -0000 @@ -143,6 +143,8 @@ private final Vector targetPlatforms = new Vector(); /** The distributer definitions. */ private Vector distributers = new Vector(); + private final Vector versionInfos = new Vector(); + /** @@ -372,7 +374,7 @@ return currentTargets; } protected LinkerConfiguration collectExplicitObjectFiles( - Vector objectFiles, Vector sysObjectFiles) { + Vector objectFiles, Vector sysObjectFiles, VersionInfo versionInfo) { // // find the first eligible linker // @@ -395,7 +397,7 @@ // produce the specified link type if (selectedLinker != null) { linkerConfig = currentLinkerDef.createConfiguration(this, - linkType, linkerDef, targetPlatform); + linkType, linkerDef, targetPlatform, versionInfo); if (linkerConfig != null) { // // create collectors for object files @@ -423,7 +425,7 @@ } } if (linkerConfig == null) { - linkerConfig = linkerDef.createConfiguration(this, linkType, null, targetPlatform); + linkerConfig = linkerDef.createConfiguration(this, linkType, null, targetPlatform, versionInfo); selectedLinker = (Linker) linkerDef.getProcessor().getLinker( linkType); objCollector = new ObjectFileCollector(selectedLinker, objectFiles); @@ -518,6 +520,23 @@ throw new BuildException("Object directory does not exist"); } TargetHistoryTable objHistory = new TargetHistoryTable(this, _objDir); + + // + // get the first active version info + // + VersionInfo versionInfo = null; + Enumeration versionEnum = versionInfos.elements(); + while (versionEnum.hasMoreElements()) { + versionInfo = (VersionInfo) versionEnum.nextElement(); + versionInfo = versionInfo.merge(); + if (versionInfo.isActive()) { + break; + } else { + versionInfo = null; + } + } + + // // determine the eventual linker configuration // (may be null) and collect any explicit @@ -525,12 +544,14 @@ Vector objectFiles = new Vector(); Vector sysObjectFiles = new Vector(); LinkerConfiguration linkerConfig = collectExplicitObjectFiles( - objectFiles, sysObjectFiles); + objectFiles, sysObjectFiles, versionInfo); + + // // Assemble hashtable of all files // that we know how to compile (keyed by output file name) // - Hashtable targets = getTargets(linkerConfig, objectFiles); + Hashtable targets = getTargets(linkerConfig, objectFiles, versionInfo, _outfile); TargetInfo linkTarget = null; // // if output file is not specified, @@ -538,7 +559,7 @@ // if (_outfile != null) { linkTarget = getLinkTarget(linkerConfig, objectFiles, - sysObjectFiles, targets); + sysObjectFiles, targets, versionInfo); } // // mark targets that don't have a history record or @@ -546,7 +567,7 @@ // the same as the history to be rebuilt // objHistory.markForRebuild(targets); - CCTaskProgressMonitor monitor = new CCTaskProgressMonitor(objHistory); + CCTaskProgressMonitor monitor = new CCTaskProgressMonitor(objHistory, versionInfo); // // check for changed include files // @@ -729,7 +750,8 @@ return new TargetHistoryTable(this, outputFileDir); } protected TargetInfo getLinkTarget(LinkerConfiguration linkerConfig, - Vector objectFiles, Vector sysObjectFiles, Hashtable compileTargets) { + Vector objectFiles, Vector sysObjectFiles, + Hashtable compileTargets, VersionInfo versionInfo) { // // walk the compile phase targets and // add those sources that have already been @@ -754,7 +776,7 @@ File[] sysObjectFileArray = new File[sysObjectFiles.size()]; sysObjectFiles.copyInto(sysObjectFileArray); String baseName = _outfile.getName(); - String[] fullNames = linkerConfig.getOutputFileNames(baseName); + String[] fullNames = linkerConfig.getOutputFileNames(baseName, versionInfo); File outputFile = new File(_outfile.getParent(), fullNames[0]); return new TargetInfo(linkerConfig, objectFileArray, sysObjectFileArray, outputFile, linkerConfig.getRebuild()); @@ -777,7 +799,7 @@ * */ private Hashtable getTargets(LinkerConfiguration linkerConfig, - Vector objectFiles) { + Vector objectFiles, VersionInfo versionInfo, File outputFile) { Hashtable targets = new Hashtable(1000); TargetDef targetPlatform = getTargetPlatform(); // @@ -789,7 +811,8 @@ .elementAt(i); if (currentCompilerDef.isActive()) { ProcessorConfiguration config = currentCompilerDef - .createConfiguration(this, linkType, compilerDef, targetPlatform); + .createConfiguration(this, linkType, compilerDef, + targetPlatform, versionInfo); // // see if this processor had a precompile child element // @@ -829,7 +852,8 @@ TargetMatcher matcher = new TargetMatcher(this, _objDir, new ProcessorConfiguration[]{configs[0]}, - linkerConfig, objectFiles, targets); + linkerConfig, objectFiles, targets, versionInfo); + matcher.visit(new File(prototype.getParent()), prototype.getName()); // @@ -847,7 +871,8 @@ // to the set of potential targets if (currentCompilerDef.hasFileSets()) { TargetMatcher matcher = new TargetMatcher(this, _objDir, - localConfigs, linkerConfig, objectFiles, targets); + localConfigs, linkerConfig, objectFiles, targets, + versionInfo); currentCompilerDef.visitFiles(matcher); } biddingProcessors.addElement(config); @@ -857,7 +882,7 @@ // add fallback compiler at the end // ProcessorConfiguration config = compilerDef.createConfiguration(this, - linkType, null, targetPlatform); + linkType, null, targetPlatform, versionInfo); biddingProcessors.addElement(config); ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors .size()]; @@ -866,8 +891,20 @@ // bid out the 's in the cctask // TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders, - linkerConfig, objectFiles, targets); + linkerConfig, objectFiles, targets, versionInfo); compilerDef.visitFiles(matcher); + + if (outputFile != null && versionInfo != null) { + boolean isDebug = linkerConfig.isDebug(); + try { + linkerConfig.getLinker().addVersionFiles(versionInfo, linkType, + outputFile, + isDebug, + _objDir, matcher); + } catch(IOException ex) { + throw new BuildException(ex); + } + } return targets; } /** @@ -1223,14 +1260,6 @@ return failOnError; } /** - * Adds descriptive version information to be included in the - * generated file. The first active version info block will - * be used. (Non-functional prototype) - */ - public void addConfiguredVersioninfo(VersionInfo info) { - linkerDef.addConfiguredVersioninfo(info); - } - /** * Adds a target definition or reference (Non-functional prototype). * * @param target @@ -1267,4 +1296,15 @@ public void setOptimize(OptimizationEnum optimization) { compilerDef.setOptimize(optimization); } + + /** + * Adds desriptive version information to be included in the + * generated file. The first active version info block will + * be used. + */ + public void addConfiguredVersioninfo(VersionInfo newVersionInfo) { + newVersionInfo.setProject(this.getProject()); + versionInfos.addElement(newVersionInfo); + } + } Index: src/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java,v retrieving revision 1.7 diff -u -r1.7 CCTaskProgressMonitor.java --- src/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java 28 Feb 2004 20:04:02 -0000 1.7 +++ src/net/sf/antcontrib/cpptasks/CCTaskProgressMonitor.java 11 May 2004 04:43:46 -0000 @@ -22,9 +22,11 @@ public class CCTaskProgressMonitor implements ProgressMonitor { private ProcessorConfiguration config; private TargetHistoryTable history; + private VersionInfo versionInfo; private long lastCommit = -1; - public CCTaskProgressMonitor(TargetHistoryTable history) { + public CCTaskProgressMonitor(TargetHistoryTable history, VersionInfo versionInfo) { this.history = history; + this.versionInfo = versionInfo; } public void finish(ProcessorConfiguration config, boolean normal) { long current = System.currentTimeMillis(); @@ -37,7 +39,7 @@ } } public void progress(String[] sources) { - history.update(config, sources); + history.update(config, sources, versionInfo); long current = System.currentTimeMillis(); if ((current - lastCommit) > 120000) { try { Index: src/net/sf/antcontrib/cpptasks/LinkerDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/LinkerDef.java,v retrieving revision 1.33 diff -u -r1.33 LinkerDef.java --- src/net/sf/antcontrib/cpptasks/LinkerDef.java 23 Apr 2004 21:15:44 -0000 1.33 +++ src/net/sf/antcontrib/cpptasks/LinkerDef.java 11 May 2004 04:43:46 -0000 @@ -50,7 +50,6 @@ private Boolean map; private int stack; private final Vector sysLibrarySets = new Vector(); - private final Vector versionInfos = new Vector(); /** * Default constructor * @@ -116,21 +115,11 @@ sysLibrarySets.addElement(libset); } - /** - * Adds desriptive version information to be included in the - * generated file. The first active version info block will - * be used. - */ - public void addConfiguredVersioninfo(VersionInfo newVersionInfo) { - if (isReference()) { - throw noChildrenAllowed(); - } - newVersionInfo.setProject(this.getProject()); - versionInfos.addElement(newVersionInfo); - } public ProcessorConfiguration createConfiguration(CCTask task, - LinkType linkType, ProcessorDef baseDef, TargetDef targetPlatform) { + LinkType linkType, ProcessorDef baseDef, + TargetDef targetPlatform, + VersionInfo versionInfo) { // // must combine some local context (the linkType) // with the referenced element @@ -148,7 +137,7 @@ proc = proc.getLinker(linkType); ProcessorDef[] defaultProviders = getDefaultProviders(baseDef); return proc.createConfiguration(task, linkType, defaultProviders, - thisDef, targetPlatform); + thisDef, targetPlatform, versionInfo); } public void execute() throws org.apache.tools.ant.BuildException { throw new org.apache.tools.ant.BuildException( Index: src/net/sf/antcontrib/cpptasks/ProcessorDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/ProcessorDef.java,v retrieving revision 1.25 diff -u -r1.25 ProcessorDef.java --- src/net/sf/antcontrib/cpptasks/ProcessorDef.java 23 Apr 2004 21:15:45 -0000 1.25 +++ src/net/sf/antcontrib/cpptasks/ProcessorDef.java 11 May 2004 04:43:46 -0000 @@ -180,15 +180,16 @@ * */ public ProcessorConfiguration createConfiguration(CCTask task, - LinkType linkType, ProcessorDef baseDef, TargetDef targetPlatform) { + LinkType linkType, ProcessorDef baseDef, + TargetDef targetPlatform, VersionInfo versionInfo) { if (isReference()) { return ((ProcessorDef) getCheckedRef(ProcessorDef.class, "ProcessorDef")).createConfiguration(task, linkType, - baseDef, targetPlatform); + baseDef, targetPlatform, versionInfo); } ProcessorDef[] defaultProviders = getDefaultProviders(baseDef); Processor proc = getProcessor(); - return proc.createConfiguration(task, linkType, defaultProviders, this, targetPlatform); + return proc.createConfiguration(task, linkType, defaultProviders, this, targetPlatform, versionInfo); } /** * Prepares list of processor arguments ( , ) that Index: src/net/sf/antcontrib/cpptasks/TargetHistoryTable.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/TargetHistoryTable.java,v retrieving revision 1.16 diff -u -r1.16 TargetHistoryTable.java --- src/net/sf/antcontrib/cpptasks/TargetHistoryTable.java 5 May 2004 03:50:45 -0000 1.16 +++ src/net/sf/antcontrib/cpptasks/TargetHistoryTable.java 11 May 2004 04:43:46 -0000 @@ -370,13 +370,13 @@ } } } - public void update(ProcessorConfiguration config, String[] sources) { + public void update(ProcessorConfiguration config, String[] sources, VersionInfo versionInfo) { String configId = config.getIdentifier(); String[] onesource = new String[1]; String[] outputNames; for (int i = 0; i < sources.length; i++) { onesource[0] = sources[i]; - outputNames = config.getOutputFileNames(sources[i]); + outputNames = config.getOutputFileNames(sources[i], versionInfo); for (int j = 0; j < outputNames.length; j++) { update(configId, outputNames[j], onesource); } Index: src/net/sf/antcontrib/cpptasks/TargetMatcher.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/TargetMatcher.java,v retrieving revision 1.11 diff -u -r1.11 TargetMatcher.java --- src/net/sf/antcontrib/cpptasks/TargetMatcher.java 5 May 2004 03:50:45 -0000 1.11 +++ src/net/sf/antcontrib/cpptasks/TargetMatcher.java 11 May 2004 04:43:46 -0000 @@ -35,16 +35,19 @@ private ProcessorConfiguration[] processors; private final File sourceFiles[] = new File[1]; private Hashtable targets; + private VersionInfo versionInfo; private CCTask task; public TargetMatcher(CCTask task, File outputDir, ProcessorConfiguration[] processors, LinkerConfiguration linker, - Vector objectFiles, Hashtable targets) { + Vector objectFiles, Hashtable targets, + VersionInfo versionInfo) { this.task = task; this.outputDir = outputDir; this.processors = processors; this.targets = targets; this.linker = linker; this.objectFiles = objectFiles; + this.versionInfo = versionInfo; } public void visit(File parentDir, String filename) throws BuildException { File fullPath = new File(parentDir, filename); @@ -81,7 +84,7 @@ // get output file name // String[] outputFileNames = selectedCompiler - .getOutputFileNames(filename); + .getOutputFileNames(filename, versionInfo); sourceFiles[0] = fullPath; // // if there is some output for this task Index: src/net/sf/antcontrib/cpptasks/VersionInfo.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/VersionInfo.java,v retrieving revision 1.2 diff -u -r1.2 VersionInfo.java --- src/net/sf/antcontrib/cpptasks/VersionInfo.java 28 Apr 2004 18:23:27 -0000 1.2 +++ src/net/sf/antcontrib/cpptasks/VersionInfo.java 11 May 2004 04:43:46 -0000 @@ -1,5 +1,5 @@ /* - * + * * Copyright 2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,22 +16,32 @@ */ package net.sf.antcontrib.cpptasks; -import java.io.IOException; -import java.io.Writer; +import java.util.Vector; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; import org.apache.tools.ant.types.DataType; import org.apache.tools.ant.types.Reference; /** - * Version Information. (Non-functional prototype) - * + * Version Information. + * + * This information is applied in a platform specific manner + * to embed version information into executable images. This + * behavior is new and subject to change. + * + * On the Microsoft Windows platform, a resource is generated and added + * to the set of files to be compiled. A resource compiler must + * be specified to compile the generated file. + * + * On Unix platforms, versioninfo is currently not used. + * Future versions may append fileversion to the output file name, + * use compatibility version for -soname and possibly create + * symbolic links. */ -public class VersionInfo extends DataType { - /** - * if property. - */ +public final class VersionInfo extends DataType { + /** + * if property. + */ private String ifCond; /** * unless property. @@ -41,8 +51,8 @@ /** * extends property. */ - private String extendsId; - + private Reference extendsRef; + /** * file version. * @@ -58,7 +68,7 @@ * */ private String language; - + /** * comments. * @@ -73,7 +83,7 @@ * Description. * */ - private String description; + private String fileDescription; /** * internal name. */ @@ -87,7 +97,7 @@ * legal trademark. * */ - private String legalTrademark; + private String legalTrademarks; /** * original filename. * @@ -112,7 +122,19 @@ * */ private String compatibilityVersion; - + + /** + * prerease build. + * + */ + private Boolean prerelease; + + /** + * prerease build. + * + */ + private Boolean patched; + /** * Constructor. @@ -120,6 +142,117 @@ */ public VersionInfo() { } + + /** + * Private constructor for merge. + * @param stack list of version infos with most significant first. + */ + private VersionInfo(final Vector stack) { + VersionInfo source = null; + for(int i = stack.size() - 1; i >= 0; i--) { + source = (VersionInfo) stack.elementAt(i); + if (source.getIf() != null) { + ifCond = source.getIf(); + } + if (source.getUnless() != null) { + unlessCond = source.getUnless(); + } + if (source.getFileversion() != null) { + fileVersion = source.getFileversion(); + } + if (source.getProductversion() != null) { + productVersion = source.getProductversion(); + } + if (source.getLanguage() != null) { + language = source.getLanguage(); + } + if (source.getFilecomments() != null) { + fileComments = source.getFilecomments(); + } + if (source.getCompanyname() != null) { + companyName = source.getCompanyname(); + } + if (source.getFiledescription() != null) { + fileDescription = source.getFiledescription(); + } + if (source.getInternalname() != null) { + internalName = source.getInternalname(); + } + if (source.getLegalcopyright() != null) { + legalCopyright = source.getLegalcopyright(); + } + if (source.getLegaltrademarks() != null) { + legalTrademarks = source.getLegaltrademarks(); + } + if (source.getOriginalfilename() != null) { + originalFilename = source.getOriginalfilename(); + } + if (source.getPrivatebuild() != null) { + privateBuild = source.getPrivatebuild(); + } + if (source.getProductname() != null) { + productName = source.getProductname(); + } + if (source.getSpecialbuild() != null) { + specialBuild = source.getSpecialbuild(); + } + if (source.getCompatibilityversion() != null) { + compatibilityVersion = source.getCompatibilityversion(); + } + if (source.getPrerelease() != null) { + prerelease = source.getPrerelease(); + } + if (source.getPatched() != null) { + patched = source.getPatched(); + } + } + setProject(source.getProject()); + } + + /** + * Returns a VersionInfo that reflects the state of + * @return + */ + public VersionInfo merge() { + if (isReference()) { + VersionInfo refVersion = (VersionInfo) + getCheckedRef(VersionInfo.class, + "VersionInfo"); + return refVersion.merge(); + } + Reference currentRef = this.getExtends(); + if (currentRef == null) { + return this; + } + Vector stack = new Vector(5); + stack.addElement(this); + while (currentRef != null) { + Object obj = currentRef.getReferencedObject(getProject()); + if (obj instanceof VersionInfo) { + VersionInfo current = (VersionInfo) obj; + if (current.isReference()) { + current = (VersionInfo) + current.getCheckedRef(VersionInfo.class, + "VersionInfo"); + } + if (stack.contains(current)) { + throw this.circularReference(); + } + stack.addElement(current); + currentRef = current.getExtends(); + } else { + throw new BuildException("Referenced element " + + currentRef.getRefId() + " is not a versioninfo."); + } + } + return new VersionInfo(stack); + } + /** + * Methods is required for documentation generation, throws + * exception if called. + * + * @throws org.apache.tools.ant.BuildException if called + */ public void execute() throws org.apache.tools.ant.BuildException { throw new org.apache.tools.ant.BuildException( "Not an actual task, but looks like one for documentation purposes"); @@ -127,7 +260,7 @@ /** * Returns true if the define's if and unless conditions (if any) are * satisfied. - * + * * @exception BuildException * throws build exception if name is not set */ @@ -136,7 +269,7 @@ } /** * Sets an id that can be used to reference this element. - * + * * @param id * id */ @@ -146,54 +279,85 @@ // mechanism, but we can document it // } + + public Reference getExtends() { + return this.extendsRef; + } /** - * Sets the name of a version info that this info extends. - * - * @param id - * id + * Specifies that this element extends the element with id attribute with a + * matching value. The configuration will be constructed from the settings + * of this element, element referenced by extends, and the containing cc + * element. + * + * @param extendsRef + * Reference to the extended processor definition. + * @throws BuildException + * if this processor definition is a reference */ - public void setExtends(String id) { - extendsId = id; + public void setExtends(Reference extendsRef) throws BuildException { + if (isReference()) { + throw tooManyAttributes(); + } + this.extendsRef = extendsRef; } - + /** + * Gets if property name. + * @return property name, may be null. + */ + public final String getIf() { + return ifCond; + } /** * Sets the property name for the 'if' condition. - * + * * The define will be ignored unless the property is defined. - * + * * The value of the property is insignificant, but values that would imply * misinterpretation ("false", "no") will throw an exception when * evaluated. - * + * * @param propName * property name */ public final void setIf(String propName) { + if (isReference()) { + throw tooManyAttributes(); + } ifCond = propName; } /** * Specifies that this element should behave as if the content of the * element with the matching id attribute was inserted at this location. If * specified, no other attributes should be specified. - * + * */ public void setRefid(Reference r) throws BuildException { super.setRefid(r); } /** + * Gets if property name. + * @return property name, may be null. + */ + public final String getUnless() { + return unlessCond; + } + /** * Set the property name for the 'unless' condition. - * + * * If named property is set, the define will be ignored. - * + * * The value of the property is insignificant, but values that would imply * misinterpretation ("false", "no") of the behavior will throw an * exception when evaluated. - * + * * @param propName * name of property */ public final void setUnless(String propName) { + if (isReference()) { + throw tooManyAttributes(); + } unlessCond = propName; } /** @@ -202,183 +366,113 @@ * */ public String getFileversion() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getFileversion(); - } - return fileVersion; + return fileVersion; } /** * Gets Product version. * @return product version, may be null */ public String getProductversion() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getProductversion(); - } - return productVersion; + return productVersion; } /** * Gets compatibility version. * @return compatibility version, may be null */ public String getCompatibilityversion() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getCompatibilityversion(); - } - return compatibilityVersion; + return compatibilityVersion; } /** * Gets file language, should be an IETF RFC 3066 identifier, for example, en-US. * @return language, may be null. */ public String getLanguage() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getLanguage(); - } - return language; + return language; } - + /** * Gets comments. * @return comments, may be null. */ public String getFilecomments() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getFilecomments(); - } - return fileComments; + return fileComments; } /** * Gets Company name. * @return company name, may be null. */ public String getCompanyname() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getCompanyname(); - } - return companyName; + return companyName; } /** * Gets Description. * @return description, may be null. */ - public String getDescription() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getDescription(); - } - return description; + public String getFiledescription() { + return fileDescription; } /** * Gets internal name. * @return internal name, may be null. */ public String getInternalname() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getInternalname(); - } - return internalName; + return internalName; } /** * Gets legal copyright. * @return legal copyright, may be null. */ public String getLegalcopyright() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getLegalcopyright(); - } - return legalCopyright; + return legalCopyright; } /** * Gets legal trademark. * @return legal trademark, may be null; */ - public String getLegaltrademark() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getLegaltrademark(); - } - return legalTrademark; + public String getLegaltrademarks() { + return legalTrademarks; } /** * Gets original filename. * @return original filename, may be null. */ public String getOriginalfilename() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getOriginalfilename(); - } - return originalFilename; + return originalFilename; } /** * Gets private build. * @return private build, may be null. */ public String getPrivatebuild() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getPrivatebuild(); - } - return privateBuild; + return privateBuild; + } + /** + * Gets prerelease. + * @return prerelease, may be null. + */ + public Boolean getPrerelease() { + return prerelease; + } + /** + * Gets patched. + * @return patched, may be null. + */ + public Boolean getPatched() { + return patched; } /** * Gets product name. * @return product name, may be null. */ public String getProductname() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getProductname(); - } - return productName; + return productName; } /** * Special build * @return special build, may be null. */ public String getSpecialbuild() { - if (isReference()) { - VersionInfo refVersion = (VersionInfo) - getCheckedRef(VersionInfo.class, - "VersionInfo"); - return refVersion.getSpecialbuild(); - } - return specialBuild; + return specialBuild; } /** @@ -390,7 +484,7 @@ if (isReference()) { throw tooManyAttributes(); } - fileVersion = value; + fileVersion = value; } /** * Sets product version. @@ -401,7 +495,7 @@ if (isReference()) { throw tooManyAttributes(); } - productVersion = value; + productVersion = value; } /** * Sets compatibility version. @@ -412,7 +506,7 @@ if (isReference()) { throw tooManyAttributes(); } - compatibilityVersion = value; + compatibilityVersion = value; } /** * Sets language. @@ -434,7 +528,18 @@ if (isReference()) { throw tooManyAttributes(); } - fileComments = value; + fileComments = value; + } + + /** + * Sets file description. + * @param value new value + */ + public void setFiledescription(String value) { + if (isReference()) { + throw tooManyAttributes(); + } + fileDescription = value; } /** @@ -446,7 +551,7 @@ if (isReference()) { throw tooManyAttributes(); } - companyName = value; + companyName = value; } @@ -454,7 +559,7 @@ * Sets internal name. Internal name will automatically be * specified from build step, only set this value if * intentionally overriding that value. - * + * * @param value new value * @throws BuildException if specified with refid */ @@ -462,9 +567,9 @@ if (isReference()) { throw tooManyAttributes(); } - internalName = value; + internalName = value; } - + /** * Sets legal copyright. * @param value new value @@ -474,23 +579,23 @@ if (isReference()) { throw tooManyAttributes(); } - legalCopyright = value; + legalCopyright = value; } /** * Sets legal trademark. * @param value new value * @throws BuildException if specified with refid */ - public void setLegaltrademark(String value) throws BuildException { + public void setLegaltrademarks(String value) throws BuildException { if (isReference()) { throw tooManyAttributes(); } - legalTrademark = value; + legalTrademarks = value; } /** * Sets original name. Only set this value if * intentionally overriding the value from the build set. - * + * * @param value new value * @throws BuildException if specified with refid */ @@ -498,7 +603,7 @@ if (isReference()) { throw tooManyAttributes(); } - originalFilename = value; + originalFilename = value; } /** * Sets private build. @@ -509,7 +614,37 @@ if (isReference()) { throw tooManyAttributes(); } - privateBuild = value; + privateBuild = value; + } + /** + * Sets prerelease. + * @param value new value + * @throws BuildException if specified with refid + */ + public void setPrerelease(boolean value) throws BuildException { + if (isReference()) { + throw tooManyAttributes(); + } + if (value) { + prerelease = Boolean.TRUE; + } else { + prerelease = Boolean.FALSE; + } + } + /** + * Sets prerelease. + * @param value new value + * @throws BuildException if specified with refid + */ + public void setPatched(boolean value) throws BuildException { + if (isReference()) { + throw tooManyAttributes(); + } + if (value) { + patched = Boolean.TRUE; + } else { + patched = Boolean.FALSE; + } } /** * Sets product name. @@ -520,7 +655,7 @@ if (isReference()) { throw tooManyAttributes(); } - productName= value; + productName= value; } /** * Sets private build. @@ -531,20 +666,6 @@ if (isReference()) { throw tooManyAttributes(); } - specialBuild = value; - } - - /** - * Writes windows resource - * @param writer writer, may not be null. - * @param project project, may not be null - * @param executableName name of executable - */ - public void writeResource(final Writer writer, - final Project p, - final String executableName) throws IOException { - // TODO: - + specialBuild = value; } - } Index: src/net/sf/antcontrib/cpptasks/WarningLevelEnum.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/WarningLevelEnum.java,v retrieving revision 1.1 diff -u -r1.1 WarningLevelEnum.java --- src/net/sf/antcontrib/cpptasks/WarningLevelEnum.java 1 May 2004 00:14:24 -0000 1.1 +++ src/net/sf/antcontrib/cpptasks/WarningLevelEnum.java 11 May 2004 04:43:46 -0000 @@ -21,7 +21,7 @@ * Enumerated attribute with the values "none", "severe", "default", * "production", "diagnostic", and "failtask". */ -class WarningLevelEnum extends EnumeratedAttribute { +public final class WarningLevelEnum extends EnumeratedAttribute { /** * Constructor. * Index: src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java,v retrieving revision 1.20 diff -u -r1.20 BorlandLinker.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java 22 Apr 2004 09:06:54 -0000 1.20 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandLinker.java 11 May 2004 04:43:46 -0000 @@ -21,10 +21,13 @@ import java.util.Vector; import net.sf.antcontrib.cpptasks.CCTask; +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; import net.sf.antcontrib.cpptasks.compiler.Linker; +import net.sf.antcontrib.cpptasks.platforms.WindowsPlatform; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; /** @@ -261,4 +264,25 @@ throws IOException { return BorlandProcessor.prepareResponseFile(outputFile, args, " + \n"); } + + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param executableName name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + */ + public void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) throws IOException { + WindowsPlatform.addVersionFiles(versionInfo, linkType, outputFile, isDebug, objDir, matcher); + } + } Index: src/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java,v retrieving revision 1.21 diff -u -r1.21 BorlandResourceCompiler.java --- src/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java 5 May 2004 03:50:44 -0000 1.21 +++ src/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java 11 May 2004 04:43:46 -0000 @@ -102,7 +102,7 @@ protected String getInputFileArgument(File outputDir, String filename, int index) { if (index == 0) { - String[] outputFileNames = getOutputFileNames(filename); + String[] outputFileNames = getOutputFileNames(filename, null); String fullOutputName = new File(outputDir, outputFileNames[0]) .toString(); return "-fo" + fullOutputName; Index: src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java,v retrieving revision 1.25 diff -u -r1.25 AbstractCompiler.java --- src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java 5 May 2004 03:50:46 -0000 1.25 +++ src/net/sf/antcontrib/cpptasks/compiler/AbstractCompiler.java 11 May 2004 04:43:47 -0000 @@ -28,6 +28,7 @@ import net.sf.antcontrib.cpptasks.ProcessorDef; import net.sf.antcontrib.cpptasks.parser.Parser; import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; /** * An abstract compiler implementation. @@ -65,15 +66,17 @@ } abstract protected CompilerConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseConfigs, - CompilerDef specificConfig, TargetDef targetPlatform); + CompilerDef specificConfig, TargetDef targetPlatform, + VersionInfo versionInfo); public ProcessorConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseConfigs, - ProcessorDef specificConfig, TargetDef targetPlatform) { + ProcessorDef specificConfig, TargetDef targetPlatform, + VersionInfo versionInfo) { if (specificConfig == null) { throw new NullPointerException("specificConfig"); } return createConfiguration(task, linkType, baseConfigs, - (CompilerDef) specificConfig, targetPlatform); + (CompilerDef) specificConfig, targetPlatform, versionInfo); } abstract protected Parser createParser(File sourceFile); protected String getBaseOutputName(String inputFile) { @@ -92,7 +95,7 @@ } return inputFile.substring(lastSlash + 1, lastPeriod); } - public String[] getOutputFileNames(String inputFile) { + public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { // // if a recognized input file // Index: src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java,v retrieving revision 1.27 diff -u -r1.27 AbstractLinker.java --- src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java 5 May 2004 03:50:46 -0000 1.27 +++ src/net/sf/antcontrib/cpptasks/compiler/AbstractLinker.java 11 May 2004 04:43:47 -0000 @@ -16,12 +16,14 @@ */ package net.sf.antcontrib.cpptasks.compiler; import java.io.File; +import java.io.IOException; import net.sf.antcontrib.cpptasks.CCTask; import net.sf.antcontrib.cpptasks.LinkerDef; import net.sf.antcontrib.cpptasks.ProcessorDef; import net.sf.antcontrib.cpptasks.TargetDef; - +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.types.Environment; /** @@ -67,19 +69,54 @@ } abstract protected LinkerConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseConfigs, - LinkerDef specificConfig, TargetDef targetPlatform); + LinkerDef specificConfig, TargetDef targetPlatform, + VersionInfo versionInfo); public ProcessorConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] baseConfigs, ProcessorDef specificConfig, - TargetDef targetPlatform) { + TargetDef targetPlatform, + VersionInfo versionInfo) { if (specificConfig == null) { throw new NullPointerException("specificConfig"); } return createConfiguration(task, linkType, baseConfigs, - (LinkerDef) specificConfig, targetPlatform); + (LinkerDef) specificConfig, targetPlatform, versionInfo); } public String getLibraryKey(File libfile) { return libfile.getName(); } - public abstract String[] getOutputFileNames(String fileName); + public abstract String[] getOutputFileNames(String fileName, VersionInfo versionInfo); + + + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param executableName name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + */ + public void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) throws IOException { + if (versionInfo == null) { + throw new NullPointerException("versionInfo"); + } + if (linkType == null) { + throw new NullPointerException("linkType"); + } + if (outputFile == null) { + throw new NullPointerException("outputFile"); + } + if (objDir == null) { + throw new NullPointerException("objDir"); + } + } + } Index: src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java,v retrieving revision 1.26 diff -u -r1.26 CommandLineCompiler.java --- src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java 23 Apr 2004 21:15:47 -0000 1.26 +++ src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java 11 May 2004 04:43:47 -0000 @@ -27,6 +27,8 @@ import net.sf.antcontrib.cpptasks.types.CommandLineArgument; import net.sf.antcontrib.cpptasks.types.UndefineArgument; import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Environment; import net.sf.antcontrib.cpptasks.OptimizationEnum;; @@ -236,7 +238,8 @@ final LinkType linkType, final ProcessorDef[] baseDefs, final CompilerDef specificDef, - final TargetDef targetPlatform) { + final TargetDef targetPlatform, + final VersionInfo versionInfo) { Vector args = new Vector(); CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1]; for (int i = 0; i < baseDefs.length; i++) { Index: src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java,v retrieving revision 1.17 diff -u -r1.17 CommandLineCompilerConfiguration.java --- src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java 5 May 2004 03:50:46 -0000 1.17 +++ src/net/sf/antcontrib/cpptasks/compiler/CommandLineCompilerConfiguration.java 11 May 2004 04:43:47 -0000 @@ -21,6 +21,7 @@ import net.sf.antcontrib.cpptasks.CompilerParam; import net.sf.antcontrib.cpptasks.DependencyInfo; import net.sf.antcontrib.cpptasks.ProcessorParam; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** @@ -180,8 +181,8 @@ public String getIncludePathIdentifier() { return includePathIdentifier; } - public String[] getOutputFileNames(String inputFile) { - return compiler.getOutputFileNames(inputFile); + public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + return compiler.getOutputFileNames(inputFile, versionInfo); } public CompilerParam getParam(String name) { for (int i = 0; i < params.length; i++) { Index: src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java,v retrieving revision 1.39 diff -u -r1.39 CommandLineLinker.java --- src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java 5 May 2004 03:50:46 -0000 1.39 +++ src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinker.java 11 May 2004 04:43:47 -0000 @@ -30,6 +30,7 @@ import net.sf.antcontrib.cpptasks.types.CommandLineArgument; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Environment; @@ -90,7 +91,8 @@ protected LinkerConfiguration createConfiguration( CCTask task, LinkType linkType, - ProcessorDef[] baseDefs, LinkerDef specificDef, TargetDef targetPlatform) { + ProcessorDef[] baseDefs, LinkerDef specificDef, TargetDef targetPlatform, + VersionInfo versionInfo) { Vector preargs = new Vector(); Vector midargs = new Vector(); @@ -174,7 +176,7 @@ //task.log("libnames:"+libnames.length, Project.MSG_VERBOSE); return new CommandLineLinkerConfiguration(this,configId,options, paramArray, - rebuild,map,libnames, startupObject); + rebuild,map, debug,libnames, startupObject); } /** @@ -215,7 +217,7 @@ } protected abstract int getMaximumCommandLength(); - public String[] getOutputFileNames(String baseName) { + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { return new String[] { baseName + outputSuffix }; } Index: src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java,v retrieving revision 1.19 diff -u -r1.19 CommandLineLinkerConfiguration.java --- src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java 5 May 2004 03:50:46 -0000 1.19 +++ src/net/sf/antcontrib/cpptasks/compiler/CommandLineLinkerConfiguration.java 11 May 2004 04:43:47 -0000 @@ -19,6 +19,7 @@ import net.sf.antcontrib.cpptasks.LinkerParam; import net.sf.antcontrib.cpptasks.ProcessorParam; import net.sf.antcontrib.cpptasks.TargetInfo; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** @@ -36,10 +37,11 @@ private/* final */boolean map; private/* final */ProcessorParam[] params; private/* final */boolean rebuild; + private boolean debug; private String startupObject; public CommandLineLinkerConfiguration(CommandLineLinker linker, String identifier, String[][] args, ProcessorParam[] params, - boolean rebuild, boolean map, String[] libraryNames, + boolean rebuild, boolean map, boolean debug, String[] libraryNames, String startupObject) { if (linker == null) { throw new NullPointerException("linker"); @@ -54,6 +56,7 @@ this.rebuild = rebuild; this.identifier = identifier; this.map = map; + this.debug = debug; if (libraryNames == null) { this.libraryNames = new String[0]; } else { @@ -83,8 +86,8 @@ public boolean getMap() { return map; } - public String[] getOutputFileNames(String inputFile) { - return linker.getOutputFileNames(inputFile); + public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { + return linker.getOutputFileNames(inputFile, versionInfo); } public LinkerParam getParam(String name) { for (int i = 0; i < params.length; i++) { @@ -116,4 +119,10 @@ public String toString() { return identifier; } + public Linker getLinker() { + return linker; + } + public boolean isDebug() { + return debug; + } } Index: src/net/sf/antcontrib/cpptasks/compiler/Linker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/Linker.java,v retrieving revision 1.18 diff -u -r1.18 Linker.java --- src/net/sf/antcontrib/cpptasks/compiler/Linker.java 21 Apr 2004 22:49:15 -0000 1.18 +++ src/net/sf/antcontrib/cpptasks/compiler/Linker.java 11 May 2004 04:43:47 -0000 @@ -16,7 +16,12 @@ */ package net.sf.antcontrib.cpptasks.compiler; import java.io.File; +import java.io.IOException; + +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; + /** * A linker for executables, and static and dynamic libraries. * @@ -54,4 +59,22 @@ * Returns true if the linker is case-sensitive */ boolean isCaseSensitive(); + + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param executableName name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + */ + void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) throws IOException; } Index: src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java,v retrieving revision 1.10 diff -u -r1.10 LinkerConfiguration.java --- src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java 28 Feb 2004 20:00:40 -0000 1.10 +++ src/net/sf/antcontrib/cpptasks/compiler/LinkerConfiguration.java 11 May 2004 04:43:47 -0000 @@ -28,4 +28,6 @@ public interface LinkerConfiguration extends ProcessorConfiguration { public LinkerParam getParam(String name); void link(CCTask task, TargetInfo linkTarget) throws BuildException; + Linker getLinker(); + boolean isDebug(); } Index: src/net/sf/antcontrib/cpptasks/compiler/Processor.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/Processor.java,v retrieving revision 1.17 diff -u -r1.17 Processor.java --- src/net/sf/antcontrib/cpptasks/compiler/Processor.java 5 May 2004 03:50:46 -0000 1.17 +++ src/net/sf/antcontrib/cpptasks/compiler/Processor.java 11 May 2004 04:43:47 -0000 @@ -18,6 +18,8 @@ import net.sf.antcontrib.cpptasks.CCTask; import net.sf.antcontrib.cpptasks.ProcessorDef; import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; + import org.apache.tools.ant.types.Environment; /** * A processor. Base interface for Compiler and Linker @@ -50,7 +52,7 @@ */ ProcessorConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] defaultProviders, ProcessorDef specificConfig, - TargetDef targetPlatform); + TargetDef targetPlatform, VersionInfo versionInfo); /** * Retrieve an identifier that identifies the specific version of the * compiler. Compilers with the same identifier should produce the same @@ -69,5 +71,5 @@ * @return output file name or null if no output file or name not * determined by input file */ - String[] getOutputFileNames(String inputFile); + String[] getOutputFileNames(String inputFile, VersionInfo versionInfo); } Index: src/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java,v retrieving revision 1.11 diff -u -r1.11 ProcessorConfiguration.java --- src/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java 5 May 2004 03:50:46 -0000 1.11 +++ src/net/sf/antcontrib/cpptasks/compiler/ProcessorConfiguration.java 11 May 2004 04:43:47 -0000 @@ -16,6 +16,8 @@ */ package net.sf.antcontrib.cpptasks.compiler; import net.sf.antcontrib.cpptasks.ProcessorParam; +import net.sf.antcontrib.cpptasks.VersionInfo; + /** * A configuration for a C++ compiler, linker or other processor * @@ -42,7 +44,7 @@ * @return output file names or zero-length array if no output file or name not * determined by input file */ - String[] getOutputFileNames(String inputFile); + String[] getOutputFileNames(String inputFile, VersionInfo versionInfo); ProcessorParam[] getParams(); /** * If true, all files using this configuration should be rebuilt and any Index: src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java,v retrieving revision 1.11 diff -u -r1.11 DevStudioCompatibleLinker.java --- src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java 22 Apr 2004 09:06:53 -0000 1.11 +++ src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java 11 May 2004 04:43:47 -0000 @@ -16,12 +16,17 @@ */ package net.sf.antcontrib.cpptasks.devstudio; import java.io.File; +import java.io.IOException; import java.util.Vector; import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.platforms.WindowsPlatform; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; + /** * Abstract base class for linkers that try to mimic the command line arguments * for the Microsoft (r) Incremental Linker @@ -118,4 +123,24 @@ public boolean isCaseSensitive() { return false; } + + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param executableName name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + */ + public void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) throws IOException { + WindowsPlatform.addVersionFiles(versionInfo, linkType, outputFile, isDebug, objDir, matcher); + } } Index: src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java,v retrieving revision 1.19 diff -u -r1.19 DevStudioMIDLCompiler.java --- src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java 5 May 2004 03:50:46 -0000 1.19 +++ src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java 11 May 2004 04:43:47 -0000 @@ -85,7 +85,7 @@ case 0 : return "/tlb"; case 1 : - return new File(outputDir, getOutputFileNames(filename)[0]) + return new File(outputDir, getOutputFileNames(filename, null)[0]) .getAbsolutePath(); } return filename; Index: src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java,v retrieving revision 1.18 diff -u -r1.18 DevStudioResourceCompiler.java --- src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java 5 May 2004 03:50:46 -0000 1.18 +++ src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java 11 May 2004 04:43:47 -0000 @@ -88,7 +88,7 @@ protected String getInputFileArgument(File outputDir, String filename, int index) { if (index == 0) { - String outputFileName = getOutputFileNames(filename)[0]; + String outputFileName = getOutputFileNames(filename, null)[0]; String fullOutputName = new File(outputDir, outputFileName) .toString(); return "/fo" + fullOutputName; @@ -113,4 +113,7 @@ protected void getUndefineSwitch(StringBuffer buffer, String define) { DevStudioProcessor.getUndefineSwitch(buffer, define); } + public String getIdentifier() { + return "Microsoft (R) Windows (R) Resource Compiler"; + } } Index: src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java,v retrieving revision 1.15 diff -u -r1.15 AbstractArLibrarian.java --- src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java 5 May 2004 03:50:44 -0000 1.15 +++ src/net/sf/antcontrib/cpptasks/gcc/AbstractArLibrarian.java 11 May 2004 04:43:47 -0000 @@ -22,6 +22,7 @@ import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.VersionInfo; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; import org.apache.tools.ant.BuildException; @@ -72,8 +73,8 @@ public int getMaximumCommandLength() { return Integer.MAX_VALUE; } - public String[] getOutputFileNames(String baseName) { - String[] baseNames = super.getOutputFileNames(baseName); + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + String[] baseNames = super.getOutputFileNames(baseName, versionInfo); if (outputPrefix.length() > 0) { for(int i = 0; i < baseNames.length; i++) { baseNames[i] = outputPrefix + baseNames[i]; Index: src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java,v retrieving revision 1.17 diff -u -r1.17 AbstractLdLinker.java --- src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java 5 May 2004 03:50:44 -0000 1.17 +++ src/net/sf/antcontrib/cpptasks/gcc/AbstractLdLinker.java 11 May 2004 04:43:47 -0000 @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,12 +23,13 @@ import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; +import net.sf.antcontrib.cpptasks.VersionInfo; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; /** * Abstract adapter for ld-like linkers - * + * * @author Curt Arnold */ public abstract class AbstractLdLinker extends CommandLineLinker { @@ -42,10 +43,10 @@ this.outputPrefix = outputPrefix; } public void addBase(long base, Vector args) { - if (base >= 0) { - args.addElement("--image-base"); - args.addElement(Long.toHexString(base)); - } + if (base >= 0) { + args.addElement("--image-base"); + args.addElement(Long.toHexString(base)); + } } public void addFixed(Boolean fixed, Vector args) { } @@ -76,9 +77,9 @@ } } public void addIncremental(boolean incremental, Vector args) { - if (incremental) { - args.addElement("-i"); - } + if (incremental) { + args.addElement("-i"); + } } protected int addLibraryPatterns(String[] libnames, StringBuffer buf, String prefix, String extension, String[] patterns, int offset) { @@ -101,36 +102,36 @@ File libdir = set.getDir(null); String[] libs = set.getLibs(); if (libdir != null) { - if (set.getType() != null && - "framework".equals(set.getType().getValue()) && - isDarwin()) { - endargs.addElement("-F" + libdir.getAbsolutePath()); - } else { - endargs.addElement("-L" + libdir.getAbsolutePath()); - } + if (set.getType() != null && + "framework".equals(set.getType().getValue()) && + isDarwin()) { + endargs.addElement("-F" + libdir.getAbsolutePath()); + } else { + endargs.addElement("-L" + libdir.getAbsolutePath()); + } } // // if there has been a change of library type // if (set.getType() != previousLibraryType) { - if (set.getType() != null && "static".equals(set.getType().getValue())) { - endargs.addElement("-Bstatic"); - previousLibraryType = set.getType(); - } else { - if (set.getType() == null || - !"framework".equals(set.getType().getValue()) || - !isDarwin()) { - endargs.addElement("-Bdynamic"); - previousLibraryType = set.getType(); - } - } + if (set.getType() != null && "static".equals(set.getType().getValue())) { + endargs.addElement("-Bstatic"); + previousLibraryType = set.getType(); + } else { + if (set.getType() == null || + !"framework".equals(set.getType().getValue()) || + !isDarwin()) { + endargs.addElement("-Bdynamic"); + previousLibraryType = set.getType(); + } + } } StringBuffer buf = new StringBuffer("-l"); - if (set.getType() != null && - "framework".equals(set.getType().getValue()) && - isDarwin()) { - buf.setLength(0); - buf.append("-framework "); + if (set.getType() != null && + "framework".equals(set.getType().getValue()) && + isDarwin()) { + buf.setLength(0); + buf.append("-framework "); } int initialLength = buf.length(); for (int j = 0; j < libs.length; j++) { @@ -154,32 +155,32 @@ return rc; } public void addMap(boolean map, Vector args) { - if (map) { - args.addElement("-M"); - } + if (map) { + args.addElement("-M"); + } } public void addStack(int stack, Vector args) { - if (stack > 0) { - args.addElement("--stack"); - args.addElement(Integer.toString(stack)); - } + if (stack > 0) { + args.addElement("--stack"); + args.addElement(Integer.toString(stack)); + } } /* (non-Javadoc) * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector) */ protected void addEntry(String entry, Vector args) { - if (entry != null) { - args.addElement("-e"); - args.addElement(entry); - } + if (entry != null) { + args.addElement("-e"); + args.addElement(entry); + } } - + public String getCommandFileSwitch(String commandFile) { throw new IllegalStateException("ld does not support command files"); } /** * Returns library path. - * + * */ protected File[] getEnvironmentIncludePath() { return CUtil.getPathFromEnvironment("LIB", ":"); @@ -194,7 +195,7 @@ } /** * Returns library path. - * + * */ public File[] getLibraryPath() { return new File[0]; @@ -203,49 +204,46 @@ StringBuffer buf = new StringBuffer(); int patternCount = libnames.length; if (libType == null) { - patternCount *= 2; + patternCount *= 2; } String[] patterns = new String[patternCount]; int offset = 0; if (libType == null || "static".equals(libType.getValue())) { - offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0); + offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0); } if (libType != null && "framework".equals(libType.getValue()) && isDarwin()) { - for(int i = 0; i < libnames.length; i++) { - buf.setLength(0); - buf.append(libnames[i]); - buf.append(".framework/"); - buf.append(libnames[i]); - patterns[offset++] = buf.toString(); - } + for(int i = 0; i < libnames.length; i++) { + buf.setLength(0); + buf.append(libnames[i]); + buf.append(".framework/"); + buf.append(libnames[i]); + patterns[offset++] = buf.toString(); + } } else { - if (libType == null || !"static".equals(libType.getValue())) { - if (isHPUX()) { - offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns, - offset); - } else { - offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns, - offset); - } - } + if (libType == null || !"static".equals(libType.getValue())) { + if (isHPUX()) { + offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns, + offset); + } else { + offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns, + offset); + } + } } return patterns; } public int getMaximumCommandLength() { return Integer.MAX_VALUE; } - public String[] getOutputFileNames(String baseName) { - String[] baseNames = super.getOutputFileNames(baseName); - if (outputPrefix.length() > 0) { - for(int i = 0; i < baseNames.length; i++) { - baseNames[i] = outputPrefix + baseNames[i]; - } - } + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + String[] baseNames = super.getOutputFileNames(baseName, versionInfo); + if (outputPrefix.length() > 0) { + for(int i = 0; i < baseNames.length; i++) { + baseNames[i] = outputPrefix + baseNames[i]; + } + } return baseNames; } - public String[] getOutputFileSwitch(String outputFile) { - return GccProcessor.getOutputFileSwitch("-o", outputFile); - } public boolean isCaseSensitive() { return true; } @@ -259,7 +257,7 @@ /** * Prepares argument list for exec command. Will return null if command * line would exceed allowable command line buffer. - * + * * @param outputFile * linker output file * @param sourceFiles Index: src/net/sf/antcontrib/cpptasks/mozilla/XpidlCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/mozilla/XpidlCompiler.java,v retrieving revision 1.1 diff -u -r1.1 XpidlCompiler.java --- src/net/sf/antcontrib/cpptasks/mozilla/XpidlCompiler.java 5 May 2004 03:50:44 -0000 1.1 +++ src/net/sf/antcontrib/cpptasks/mozilla/XpidlCompiler.java 11 May 2004 04:43:47 -0000 @@ -31,6 +31,7 @@ import net.sf.antcontrib.cpptasks.gcc.LdLinker; import net.sf.antcontrib.cpptasks.parser.CParser; import net.sf.antcontrib.cpptasks.parser.Parser; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Environment; @@ -125,9 +126,11 @@ /** * Gets output file names. * @param inputFile String input file name + * @param versionInfo version info, not used by this compiler. * @return String[] output file names */ - public String[] getOutputFileNames(final String inputFile) { + public String[] getOutputFileNames(final String inputFile, + final VersionInfo versionInfo) { // // if a recognized input file // @@ -296,7 +299,7 @@ for (int j = 0; j < sourceFiles.length; j++) { tlbIndex = args.length + 4; headerIndex = args.length + 4; - String[] outputFileNames = getOutputFileNames(sourceFiles[j]); + String[] outputFileNames = getOutputFileNames(sourceFiles[j], null); tlbCommand[tlbIndex++] = outputFileNames[0]; tlbCommand[tlbIndex++] = sourceFiles[j]; Index: src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java,v retrieving revision 1.18 diff -u -r1.18 OS390Linker.java --- src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java 5 May 2004 03:50:59 -0000 1.18 +++ src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java 11 May 2004 04:43:47 -0000 @@ -28,6 +28,7 @@ import net.sf.antcontrib.cpptasks.compiler.Linker; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** @@ -148,8 +149,8 @@ public int getMaximumCommandLength() { return Integer.MAX_VALUE; } - public String[] getOutputFileNames(String baseName) { - String[] baseNames = super.getOutputFileNames(baseName); + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + String[] baseNames = super.getOutputFileNames(baseName, versionInfo); if (outputPrefix.length() > 0) { for(int i = 0; i < baseNames.length; i++) { baseNames[i] = outputPrefix + baseNames[i]; Index: src/net/sf/antcontrib/cpptasks/os400/IccLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/os400/IccLinker.java,v retrieving revision 1.8 diff -u -r1.8 IccLinker.java --- src/net/sf/antcontrib/cpptasks/os400/IccLinker.java 5 May 2004 03:50:59 -0000 1.8 +++ src/net/sf/antcontrib/cpptasks/os400/IccLinker.java 11 May 2004 04:43:47 -0000 @@ -27,6 +27,7 @@ import net.sf.antcontrib.cpptasks.compiler.Linker; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** * Adapter for the IBM (R) OS/390 (tm) Linker @@ -196,8 +197,8 @@ } return rc; } - public String[] getOutputFileNames(String baseName) { - String[] baseNames = super.getOutputFileNames(baseName); + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + String[] baseNames = super.getOutputFileNames(baseName, versionInfo); if (outputPrefix.length() > 0) { for(int i = 0; i < baseNames.length; i++) { baseNames[i] = outputPrefix + baseNames[i]; Index: src/net/sf/antcontrib/cpptasks/sun/C89Linker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/sun/C89Linker.java,v retrieving revision 1.9 diff -u -r1.9 C89Linker.java --- src/net/sf/antcontrib/cpptasks/sun/C89Linker.java 5 May 2004 03:50:46 -0000 1.9 +++ src/net/sf/antcontrib/cpptasks/sun/C89Linker.java 11 May 2004 04:43:47 -0000 @@ -25,6 +25,7 @@ import net.sf.antcontrib.cpptasks.compiler.Linker; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; +import net.sf.antcontrib.cpptasks.VersionInfo; /** * Adapter for the Sun C89 Linker @@ -113,8 +114,8 @@ public int getMaximumCommandLength() { return Integer.MAX_VALUE; } - public String[] getOutputFileNames(String baseName) { - String[] baseNames = super.getOutputFileNames(baseName); + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { + String[] baseNames = super.getOutputFileNames(baseName, versionInfo); if (outputPrefix.length() > 0) { for(int i = 0; i < baseNames.length; i++) { baseNames[i] = outputPrefix + baseNames[i]; Index: src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectCompiler.java,v retrieving revision 1.1 diff -u -r1.1 MetaObjectCompiler.java --- src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectCompiler.java 5 May 2004 03:50:45 -0000 1.1 +++ src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectCompiler.java 11 May 2004 04:43:47 -0000 @@ -31,6 +31,7 @@ import net.sf.antcontrib.cpptasks.parser.CParser; import net.sf.antcontrib.cpptasks.parser.Parser; import net.sf.antcontrib.cpptasks.gcc.LdLinker; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.types.Environment; @@ -159,11 +160,13 @@ /** * Gets output file names. * @param inputFile String input file name + * @param versionInfo version info, not used by this compiler. * @return String[] output file names */ - public String[] getOutputFileNames(final String inputFile) { + public String[] getOutputFileNames(final String inputFile, + final VersionInfo versionInfo) { if (inputFile.endsWith(".cpp")) { - return super.getOutputFileNames(inputFile); + return super.getOutputFileNames(inputFile, versionInfo); } // // if a recognized input file @@ -188,7 +191,7 @@ case 0: return "-o"; case 1: - String outputFileName = getOutputFileNames(filename)[0]; + String outputFileName = getOutputFileNames(filename, null)[0]; return new File(outputDir, outputFileName) .toString(); Index: src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectParser.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectParser.java,v retrieving revision 1.1 diff -u -r1.1 MetaObjectParser.java --- src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectParser.java 5 May 2004 03:50:45 -0000 1.1 +++ src/net/sf/antcontrib/cpptasks/trolltech/MetaObjectParser.java 11 May 2004 04:43:47 -0000 @@ -34,7 +34,7 @@ /** * Parser state that matches file T character. */ - private static class FinalTState + private static final class FinalTState extends AbstractParserState { /** * Parser. Index: src/net/sf/antcontrib/cpptasks/trolltech/UserInterfaceCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/trolltech/UserInterfaceCompiler.java,v retrieving revision 1.1 diff -u -r1.1 UserInterfaceCompiler.java --- src/net/sf/antcontrib/cpptasks/trolltech/UserInterfaceCompiler.java 5 May 2004 03:50:45 -0000 1.1 +++ src/net/sf/antcontrib/cpptasks/trolltech/UserInterfaceCompiler.java 11 May 2004 04:43:47 -0000 @@ -29,6 +29,7 @@ import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor; import net.sf.antcontrib.cpptasks.gcc.LdLinker; import net.sf.antcontrib.cpptasks.parser.Parser; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Environment; @@ -125,9 +126,11 @@ /** * Gets output file names. * @param inputFile String input file name + * @param versionInfo version info, not used by this compiler. * @return String[] output file names */ - public String[] getOutputFileNames(final String inputFile) { + public String[] getOutputFileNames(final String inputFile, + final VersionInfo versionInfo) { // // if a recognized input file // @@ -154,15 +157,15 @@ return "-o"; case 1: - String outputFileName = getOutputFileNames(filename)[0]; + String outputFileName = getOutputFileNames(filename, null)[0]; return new File(outputDir, outputFileName) .toString(); case 2: return filename; - default: - return null; + default: + return null; } } @@ -277,7 +280,7 @@ uicIndex = args.length + 2; uicImplIndex = args.length + 2; mocIndex = args.length + 2; - String[] outputFileNames = getOutputFileNames(sourceFiles[j]); + String[] outputFileNames = getOutputFileNames(sourceFiles[j], null); uicCommand[uicIndex++] = outputFileNames[0]; uicCommand[uicIndex++] = sourceFiles[j]; Index: test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java,v retrieving revision 1.13 diff -u -r1.13 TestCompilerDef.java --- test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java 23 Apr 2004 21:15:45 -0000 1.13 +++ test/junit/net/sf/antcontrib/cpptasks/TestCompilerDef.java 11 May 2004 04:43:47 -0000 @@ -322,7 +322,7 @@ linkType.setStaticRuntime(true); CommandLineCompilerConfiguration config = (CommandLineCompilerConfiguration) extendedCompiler - .createConfiguration(cctask, linkType, null, null); + .createConfiguration(cctask, linkType, null, null, null); String[] preArgs = config.getPreArguments(); assertEquals("/ML", preArgs[3]); } Index: test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java,v retrieving revision 1.11 diff -u -r1.11 TestProcessorDef.java --- test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java 23 Apr 2004 21:15:45 -0000 1.11 +++ test/junit/net/sf/antcontrib/cpptasks/TestProcessorDef.java 11 May 2004 04:43:47 -0000 @@ -178,7 +178,11 @@ final ProcessorDef extendedProcessor) { CCTask cctask = new CCTask(); LinkType linkType = new LinkType(); - return extendedProcessor.createConfiguration(cctask, linkType, null, null); + return extendedProcessor.createConfiguration(cctask, + linkType, + null, + null, + null); } /** @@ -199,8 +203,8 @@ * @throws IOException * if unable to delete file */ - protected final void testExtendsFileSet(final File tempFile) - throws IOException { + protected final void testExtendsFileSet(final File tempFile) throws + IOException { ProcessorDef baseLinker = create(); ConditionalFileSet fileSet = new ConditionalFileSet(); ProcessorDef extendedLinker = createExtendedProcessorDef(baseLinker); @@ -264,7 +268,7 @@ * processor under test */ protected final void testExtendsRebuild( - final ProcessorDef baseProcessor) { + final ProcessorDef baseProcessor) { baseProcessor.setRebuild(true); ProcessorDef extendedLinker = createExtendedProcessorDef(baseProcessor); ProcessorConfiguration config = getConfiguration(extendedLinker); Index: test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java,v retrieving revision 1.9 diff -u -r1.9 TestTargetHistoryTable.java --- test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java 5 May 2004 03:50:46 -0000 1.9 +++ test/junit/net/sf/antcontrib/cpptasks/TestTargetHistoryTable.java 11 May 2004 04:43:47 -0000 @@ -20,6 +20,7 @@ import java.io.IOException; import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration; +import net.sf.antcontrib.cpptasks.VersionInfo; /** * Tests for TargetHistoryTable * @@ -37,7 +38,7 @@ public String getIdentifier() { return "Mock Configuration"; } - public String[] getOutputFileNames(String baseName) { + public String[] getOutputFileNames(String baseName, VersionInfo versionInfo) { return new String[] { baseName }; } public ProcessorParam[] getParams() { @@ -123,7 +124,7 @@ // update the table // table.update(new MockProcessorConfiguration(), - new String[]{"dummy.o"}); + new String[]{"dummy.o"}, null); // // commit. If "compiled" file was judged to be // valid we should have a history file. Index: test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java,v retrieving revision 1.12 diff -u -r1.12 TestTargetInfo.java --- test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java 5 May 2004 03:50:46 -0000 1.12 +++ test/junit/net/sf/antcontrib/cpptasks/TestTargetInfo.java 11 May 2004 04:43:47 -0000 @@ -20,6 +20,9 @@ import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration; import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor; import org.apache.tools.ant.BuildException; +import net.sf.antcontrib.cpptasks.VersionInfo; + + /** * A description of a file built or to be built */ @@ -48,7 +51,7 @@ public String getIncludePathIdentifier() { return "dummyIncludePath"; } - public String[] getOutputFileNames(String inputFile) { + public String[] getOutputFileNames(String inputFile, VersionInfo versionInfo) { return new String[0]; } public CompilerParam getParam(String name) { Index: test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java,v retrieving revision 1.20 diff -u -r1.20 TestAbstractCompiler.java --- test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java 5 May 2004 03:50:45 -0000 1.20 +++ test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractCompiler.java 11 May 2004 04:43:47 -0000 @@ -22,6 +22,7 @@ import net.sf.antcontrib.cpptasks.ProcessorDef; import net.sf.antcontrib.cpptasks.parser.CParser; import net.sf.antcontrib.cpptasks.parser.Parser; +import net.sf.antcontrib.cpptasks.VersionInfo; import org.apache.tools.ant.BuildException; /** @@ -41,7 +42,8 @@ } public CompilerConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] def1, CompilerDef def2, - net.sf.antcontrib.cpptasks.TargetDef targetPlatform) { + net.sf.antcontrib.cpptasks.TargetDef targetPlatform, + VersionInfo versionInfo) { return null; } public Parser createParser(File file) { @@ -69,15 +71,15 @@ } public void testGetOutputFileName1() { AbstractProcessor compiler = create(); - String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c"); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.c"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("hello.c"); + output = compiler.getOutputFileNames("hello.c", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); assertEquals(0, output.length); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); assertEquals(0, output.length); } } Index: test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java,v retrieving revision 1.19 diff -u -r1.19 TestAbstractLinker.java --- test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java 5 May 2004 03:50:45 -0000 1.19 +++ test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractLinker.java 11 May 2004 04:43:47 -0000 @@ -22,6 +22,7 @@ import net.sf.antcontrib.cpptasks.ProcessorDef; import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; import net.sf.antcontrib.cpptasks.TargetDef; +import net.sf.antcontrib.cpptasks.VersionInfo; /** * Test for abstract compiler class @@ -37,7 +38,8 @@ final LinkType linkType, final ProcessorDef[] def1, final LinkerDef def2, - final TargetDef targetPlatform) { + final TargetDef targetPlatform, + final VersionInfo versionInfo) { return null; } public String getIdentifier() { @@ -52,7 +54,7 @@ public Linker getLinker(LinkType type) { return null; } - public String[] getOutputFileNames(String sourceFile) { + public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) { return new String[0]; } public String[][] getRuntimeLibraries(boolean debug, Index: test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java,v retrieving revision 1.16 diff -u -r1.16 TestAbstractProcessor.java --- test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java 5 May 2004 03:50:45 -0000 1.16 +++ test/junit/net/sf/antcontrib/cpptasks/compiler/TestAbstractProcessor.java 11 May 2004 04:43:47 -0000 @@ -18,6 +18,7 @@ import junit.framework.TestCase; import net.sf.antcontrib.cpptasks.CCTask; import net.sf.antcontrib.cpptasks.ProcessorDef; +import net.sf.antcontrib.cpptasks.VersionInfo; /** * Test for abstract compiler class * @@ -32,7 +33,8 @@ public ProcessorConfiguration createConfiguration(CCTask task, LinkType linkType, ProcessorDef[] defaultProvider, ProcessorDef specificProvider, - net.sf.antcontrib.cpptasks.TargetDef targetPlatform) { + net.sf.antcontrib.cpptasks.TargetDef targetPlatform, + VersionInfo versionInfo) { return null; } public String getIdentifier() { @@ -41,7 +43,7 @@ public Linker getLinker(LinkType type) { return null; } - public String[] getOutputFileNames(String sourceFile) { + public String[] getOutputFileNames(String sourceFile, VersionInfo versionInfo) { return new String[0]; } public String[][] getRuntimeLibraries(boolean debug, Index: test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java,v retrieving revision 1.8 diff -u -r1.8 TestCompilerConfiguration.java --- test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java 5 May 2004 03:50:45 -0000 1.8 +++ test/junit/net/sf/antcontrib/cpptasks/compiler/TestCompilerConfiguration.java 11 May 2004 04:43:47 -0000 @@ -48,21 +48,21 @@ // may cause IllegalStateException since // setPlatformInfo has not been called try { - String[] output = compiler.getOutputFileNames(input); + String[] output = compiler.getOutputFileNames(input, null); } catch (java.lang.IllegalStateException ex) { } } public void testGetOutputFileName2() { CompilerConfiguration compiler = create(); - String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c"); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.c", null); assertEquals("hello" + getObjectFileExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.c"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.c", null); assertEquals("hello" + getObjectFileExtension(), output[0]); - output = compiler.getOutputFileNames("hello.c"); + output = compiler.getOutputFileNames("hello.c", null); assertEquals("hello" + getObjectFileExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); assertEquals(0, output.length); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); assertEquals(0, output.length); } } Index: test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java,v retrieving revision 1.5 diff -u -r1.5 TestAbstractArLibrarian.java --- test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java 5 May 2004 03:50:44 -0000 1.5 +++ test/junit/net/sf/antcontrib/cpptasks/gcc/TestAbstractArLibrarian.java 11 May 2004 04:43:47 -0000 @@ -73,7 +73,7 @@ * See bug [ 687732 ] Filenames for gcc static library does start with lib */ public void testOutputFileName() { - String[] outputFiles = GccLibrarian.getInstance().getOutputFileNames("x"); + String[] outputFiles = GccLibrarian.getInstance().getOutputFileNames("x", null); assertEquals("libx.a", outputFiles[0]); } } Index: test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java,v retrieving revision 1.4 diff -u -r1.4 TestGccLinker.java --- test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java 5 May 2004 03:50:44 -0000 1.4 +++ test/junit/net/sf/antcontrib/cpptasks/gcc/TestGccLinker.java 11 May 2004 04:43:47 -0000 @@ -45,7 +45,7 @@ LinkType linkType = new LinkType(); linkType.setOutputType(outputType); Linker pluginLinker = linker.getLinker(linkType); - assertEquals("libfoo.bundle", pluginLinker.getOutputFileNames("foo")[0]); + assertEquals("libfoo.bundle", pluginLinker.getOutputFileNames("foo", null)[0]); } public void testGetLinkerDarwinShared() { System.setProperty("os.name", "Mac OS X"); @@ -55,7 +55,7 @@ LinkType linkType = new LinkType(); linkType.setOutputType(outputType); Linker sharedLinker = linker.getLinker(linkType); - assertEquals("libfoo.dylib", sharedLinker.getOutputFileNames("foo")[0]); + assertEquals("libfoo.dylib", sharedLinker.getOutputFileNames("foo", null)[0]); } public void testGetLinkerNonDarwinPlugin() { System.setProperty("os.name", "Microsoft Windows"); @@ -65,7 +65,7 @@ LinkType linkType = new LinkType(); linkType.setOutputType(outputType); Linker pluginLinker = linker.getLinker(linkType); - assertEquals("libfoo.so", pluginLinker.getOutputFileNames("foo")[0]); + assertEquals("libfoo.so", pluginLinker.getOutputFileNames("foo", null)[0]); } public void testGetLinkerNonDarwinShared() { System.setProperty("os.name", "Microsoft Windows"); @@ -75,6 +75,6 @@ LinkType linkType = new LinkType(); linkType.setOutputType(outputType); Linker sharedLinker = linker.getLinker(linkType); - assertEquals("libfoo.so", sharedLinker.getOutputFileNames("foo")[0]); + assertEquals("libfoo.so", sharedLinker.getOutputFileNames("foo", null)[0]); } } Index: test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java,v retrieving revision 1.1 diff -u -r1.1 TestMetaObjectCompiler.java --- test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java 5 May 2004 03:50:44 -0000 1.1 +++ test/junit/net/sf/antcontrib/cpptasks/trolltech/TestMetaObjectCompiler.java 11 May 2004 04:43:47 -0000 @@ -60,15 +60,15 @@ */ public void testGetOutputFileName1() { AbstractProcessor compiler = MetaObjectCompiler.getInstance(); - String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.cpp"); + String[] output = compiler.getOutputFileNames("c:/foo\\bar\\hello.cpp", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.cpp"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.cpp", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("hello.cpp"); + output = compiler.getOutputFileNames("hello.cpp", null); assertEquals("hello" + getObjectExtension(), output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar\\hello.h", null); assertEquals("moc_hello.cpp", output[0]); - output = compiler.getOutputFileNames("c:/foo\\bar/hello.h"); + output = compiler.getOutputFileNames("c:/foo\\bar/hello.h", null); assertNull("moc_hello.cpp", output[0]); } } Index: src/net/sf/antcontrib/cpptasks/platforms/WindowsPlatform.java =================================================================== RCS file: src/net/sf/antcontrib/cpptasks/platforms/WindowsPlatform.java diff -N src/net/sf/antcontrib/cpptasks/platforms/WindowsPlatform.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/net/sf/antcontrib/cpptasks/platforms/WindowsPlatform.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,364 @@ +/* + * + * 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. + */ +package net.sf.antcontrib.cpptasks.platforms; + +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import net.sf.antcontrib.cpptasks.CUtil; +import net.sf.antcontrib.cpptasks.TargetMatcher; +import net.sf.antcontrib.cpptasks.VersionInfo; +import net.sf.antcontrib.cpptasks.compiler.LinkType; + + +/** + * Platform specific behavior for Microsoft Windows. + * + * @author Curt Arnold + */ +public final class WindowsPlatform { + + /** + * Constructor. + */ + private WindowsPlatform() { + } + /** + * Adds source or object files to the bidded fileset to + * support version information. + * + * @param versionInfo version information + * @param linkType link type + * @param isDebug true if debug build + * @param outputFile name of generated executable + * @param objDir directory for generated files + * @param matcher bidded fileset + * @throws IOException if unable to write version resource + */ + public static void addVersionFiles(final VersionInfo versionInfo, + final LinkType linkType, + final File outputFile, + final boolean isDebug, + final File objDir, + final TargetMatcher matcher) + throws IOException { + if (versionInfo == null) { + throw new NullPointerException("versionInfo"); + } + if (linkType == null) { + throw new NullPointerException("linkType"); + } + if (outputFile == null) { + throw new NullPointerException("outputFile"); + } + if (objDir == null) { + throw new NullPointerException("objDir"); + } + + /** + * Fully resolve version info + */ + VersionInfo mergedInfo = versionInfo.merge(); + + File versionResource = new File(objDir, "versioninfo.rc"); + + boolean notChanged = false; + // + // if the resource exists + // + if (versionResource.exists()) { + ByteArrayOutputStream memStream = new ByteArrayOutputStream(); + Writer writer = new BufferedWriter(new OutputStreamWriter(memStream)); + writeResource(writer, mergedInfo, outputFile, isDebug, linkType); + writer.close(); + ByteArrayInputStream proposedResource = new ByteArrayInputStream( + memStream.toByteArray()); + + InputStream existingResource = new FileInputStream(versionResource); + // + // + // + notChanged = hasSameContent(proposedResource, existingResource); + existingResource.close(); + } + + // + // if the resource file did not exist or will be changed then + // write the file + // + if (!notChanged) { + Writer writer = new BufferedWriter( + new OutputStreamWriter( + new FileOutputStream(versionResource))); + writeResource(writer, mergedInfo, outputFile, isDebug, linkType); + writer.close(); + } + if (matcher != null) { + matcher.visit(new File(versionResource.getParent()), + versionResource.getName()); + } + + } + + /** + * Compare two input streams for duplicate content + * + * Naive implementation, but should not be performance issue. + * @param stream1 stream + * @param stream2 stream + * @return true if streams are identical in content + * @throws IOException if error reading streams + */ + private static boolean hasSameContent(final InputStream stream1, + final InputStream stream2) + throws IOException { + int byte1 = -1; + int byte2 = -1; + do { + byte1 = stream1.read(); + byte2 = stream2.read(); + + } + while (byte1 == byte2 && byte1 != -1); + return (byte1 == byte2); + } + + + /** + * Parse version string into array of four short values. + * @param version String version + * @return short[] four element array + */ + public static short[] parseVersion(final String version) { + short[] values = new short[] { + 0, 0, 0, 0}; + if (version != null) { + StringBuffer buf = new StringBuffer(version); + int start = 0; + for (int i = 0; i < 4; i++) { + int end = version.indexOf('.', start); + if (end <= 0) { + end = version.length(); + for (int j = end; j > start; j--) { + String part = buf.substring(start, end); + try { + values[i] = Short.parseShort(part); + break; + } catch (NumberFormatException ex) { + values[i] = 0; + } + } + break; + } else { + String part = buf.substring(start, end); + try { + values[i] = Short.parseShort(part); + start = end + 1; + } catch (NumberFormatException ex) { + break; + } + } + } + } + return values; + } + + /** + * Converts parsed version information into a string representation. + * + * @param buf StringBuffer string buffer to receive version number + * @param version short[] four-element array + */ + private static void encodeVersion(final StringBuffer buf, + final short[] version) { + for (int i = 0; i < 3; i++) { + buf.append(Short.toString(version[i])); + buf.append(','); + } + buf.append(Short.toString(version[3])); + } + + /** + * Writes windows resource. + * @param writer writer, may not be nul + * @param versionInfo version information + * @param outputFile executable file + * @param isDebug true if debug + * @param linkType link type + * @throws IOException if error writing resource file + */ + public static void writeResource(final Writer writer, + final VersionInfo versionInfo, + final File outputFile, + final boolean isDebug, + final LinkType linkType) throws IOException { + + writer.write("#include \"windows.h\"\n"); + + writer.write("VS_VERSION_INFO VERSIONINFO\n"); + StringBuffer buf = new StringBuffer("FILEVERSION "); + encodeVersion(buf, parseVersion(versionInfo.getFileversion())); + buf.append("\nPRODUCTVERSION "); + encodeVersion(buf, parseVersion(versionInfo.getProductversion())); + buf.append("\n"); + writer.write(buf.toString()); + buf.setLength(0); + buf.append("FILEFLAGSMASK VS_FF_DEBUG"); + Boolean patched = versionInfo.getPatched(); + Boolean prerelease = versionInfo.getPrerelease(); + if (patched != null) { + buf.append(" | VS_FF_PATCHED"); + } + if (prerelease != null) { + buf.append(" | VS_FF_PRERELEASE"); + } + if (versionInfo.getPrivatebuild() != null) { + buf.append(" | VS_FF_PRIVATEBUILD"); + } + if (versionInfo.getSpecialbuild() != null) { + buf.append(" | VS_FF_SPECIALBUILD"); + } + buf.append('\n'); + writer.write(buf.toString()); + buf.setLength(0); + buf.append("FILEFLAGS "); + + if (isDebug) { + buf.append("VS_FF_DEBUG | "); + } + if (Boolean.TRUE.equals(patched)) { + buf.append("VS_FF_PATCHED | "); + } + if (Boolean.TRUE.equals(prerelease)) { + buf.append("VS_FF_PRERELEASE | "); + } + if (Boolean.TRUE.equals(versionInfo.getPrivatebuild())) { + buf.append("VS_FF_PRIVATEBUILD | "); + } + if (Boolean.TRUE.equals(versionInfo.getSpecialbuild())) { + buf.append("VS_FF_SPECIALBUILD | "); + } + if (buf.length() > 10) { + buf.setLength(buf.length() - 3); + buf.append('\n'); + } else { + buf.append("0\n"); + } + writer.write(buf.toString()); + buf.setLength(0); + + writer.write("FILEOS VOS_NT_WINDOWS32\nFILETYPE "); + if (linkType.isExecutable()) { + writer.write("VFT_APP\n"); + } else { + if (linkType.isSharedLibrary()) { + writer.write("VFT_DLL\n"); + } else if (linkType.isStaticLibrary()) { + writer.write("VFT_STATIC_LIB\n"); + } else { + writer.write("VFT_UNKNOWN\n"); + } + } + writer.write("FILESUBTYPE 0x0L\n"); + writer.write("BEGIN\n"); + writer.write("BLOCK \"StringFileInfo\"\n"); + writer.write(" BEGIN\n#ifdef UNICODE\nBLOCK \"040904B0\"\n"); + writer.write("#else\nBLOCK \"040904E4\"\n#endif\n"); + writer.write("BEGIN\n"); + if (versionInfo.getFilecomments() != null) { + writer.write("VALUE \"Comments\", \""); + writer.write(versionInfo.getFilecomments()); + writer.write("\\0\"\n"); + } + if (versionInfo.getCompanyname() != null) { + writer.write("VALUE \"CompanyName\", \""); + writer.write(versionInfo.getCompanyname()); + writer.write("\\0\"\n"); + } + if (versionInfo.getFiledescription() != null) { + writer.write("VALUE \"FileDescription\", \""); + writer.write(versionInfo.getFiledescription()); + writer.write("\\0\"\n"); + } + if (versionInfo.getFileversion() != null) { + writer.write("VALUE \"FileVersion\", \""); + writer.write(versionInfo.getFileversion()); + writer.write("\\0\"\n"); + } + String baseName = CUtil.getBasename(outputFile); + String internalName = versionInfo.getInternalname(); + if (internalName == null) { + internalName = baseName; + } + writer.write("VALUE \"InternalName\", \""); + writer.write(internalName); + writer.write("\\0\"\n"); + if (versionInfo.getLegalcopyright() != null) { + writer.write("VALUE \"LegalCopyright\", \""); + writer.write(versionInfo.getLegalcopyright()); + writer.write("\\0\"\n"); + } + if (versionInfo.getLegaltrademarks() != null) { + writer.write("VALUE \"LegalTrademarks\", \""); + writer.write(versionInfo.getLegaltrademarks()); + writer.write("\\0\"\n"); + } + writer.write("VALUE \"OriginalFilename\", \""); + writer.write(baseName); + writer.write("\\0\"\n"); + if (versionInfo.getPrivatebuild() != null) { + writer.write("VALUE \"PrivateBuild\", \""); + writer.write(versionInfo.getPrivatebuild()); + writer.write("\\0\"\n"); + } + if (versionInfo.getProductname() != null) { + writer.write("VALUE \"ProductName\", \""); + writer.write(versionInfo.getProductname()); + writer.write("\\0\"\n"); + } + if (versionInfo.getProductversion() != null) { + writer.write("VALUE \"ProductVersion\", \""); + writer.write(versionInfo.getProductversion()); + writer.write("\\0\"\n"); + } + if (versionInfo.getSpecialbuild() != null) { + writer.write("VALUE \"SpecialBuild\", \""); + writer.write(versionInfo.getSpecialbuild()); + writer.write("\\0\"\n"); + } + writer.write("END\n"); + writer.write("END\n"); + + writer.write("BLOCK \"VarFileInfo\"\n"); + writer.write("BEGIN\n#ifdef UNICODE\n"); + writer.write("VALUE \"Translation\", 0x409, 1200\n"); + writer.write("#else\n"); + writer.write("VALUE \"Translation\", 0x409, 1252\n"); + writer.write("#endif\n"); + writer.write("END\n"); + writer.write("END\n"); + } + +} Index: src/net/sf/antcontrib/cpptasks/platforms/package.html =================================================================== RCS file: src/net/sf/antcontrib/cpptasks/platforms/package.html diff -N src/net/sf/antcontrib/cpptasks/platforms/package.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/net/sf/antcontrib/cpptasks/platforms/package.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,27 @@ + + + + + + + +Platform specific utilities. + + +