Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Adam Murdoch <adammurdoch@us...> - 2002-01-08 12:26:47
|
Update of /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks In directory usw-pr-cvs1:/tmp/cvs-serv5426/src/net/sf/antcontrib/cpptasks Modified Files: LinkerDef.java CompilerDef.java CCTask.java Log Message: - Allow nested <defineset> <includepath> <sysincludepath> and <compilerarg> elements inside <compiler> elements. - Allow nested <libset> and <linkerarg> elements inside <linker> elements. Index: LinkerDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/LinkerDef.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinkerDef.java 2001/12/19 08:44:58 1.1 --- LinkerDef.java 2002/01/08 12:26:44 1.2 *************** *** 54,57 **** --- 54,64 ---- package net.sf.antcontrib.cpptasks; + import org.apache.tools.ant.types.Commandline; + import net.sf.antcontrib.cpptasks.compiler.SimpleLinkConfig; + import net.sf.antcontrib.cpptasks.compiler.LinkConfig; + import net.sf.antcontrib.cpptasks.types.LibrarySet; + + import java.util.*; + /** * A linker definition. *************** *** 61,64 **** --- 68,103 ---- public class LinkerDef extends AbstractDef { + /** + * Adds a linker command-line arg. + */ + public void addConfiguredLinkerArg(Commandline.Argument arg) + { + _config.addCommandLineArgs(arg.getParts()); + } + /** + * Adds a library set. + */ + public void addLibset(LibrarySet libset) + { + _libsets.addElement(libset); + } + + /** + * Returns the linker-specific config. + */ + public LinkConfig getConfig() + { + return _config; + } + /** + * Returns the linker-specific libsets. + */ + public Vector getLibsets() + { + return _libsets; + } + + private SimpleLinkConfig _config = new SimpleLinkConfig(); + private Vector _libsets = new Vector(); } Index: CompilerDef.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CompilerDef.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CompilerDef.java 2001/12/19 08:44:58 1.1 --- CompilerDef.java 2002/01/08 12:26:44 1.2 *************** *** 56,59 **** --- 56,65 ---- import net.sf.antcontrib.cpptasks.compiler.CCompiler; import net.sf.antcontrib.cpptasks.compiler.CompilerAdaptor; + import net.sf.antcontrib.cpptasks.compiler.SimpleCConfig; + import net.sf.antcontrib.cpptasks.compiler.CompileConfig; + import net.sf.antcontrib.cpptasks.types.DefineSet; + import org.apache.tools.ant.types.Commandline; + import org.apache.tools.ant.types.Path; + import org.apache.tools.ant.Project; /** *************** *** 64,66 **** --- 70,141 ---- public class CompilerDef extends AbstractDef { + /** + * Adds a compiler command-line arg. + */ + public void addConfiguredCompilerArg(Commandline.Argument arg) + { + _config.addCommandLineArgs(arg.getParts()); + } + + /** + * Adds a defineset. + */ + public void addConfiguredDefineset(DefineSet defs) + { + _config.addDefines(defs.getDefines()); + } + + /** + * Creates an include path. + */ + public Path createIncludePath() + { + return _incpath.createPath(); + } + + /** + * Creates a system include path. + */ + public Path createSysincludepath() + { + return _sysincpath.createPath(); + } + + /** + * Sets the project. + */ + public void setProject(Project project) + { + super.setProject(project); + _incpath = new Path(project); + _sysincpath = new Path(project); + } + + /** + * Returns the compiler-specific config. + */ + public CompileConfig getConfig() + { + return _config; + } + + /** + * Returns the compiler-specific include path. + */ + public Path getIncludePath() + { + return _incpath; + } + + /** + * Returns the compiler-specific system include path. + */ + public Path getSystemIncludePath() + { + return _sysincpath; + } + + private SimpleCConfig _config = new SimpleCConfig(); + private Path _incpath; + private Path _sysincpath; } Index: CCTask.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CCTask.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CCTask.java 2001/12/22 02:30:26 1.6 --- CCTask.java 2002/01/08 12:26:44 1.7 *************** *** 92,96 **** * Creates an include path. */ ! public Path createIncludepath() { return _incpath.createPath(); --- 92,96 ---- * Creates an include path. */ ! public Path createIncludePath() { return _incpath.createPath(); *************** *** 100,104 **** * Creates a system include path. */ ! public Path createSysincludepath() { return _sysincpath.createPath(); --- 100,104 ---- * Creates a system include path. */ ! public Path createSysIncludePath() { return _sysincpath.createPath(); *************** *** 215,224 **** } ! // Find the compiler to use ! CompilerAdaptor adaptor = findAdaptor(_compilers, CompilerAdaptorFactory.getDefaultAdaptor()); // Compile Vector linkInputFiles = new Vector(); ! compile(adaptor, linkInputFiles); // Skip the link if requested --- 215,235 ---- } ! // Determine which compiler to use ! CompilerDef compilerDef = null; ! for ( int i = 0; i < _compilers.size(); i++ ) { ! CompilerDef def = (CompilerDef)_compilers.elementAt(i); ! if ( def.include() ) { ! compilerDef = def; ! break; ! } ! } ! CompilerAdaptor adaptor = CompilerAdaptorFactory.getDefaultAdaptor(); ! if ( compilerDef != null ) { ! adaptor = compilerDef.getCompilerAdaptor(); ! } // Compile Vector linkInputFiles = new Vector(); ! compile(compilerDef, adaptor, linkInputFiles); // Skip the link if requested *************** *** 228,235 **** // Find the linker to use ! adaptor = findAdaptor(_linkers, adaptor); // Link ! link(adaptor, linkInputFiles); } --- 239,256 ---- // Find the linker to use ! LinkerDef linkerDef = null; ! for ( int i = 0; i < _linkers.size(); i++ ) { ! LinkerDef def = (LinkerDef)_linkers.elementAt(i); ! if ( def.include() ) { ! linkerDef = def; ! break; ! } ! } ! if ( linkerDef != null ) { ! adaptor = linkerDef.getCompilerAdaptor(); ! } // Link ! link(linkerDef, adaptor, linkInputFiles); } *************** *** 237,256 **** * Compiles the source file. * ! * @param compiler ! * The compiler to use. * * @param linkInputFiles * Returns the files which should be included when linking. */ ! private void compile(CompilerAdaptor adaptor, Vector linkInputFiles) throws BuildException { CCompiler compiler = adaptor.getCCompiler(); // Add config ! String[] incDirs = _incpath.list(); ! _config.appendIncludePath(incDirs); ! _config.appendIncludePath(_sysincpath.list()); ! _config.setTarget(_linkType); // Get the dependency caches DependencyCache headerDepCache = DependencyCache.getCache(project, "c_header"); --- 258,299 ---- * Compiles the source file. * ! * @param compilerDef ! * The compiler definition to use. ! * ! * @param adaptor ! * The compiler adaptor to use. * * @param linkInputFiles * Returns the files which should be included when linking. */ ! private void compile(CompilerDef compilerDef, ! CompilerAdaptor adaptor, ! Vector linkInputFiles) throws BuildException { CCompiler compiler = adaptor.getCCompiler(); + // Set-up the config + SimpleCConfig config = new SimpleCConfig(); + // Add config ! if ( compilerDef != null ) { ! config.addConfig(compilerDef.getConfig()); ! } ! config.addConfig(_config); ! ! // Add include paths ! config.appendIncludePath(_incpath.list()); ! if ( compilerDef != null ) { ! config.appendIncludePath(compilerDef.getIncludePath().list()); ! } ! String[] incDirs = config.getIncludePath(); + // Add system include paths + if ( compilerDef != null ) { + config.appendIncludePath(compilerDef.getSystemIncludePath().list()); + } + config.appendIncludePath(_sysincpath.list()); + config.setTarget(_linkType); + // Get the dependency caches DependencyCache headerDepCache = DependencyCache.getCache(project, "c_header"); *************** *** 319,323 **** } else if ( ! oldConfig._compilerName.equals(adaptor.getName()) ! || ! compiler.isSameConfiguration(oldConfig._config, _config) ) { // Different config, compile again log("Compiling \"" + srcFile.getName() + "\" because its compile settings have changed.", Project.MSG_INFO); --- 362,366 ---- } else if ( ! oldConfig._compilerName.equals(adaptor.getName()) ! || ! compiler.isSameConfiguration(oldConfig._config, config) ) { // Different config, compile again log("Compiling \"" + srcFile.getName() + "\" because its compile settings have changed.", Project.MSG_INFO); *************** *** 336,343 **** // Run the compiler ! compiler.compile(this, srcFile, destFile, _config); // Add the compile config to the cache ! CompileInfo info = new CompileInfo(adaptor.getName(), srcFile.getAbsolutePath(), _config); configCache.put(destFile, info); } --- 379,386 ---- // Run the compiler ! compiler.compile(this, srcFile, destFile, config); // Add the compile config to the cache ! CompileInfo info = new CompileInfo(adaptor.getName(), srcFile.getAbsolutePath(), config); configCache.put(destFile, info); } *************** *** 348,357 **** * Links an output file. * ! * @param linker ! * The linker to use. * @param linkInputFiles * The input files. */ ! private void link(CompilerAdaptor adaptor, Vector linkInputFiles) throws BuildException { Linker linker = adaptor.getLinker(_linkType); --- 391,406 ---- * Links an output file. * ! * @param linkerDef ! * The linker definition to use. ! * ! * @param adaptor ! * The compiler adaptor to use. ! * * @param linkInputFiles * The input files. */ ! private void link(LinkerDef linkerDef, ! CompilerAdaptor adaptor, ! Vector linkInputFiles) throws BuildException { Linker linker = adaptor.getLinker(_linkType); *************** *** 365,371 **** File outfile = new File(destdir, outFileName); // Locate the libraries and add them to the link input ! for ( int i = 0; i < _libsets.size(); i++ ) { ! LibrarySet libset = (LibrarySet)_libsets.elementAt(i); String[] libNames = libset.getLibNames(); String[] path = libset.getLibpath().list(); --- 414,432 ---- File outfile = new File(destdir, outFileName); + // Build link config + SimpleLinkConfig config = new SimpleLinkConfig(); + if ( linkerDef != null ) { + config.addConfig(linkerDef.getConfig()); + } + config.addConfig(_linkConfig); + // Locate the libraries and add them to the link input ! Vector libsets = new Vector(); ! libsets.addAll(_libsets); ! if ( linkerDef != null ) { ! libsets.addAll(linkerDef.getLibsets()); ! } ! for ( int i = 0; i < libsets.size(); i++ ) { ! LibrarySet libset = (LibrarySet)libsets.elementAt(i); String[] libNames = libset.getLibNames(); String[] path = libset.getLibpath().list(); *************** *** 379,383 **** else { // Assume it's a system library - pass to the linker ! _linkConfig.addLibrary(libName); } } --- 440,444 ---- else { // Assume it's a system library - pass to the linker ! config.addLibrary(libName); } } *************** *** 419,423 **** else if ( ! info._linkerName.equals(adaptor.getName()) || info._linkType != _linkType ! || ! linker.isSameConfiguration(info._config, _linkConfig) ) { log("Linking \"" + outfile.getName() + "\" because its link settings have changed."); needLink = true; --- 480,484 ---- else if ( ! info._linkerName.equals(adaptor.getName()) || info._linkType != _linkType ! || ! linker.isSameConfiguration(info._config, config) ) { log("Linking \"" + outfile.getName() + "\" because its link settings have changed."); needLink = true; *************** *** 441,461 **** // Invoke the linker ! linker.link(this, outfile, linkInputFiles, _linkConfig); ! LinkInfo info = new LinkInfo(adaptor.getName(), _linkType, _linkConfig); configCache.put(outfile, info); - } - - /** - * Locates the compiler adaptor to use. - */ - private CompilerAdaptor findAdaptor(Vector defs, CompilerAdaptor defaultAdaptor) - { - for ( int i = 0; i < defs.size(); i++ ) { - AbstractDef def = (AbstractDef)defs.elementAt(i); - if ( def.include() ) { - return def.getCompilerAdaptor(); - } - } - return defaultAdaptor; } --- 502,508 ---- // Invoke the linker ! linker.link(this, outfile, linkInputFiles, config); ! LinkInfo info = new LinkInfo(adaptor.getName(), _linkType, config); configCache.put(outfile, info); } |