diff options
author | Simon Rettberg | 2019-04-16 14:45:42 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-04-16 14:45:42 +0200 |
commit | f3aeb4688168e1ec6bebd88b6e9a1b8e8746f4ef (patch) | |
tree | e4f32a296463db56dfe41ba2930b8cc935f9e448 | |
parent | [CreateLdapConfig] Pass through nohomewarn as SHARE_NO_HOME_WARN (diff) | |
download | tmlite-bwlp-f3aeb4688168e1ec6bebd88b6e9a1b8e8746f4ef.tar.gz tmlite-bwlp-f3aeb4688168e1ec6bebd88b6e9a1b8e8746f4ef.tar.xz tmlite-bwlp-f3aeb4688168e1ec6bebd88b6e9a1b8e8746f4ef.zip |
[CompileIPxeNew] 'nice' make, use all cores (-jN)
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java | 37 |
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; } |