diff options
Diffstat (limited to 'src/main')
6 files changed, 73 insertions, 13 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java b/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java index aaa3881..59ca033 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/DependencyTable.java @@ -555,8 +555,21 @@ public final class DependencyTable { // for (int i = 0; i < includeInfos.length; i++) { DependencyInfo includeInfo = includeInfos[i]; - walkDependencies(task, includeInfo, compiler, stack, - visitor); + // Darren Sargent 23Oct2008 + // only recurse for direct includes of current source + // file + if (includeInfo.getSource().contains( + File.separatorChar + "src" + File.separatorChar + + "main") + || includeInfo.getSource().contains( + File.separatorChar + "src" + + File.separatorChar + "test")) { + task.log("Walking dependencies for " + + includeInfo.getSource(), + Project.MSG_VERBOSE); + walkDependencies(task, includeInfo, compiler, + stack, visitor); + } } } } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java index 46ec59a..58cd7b1 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/CommandLineCompiler.java @@ -48,6 +48,7 @@ public abstract class CommandLineCompiler extends AbstractCompiler { private final boolean newEnvironment; protected CommandLineCompiler(String command, String identifierArg, String[] sourceExtensions, String[] headerExtensions, + String outputSuffix, boolean libtool, CommandLineCompiler libtoolCompiler, boolean newEnvironment, Environment env) { @@ -83,14 +84,15 @@ public abstract class CommandLineCompiler extends AbstractCompiler { * configuration identifier */ protected void addIncludes(String baseDirPath, File[] includeDirs, - Vector args, Vector relativeArgs, StringBuffer includePathId) { + Vector args, Vector relativeArgs, StringBuffer includePathId, + boolean isSystem) { for (int i = 0; i < includeDirs.length; i++) { args.addElement(getIncludeDirSwitch(includeDirs[i] - .getAbsolutePath())); + .getAbsolutePath(), isSystem)); if (relativeArgs != null) { - String relative = CUtil.getRelativePath(baseDirPath, + String relative = CUtil.getRelativePath(baseDirPath, includeDirs[i]); - relativeArgs.addElement(getIncludeDirSwitch(relative)); + relativeArgs.addElement(getIncludeDirSwitch(relative, isSystem)); if (includePathId != null) { if (includePathId.length() == 0) { includePathId.append("/I"); @@ -199,6 +201,7 @@ public abstract class CommandLineCompiler extends AbstractCompiler { int retval = runCommand(task, outputDir, commandline); if (monitor != null) { String[] fileNames = new String[firstFileNextExec - sourceIndex]; + for (int j = 0; j < fileNames.length; j++) { fileNames[j] = sourceFiles[sourceIndex + j]; } @@ -215,6 +218,7 @@ public abstract class CommandLineCompiler extends AbstractCompiler { exc = new BuildException(this.getCommand() + " failed with return code " + retval, task .getLocation()); + // // and throw it now unless we are relentless // @@ -278,6 +282,8 @@ public abstract class CommandLineCompiler extends AbstractCompiler { Boolean rtti = specificDef.getRtti(defaultProviders, 1); OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1); this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization); + + // // add all appropriate defines and undefines // @@ -346,8 +352,8 @@ public abstract class CommandLineCompiler extends AbstractCompiler { sysIncPath[i] = new File((String) sysIncludePath.elementAt(i)); } addIncludes(baseDirPath, incPath, args, relativeArgs, - includePathIdentifier); - addIncludes(baseDirPath, sysIncPath, args, null, null); + includePathIdentifier, false); + addIncludes(baseDirPath, sysIncPath, args, null, null, true); StringBuffer buf = new StringBuffer(getIdentifier()); for (int i = 0; i < relativeArgs.size(); i++) { buf.append(' '); @@ -387,7 +393,23 @@ public abstract class CommandLineCompiler extends AbstractCompiler { return identifier; } abstract protected String getIncludeDirSwitch(String source); - protected String getInputFileArgument(File outputDir, String filename, + + /** + * Added by Darren Sargent 22Oct2008 Returns the include dir switch value. + * Default implementation doesn't treat system includes specially, for + * compilers which don't care. + * + * @param source + * the given source value. + * @param isSystem + * "true" if this is a system include path + * + * @return the include dir switch value. + */ + protected String getIncludeDirSwitch(String source, boolean isSystem) { + return getIncludeDirSwitch(source); + } + protected String getInputFileArgument(File outputDir, String filename, int index) { // // if there is an embedded space, diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java index cc4493d..cb378c0 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleCCompiler.java @@ -92,6 +92,10 @@ public abstract class DevStudioCompatibleCCompiler args.addElement(mflag); if (rtti != null && rtti.booleanValue()) { args.addElement("/GR"); + } else { + // added by Darren Sargent, 21Mar2008 -- /GR is default so need + // /GR- to disable it + args.addElement("/GR-"); } } protected void addDebugSwitch(Vector args) { @@ -118,6 +122,7 @@ public abstract class DevStudioCompatibleCCompiler String[] additionalArgs = new String[]{ "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yu" + lastInclude}; + return new CommandLineCompilerConfiguration(baseConfig, additionalArgs, exceptFiles, false); } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java index f975f49..fd32619 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/devstudio/VisualStudioNETProjectWriter.java @@ -200,12 +200,18 @@ public final class VisualStudioNETProjectWriter final CommandLineCompilerConfiguration compilerConfig) { File[] includePath = compilerConfig.getIncludePath(); StringBuffer includeDirs = new StringBuffer(); - for (int i = 0; i < includePath.length; i++) { - String relPath = CUtil.getRelativePath(baseDir, includePath[i]); - includeDirs.append(CUtil.toWindowsPath(relPath)); + // Darren Sargent Feb 10 2010 -- reverted to older code to ensure sys + // includes get, erm, included + String[] args = compilerConfig.getPreArguments(); + + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("/I")) { + includeDirs.append(args[i].substring(2)); includeDirs.append(';'); } + } + // end Darren if (includeDirs.length() > 0) { includeDirs.setLength(includeDirs.length() - 1); @@ -360,6 +366,11 @@ public final class VisualStudioNETProjectWriter if ("/W3".equals(args[i])) { warn = "3"; } + // Added by Darren Sargent, 2/26/2008 + if ("/W4".equals(args[i])) { + warn = "4"; + } + // end added } return warn; } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java index 33f5018..bbc72f0 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCCompiler.java @@ -135,7 +135,8 @@ public final class GccCCompiler extends GccCompatibleCCompiler { // BEGINFREEHEP // Add -fno_rtti only for g++ and c++ if (!getCommand().equals("g77") && !getCommand().equals("gcc") && (rtti != null) && (!rtti.booleanValue())) { - args.addElement("-fno_rtti"); + // Darren Sargent: fix RTTI option + args.addElement("-fno-rtti"); } // ENDFREEHEP } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java index 0fce11b..560b608 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GccCompatibleCCompiler.java @@ -142,9 +142,17 @@ public abstract class GccCompatibleCCompiler extends CommandLineCCompiler { protected File[] getEnvironmentIncludePath() { return CUtil.getPathFromEnvironment("INCLUDE", ":"); } + // Darren Sargent 22Oct2008 - added overloads to properly handle system paths public String getIncludeDirSwitch(String includeDir) { + return getIncludeDirSwitch(includeDir, false); + } + public String getIncludeDirSwitch(String includeDir, boolean isSystem) { + if ( isSystem ) { + return "-isystem" + includeDir; + } else { return "-I" + includeDir; } + } public void getUndefineSwitch(StringBuffer buffer, String define) { buffer.append("-U"); buffer.append(define); |