summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java
index f937b80..575ee0a 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java
@@ -120,8 +120,15 @@ public class CompileIPxeNew extends AbstractTask
return false;
}
// Compile
+ int cpus = Runtime.getRuntime().availableProcessors();
+ if (cpus < 1) {
+ cpus = 1;
+ } else if (cpus > 256) { // Sanity check in case it (apparently) reports nonsense
+ cpus = 4;
+ }
ProcLogger pl = new ProcLogger();
- if ( 0 != Exec.syncAt( 600, pl, "/opt/openslx/ipxe/src", join( "make", "EMBED=../ipxelinux.ipxe", FILES_ALL ) ) ) {
+ if ( 0 != Exec.syncAt( 600, pl, "/opt/openslx/ipxe/src", join( "nice", "make", "-j" + cpus,
+ "EMBED=../ipxelinux.ipxe", FILES_ALL ) ) ) {
status.addError( "Compiling ipxe targets failed" );
return false;
}
@@ -159,12 +166,30 @@ public class CompileIPxeNew extends AbstractTask
return true;
}
- private String[] join(String a, String b, String... rest)
+ private String[] join(Object... stuff)
{
- String[] r = new String[rest.length + 2];
- r[0] = a;
- r[1] = b;
- System.arraycopy( rest, 0, r, 2, rest.length );
+ int num = 0;
+ for ( Object o : stuff ) {
+ if ( o instanceof String[] ) {
+ num += ( (String[])o ).length;
+ } else if ( o instanceof String ) {
+ num++;
+ } else {
+ try {
+ status.addLog( "Ignoring non-String join argument '" + o + "'" );
+ } catch ( Exception e ) {} // o.toString() failed... screw it...
+ }
+ }
+ String[] r = new String[ num ];
+ num = 0;
+ for ( Object o : stuff ) {
+ if ( o instanceof String[] ) {
+ System.arraycopy( (String[])o, 0, r, num, ( (String[])o ).length );
+ num += ( (String[])o ).length;
+ } else if ( o instanceof String ) {
+ r[num++] = (String)o;
+ }
+ }
return r;
}