diff options
Diffstat (limited to 'src/net')
6 files changed, 79 insertions, 42 deletions
diff --git a/src/net/sf/antcontrib/cpptasks/CCTask.java b/src/net/sf/antcontrib/cpptasks/CCTask.java index cd780fa..b6c424f 100644 --- a/src/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/net/sf/antcontrib/cpptasks/CCTask.java @@ -175,7 +175,7 @@ public class CCTask extends Task { return targetsByConfig; } -// FREEHEP + // FREEHEP private int maxCores = 0; /** The compiler definitions. */ private Vector _compilers = new Vector(); @@ -739,18 +739,20 @@ public class CCTask extends Task { // // prepare the list of source files // - + // BEGINFREEHEP int noOfCores = Runtime.getRuntime().availableProcessors(); if (maxCores > 0) { - noOfCores = Math.min(maxCores, noOfCores); + noOfCores = Math.min(maxCores, noOfCores); } int noOfFiles = targetsForConfig.size(); - if (noOfFiles < noOfCores) noOfCores = targetsForConfig.size(); + if (noOfFiles < noOfCores) + noOfCores = targetsForConfig.size(); Set[] sourceFiles = new HashSet[noOfCores]; - for (int j=0; j<sourceFiles.length; j++) { - sourceFiles[j] = new HashSet(targetsForConfig.size() / sourceFiles.length); + for (int j = 0; j < sourceFiles.length; j++) { + sourceFiles[j] = new HashSet(targetsForConfig.size() + / sourceFiles.length); } Enumeration targetsEnum = targetsForConfig.elements(); index = 0; @@ -761,37 +763,66 @@ public class CCTask extends Task { .toString()); index %= sourceFiles.length; } - + + // setup cores/cpus Core[] cores = new Core[noOfCores]; - for (int j=0; j<cores.length; j++) { + for (int j = 0; j < cores.length; j++) { cores[j] = new Core(this, config, _objDir, sourceFiles[j], - relentless, monitor); + relentless, monitor); + log("\nStarting Core " + j + " with " + + sourceFiles[j].size() + " source files..."); + } + + // starting cores + for (int j = 0; j < cores.length; j++) { cores[j].start(); - System.err.println("\nStarted Core "+j+" with "+sourceFiles[j].size()+" source files..."); } + // checking cores + boolean alive = false; try { - for (int j=0; j<cores.length; j++) { - System.err.println("\nJoining Core "+j); - cores[j].join(); - } - } catch (InterruptedException ex) { + do { + alive = false; + for (int j = 0; j < cores.length; j++) { + if (cores[j] != null) { + if (cores[j].isAlive()) { + alive = true; + } else { + Exception exception = cores[j].getException(); + if (exception != null) { + if ((compileException == null) && (exception instanceof BuildException)) { + compileException = (BuildException)exception; + } else { + log(cores[j].getName()+" "+exception+" ", Project.MSG_ERR); + } + if (!relentless) { + cores[j] = null; + alive = false; + break; + } + } + cores[j] = null; + } + } + } + if (alive) { + Thread.sleep(5000); + } + } while (alive); + } catch (InterruptedException e) { break; } - - Exception exception = null; - for (int j=0; j<cores.length; j++) { - System.err.println("\nChecking Core "+j); - exception = cores[j].getException(); - if (exception != null) break; - } - if (exception != null) { - if (exception instanceof BuildException) { - compileException = (BuildException)exception; + + // killing leftovers + for (int j = 0; j < cores.length; j++) { + if (cores[j] != null) { + cores[j].interrupt(); + log(cores[j].getName()+" interrupted "); } - if (!relentless) - break; } + + if (!relentless) + break; // ENDFREEHEP } @@ -904,9 +935,8 @@ public class CCTask extends Task { private Exception compileException; private CCTask task; - Core(CCTask task, CompilerConfiguration config, File objDir, - Set set, boolean relentless, - CCTaskProgressMonitor monitor) { + Core(CCTask task, CompilerConfiguration config, File objDir, Set set, + boolean relentless, CCTaskProgressMonitor monitor) { this.task = task; this.config = config; this.objDir = objDir; @@ -923,7 +953,7 @@ public class CCTask extends Task { super.run(); try { String[] sources = new String[sourceFiles.size()]; - sources = (String[])sourceFiles.toArray(sources); + sources = (String[]) sourceFiles.toArray(sources); config.compile(task, objDir, sources, relentless, monitor); } catch (Exception ex) { if (compileException == null) { @@ -963,6 +993,7 @@ public class CCTask extends Task { System.err.print("\r" + objDir.listFiles(updatedFiles).length + " / " + rebuildCount + " files compiled..."); + System.err.print("\r"); System.err.flush(); Thread.sleep(5000); } @@ -1562,16 +1593,17 @@ public class CCTask extends Task { public void setWarnings(WarningLevelEnum level) { compilerDef.setWarnings(level); } - -// BEGINFREEHEP + + // BEGINFREEHEP public void setMaxCores(int maxCores) { - this.maxCores = maxCores; + this.maxCores = maxCores; } - + public int getMaxCores() { - return maxCores; + return maxCores; } -// ENDFREEHEP + + // ENDFREEHEP /** * Indicates whether the build will continue even if there are compilation diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java index 1281046..d0b8b95 100644 --- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java +++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCCompiler.java @@ -45,6 +45,7 @@ public final class DevStudioCCompiler extends DevStudioCompatibleCCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on safe side + return 32000; // 32767; } } diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java index 985dfcf..de006d8 100644 --- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java +++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLibrarian.java @@ -61,7 +61,8 @@ public abstract class DevStudioCompatibleLibrarian extends CommandLineLinker { return new String[0]; } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } public String[] getOutputFileSwitch(String outFile) { StringBuffer buf = new StringBuffer("/OUT:"); diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java index c21a6f6..88ecd78 100644 --- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java +++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java @@ -117,7 +117,8 @@ public abstract class DevStudioCompatibleLinker extends CommandLineLinker { return patterns; } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } public String[] getOutputFileSwitch(String outputFile) { return new String[]{"/OUT:" + outputFile}; diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java index fa2e414..effd883 100644 --- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java +++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java @@ -94,7 +94,8 @@ public final class DevStudioMIDLCompiler extends CommandLineCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } protected int getMaximumInputFilesPerCommand() { return 1; diff --git a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java index 6f8360b..3d9b83e 100644 --- a/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java +++ b/src/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java @@ -99,7 +99,8 @@ public final class DevStudioResourceCompiler extends CommandLineCompiler { return DevStudioLinker.getInstance().getLinker(type); } public int getMaximumCommandLength() { - return 32767; +// FREEHEP stay on the safe side + return 32000; // 32767; } protected int getMaximumInputFilesPerCommand() { return 1; |