diff --git a/src/SplitJob.class b/src/SplitJob.class new file mode 100644 index 0000000..10c467d Binary files /dev/null and b/src/SplitJob.class differ diff --git a/src/SplitJob.java b/src/SplitJob.java new file mode 100644 index 0000000..8498be6 --- /dev/null +++ b/src/SplitJob.java @@ -0,0 +1,54 @@ + +import java.io.*; + +import static java.lang.ProcessBuilder.Redirect; + +public class SplitJob { + + private static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + + + public static void main(String[] args) { + + final Runtime runtime = Runtime.getRuntime(); + int numThreads = runtime.availableProcessors(); + Process[] procs = new Process[numThreads]; + + try { + + ProcessBuilder builder = new ProcessBuilder(args); + builder.redirectError(Redirect.INHERIT); + + for (int i = 0; i < numThreads; i++) { + procs[i] = builder.start(); + } + + for (int i = 0; ; i = (i + 1) % numThreads) { + + String s = in.readLine(); + + if (s == null) + break; + + byte[] data = (s + '\n').getBytes(); + procs[i].getOutputStream().write(data, 0, data.length); + procs[i].getOutputStream().flush(); + } + + for (Process proc : procs) { + + proc.getOutputStream().close(); + int exitCode = proc.waitFor(); + + if (exitCode != 0) { + System.err.printf("[Error] %s stopped with exit code: %d\n", args[0], exitCode); + System.exit(2); + } + } + + } catch (Exception e) { + System.err.printf("[Error] %s: %s\n", e.getClass().getName(), e.getMessage()); + System.exit(1); + } + } +} diff --git a/src/render_icons.sh b/src/render_icons.sh index 3864c08..29a6fe2 100755 --- a/src/render_icons.sh +++ b/src/render_icons.sh @@ -68,13 +68,12 @@ do # since we finished rendering it out last. if [[ $CONTEXT.svg -nt .${CONTEXT}_timestamp ]] then - genInkscapeCmds $CONTEXT | $INKSCAPE --shell > /dev/null && touch .${CONTEXT}_timestamp & + echo "Rendering icons from $CONTEXT.svg" + genInkscapeCmds $CONTEXT | java SplitJob $INKSCAPE --shell && touch .${CONTEXT}_timestamp else echo "No changes to $CONTEXT.svg, skipping..." fi done -wait - # Remove all empty directories from the theme folder. find $THEMEDIR -type d -empty -delete