Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/scripts/compiler-runner/src/org/chromium/devtools/compiler/Runner.java |
| diff --git a/third_party/WebKit/Source/devtools/scripts/compiler-runner/src/org/chromium/devtools/compiler/Runner.java b/third_party/WebKit/Source/devtools/scripts/compiler-runner/src/org/chromium/devtools/compiler/Runner.java |
| index 34db72d60fc6183790f148db5311db31298a408c..19f7c61710e7f00cfbf459a8fda28987305dd5af 100644 |
| --- a/third_party/WebKit/Source/devtools/scripts/compiler-runner/src/org/chromium/devtools/compiler/Runner.java |
| +++ b/third_party/WebKit/Source/devtools/scripts/compiler-runner/src/org/chromium/devtools/compiler/Runner.java |
| @@ -102,8 +102,23 @@ public class Runner { |
| List<CompilerInstanceDescriptor> descriptors, ExecutorService executor) { |
| List<Future<CompilerRunner>> futures = new ArrayList<>(descriptors.size()); |
| for (CompilerInstanceDescriptor descriptor : descriptors) { |
| - CompilerRunner task = new CompilerRunner(descriptor, new ByteArrayOutputStream(512)); |
| - futures.add(executor.submit(task)); |
| + try { |
| + ByteArrayOutputStream rawStream = new ByteArrayOutputStream(512); |
| + PrintStream errPrintStream = new PrintStream(rawStream, false, "UTF-8"); |
| + // We have to create instance of LocalCommandLineRunner object here, |
| + // because its constructor should be executed on one thread. |
|
lushnikov
2016/03/08 20:01:49
on a single thread
kozy
2016/03/08 20:28:55
Done.
|
| + // Constructor is parsing flags and create options object that can be used |
|
lushnikov
2016/03/08 20:01:49
creating
kozy
2016/03/08 20:28:55
Done.
|
| + // later in parallel threads during compilation. |
|
lushnikov
2016/03/08 20:01:49
-threads
kozy
2016/03/08 20:28:55
Done.
|
| + LocalCommandLineRunner runner = |
| + new LocalCommandLineRunner(descriptor.commandLine.split(" +"), |
| + System.out, errPrintStream); |
| + |
| + CompilerRunner task = new CompilerRunner(descriptor, rawStream, runner); |
| + futures.add(executor.submit(task)); |
| + } catch (Exception e) { |
| + System.err.println("ERROR - " + e.getMessage()); |
| + e.printStackTrace(System.err); |
| + } |
| } |
| for (Future<CompilerRunner> future : futures) { |
| @@ -168,25 +183,11 @@ public class Runner { |
| private static class LocalCommandLineRunner extends CommandLineRunner { |
| - private static final String EXCLUDED_EXTERNS_ES6_JS = "externs.zip//es6.js"; |
| - |
| protected LocalCommandLineRunner(String[] args, PrintStream out, PrintStream err) { |
| super(args, out, err); |
| } |
| @Override |
| - protected List<SourceFile> createExterns() throws FlagUsageException, IOException { |
| - List<SourceFile> externs = super.createExterns(); |
| - ArrayList<SourceFile> result = new ArrayList<>(externs.size()); |
| - for (SourceFile sourceFile: externs) { |
| - if (!EXCLUDED_EXTERNS_ES6_JS.equals(sourceFile.getName())) { |
| - result.add(sourceFile); |
| - } |
| - } |
| - return result; |
| - } |
| - |
| - @Override |
| protected CompilerOptions createOptions() { |
| CompilerOptions options = super.createOptions(); |
| options.setIdeMode(true); |
| @@ -220,29 +221,24 @@ public class Runner { |
| private final CompilerInstanceDescriptor descriptor; |
| private final ByteArrayOutputStream errStream; |
| private int result; |
| + private final LocalCommandLineRunner runner; |
| public CompilerRunner( |
| - CompilerInstanceDescriptor descriptor, ByteArrayOutputStream errStream) { |
| + CompilerInstanceDescriptor descriptor, ByteArrayOutputStream errStream, |
| + LocalCommandLineRunner runner) { |
| this.descriptor = descriptor; |
| this.errStream = errStream; |
| + this.runner = runner; |
| } |
| @Override |
| public CompilerRunner call() throws Exception { |
| - PrintStream errPrintStream = new PrintStream(errStream, false, "UTF-8"); |
| - LocalCommandLineRunner runner = |
| - new LocalCommandLineRunner(prepareArgs(), System.out, errPrintStream); |
| - if (!runner.shouldRunCompiler()) { |
| + if (!this.runner.shouldRunCompiler()) { |
| this.result = -1; |
| } |
| - this.result = runner.execute(); |
| + this.result = this.runner.execute(); |
| return this; |
| } |
| - |
| - private String[] prepareArgs() { |
| - // FIXME: This does not support quoted arguments. |
| - return descriptor.commandLine.split(" +"); |
| - } |
| } |
| private static class Flags { |