OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
10 show | 10 show |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 last = completer.future; | 95 last = completer.future; |
96 } | 96 } |
97 | 97 |
98 // Build modules asynchronously | 98 // Build modules asynchronously |
99 var tmpdir = (tmp == null) | 99 var tmpdir = (tmp == null) |
100 ? Directory.systemTemp | 100 ? Directory.systemTemp |
101 .createTempSync(outfile.replaceAll(path.separator, '__')) | 101 .createTempSync(outfile.replaceAll(path.separator, '__')) |
102 : new Directory(tmp)..createSync(); | 102 : new Directory(tmp)..createSync(); |
103 for (var module in orderedModules) { | 103 for (var module in orderedModules) { |
104 var file = tmpdir.path + path.separator + module + '.js'; | 104 var file = tmpdir.path + path.separator + module + '.js'; |
105 var command = new List.from(template)..addAll(['-o', file]); | 105 var command = template.toList()..addAll(['-o', file]); |
106 var dependences = transitiveDependenceMap[module]; | 106 var dependences = transitiveDependenceMap[module]; |
107 for (var dependence in dependences) { | 107 for (var dependence in dependences) { |
108 var summary = tmpdir.path + path.separator + dependence + '.sum'; | 108 var summary = tmpdir.path + path.separator + dependence + '.sum'; |
109 command.addAll(['-s', summary]); | 109 command.addAll(['-s', summary]); |
110 } | 110 } |
111 var infiles = fileMap[module]; | 111 var infiles = fileMap[module]; |
112 command.addAll(infiles); | 112 command.addAll(infiles); |
113 | 113 |
114 var immediateDeps = | 114 var waitList = dependenceMap.containsKey(module) |
115 dependenceMap.containsKey(module) ? dependenceMap[module] : <String>[]; | 115 ? dependenceMap[module].map((dep) => readyMap[dep]) |
116 var waitList = immediateDeps.map((dep) => readyMap[dep]); | 116 : <Future>[]; |
117 var future = Future.wait(waitList); | 117 var future = Future.wait(waitList); |
118 readyMap[module] = future.then((_) { | 118 readyMap[module] = future.then((_) { |
119 var ready = Process.run(dartPath, command); | 119 var ready = Process.run(dartPath, command); |
120 if (log) { | 120 if (log) { |
121 print(command.join(' ')); | 121 print(command.join(' ')); |
122 } | 122 } |
123 return ready.then((result) { | 123 return ready.then((result) { |
124 if (result.exitCode != 0) { | 124 if (result.exitCode != 0) { |
125 print('ERROR: compiling $module'); | 125 print('ERROR: compiling $module'); |
126 print(result.stdout); | 126 print(result.stdout); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 var uri = _resolveDirective(d); | 272 var uri = _resolveDirective(d); |
273 processDependence(entryPoint, canonicalize(uri, entryDir)); | 273 processDependence(entryPoint, canonicalize(uri, entryDir)); |
274 transitiveFiles(uri, entryDir, packageRoot); | 274 transitiveFiles(uri, entryDir, packageRoot); |
275 } else if (d is PartDirective) { | 275 } else if (d is PartDirective) { |
276 var uri = _resolveDirective(d); | 276 var uri = _resolveDirective(d); |
277 processFile(canonicalize(uri, entryDir)); | 277 processFile(canonicalize(uri, entryDir)); |
278 } | 278 } |
279 } | 279 } |
280 } | 280 } |
281 } | 281 } |
OLD | NEW |