| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 void main(List<String> args) { | 22 void main(List<String> args) { |
| 23 // Parse flags. | 23 // Parse flags. |
| 24 var parser = new ArgParser() | 24 var parser = new ArgParser() |
| 25 ..addOption('out', | 25 ..addOption('out', |
| 26 help: 'Output file (defaults to "out.js")', | 26 help: 'Output file (defaults to "out.js")', |
| 27 abbr: 'o', | 27 abbr: 'o', |
| 28 defaultsTo: 'out.js') | 28 defaultsTo: 'out.js') |
| 29 ..addFlag('unsafe-force-compile', | 29 ..addFlag('unsafe-force-compile', |
| 30 help: 'Generate code with undefined behavior', negatable: false) | 30 help: 'Generate code with undefined behavior', negatable: false) |
| 31 ..addOption('packages', |
| 32 help: |
| 33 'Path to the package resolution configuration file, which supplies ' |
| 34 'a mapping of package names to paths. This option cannot be ' |
| 35 'used with --package-root.') |
| 31 ..addOption('package-root', | 36 ..addOption('package-root', |
| 32 help: 'Directory containing packages', | |
| 33 abbr: 'p', | 37 abbr: 'p', |
| 34 defaultsTo: 'packages/') | 38 help: 'Path to a package root directory (deprecated). This option ' |
| 39 'cannot be used with --packages.') |
| 35 ..addFlag('log', help: 'Show individual build commands') | 40 ..addFlag('log', help: 'Show individual build commands') |
| 36 ..addOption('tmp', | 41 ..addOption('tmp', |
| 37 help: | 42 help: |
| 38 'Directory for temporary artifacts (defaults to a system tmp directo
ry)'); | 43 'Directory for temporary artifacts (defaults to a system tmp directo
ry)'); |
| 39 | 44 |
| 40 var options = parser.parse(args); | 45 var options = parser.parse(args); |
| 41 if (options.rest.length != 1) { | 46 if (options.rest.length != 1) { |
| 42 throw 'Expected a single dart entrypoint.'; | 47 throw 'Expected a single dart entrypoint.'; |
| 43 } | 48 } |
| 44 var entry = options.rest.first; | 49 var entry = options.rest.first; |
| 45 var outfile = options['out'] as String; | 50 var outfile = options['out'] as String; |
| 51 var packages = options['packages'] as String; |
| 46 var packageRoot = options['package-root'] as String; | 52 var packageRoot = options['package-root'] as String; |
| 47 var unsafe = options['unsafe-force-compile'] as bool; | 53 var unsafe = options['unsafe-force-compile'] as bool; |
| 48 var log = options['log'] as bool; | 54 var log = options['log'] as bool; |
| 49 var tmp = options['tmp'] as String; | 55 var tmp = options['tmp'] as String; |
| 50 | 56 |
| 51 // Build an invocation to dartdevc | 57 // Build an invocation to dartdevc |
| 52 var dartPath = Platform.resolvedExecutable; | 58 var dartPath = Platform.resolvedExecutable; |
| 53 var ddcPath = path.dirname(path.dirname(Platform.script.toFilePath())); | 59 var ddcPath = path.dirname(path.dirname(Platform.script.toFilePath())); |
| 54 var template = [ | 60 var template = [ |
| 55 '$ddcPath/bin/dartdevc.dart', | 61 '$ddcPath/bin/dartdevc.dart', |
| 56 'compile', | 62 'compile', |
| 57 '--no-source-map', // Invalid as we're just concatenating files below | 63 '--no-source-map', // Invalid as we're just concatenating files below |
| 58 '-p', | |
| 59 packageRoot | |
| 60 ]; | 64 ]; |
| 65 if (packages != null) { |
| 66 template.addAll(['--packages', packages]); |
| 67 } |
| 68 if (packageRoot != null) { |
| 69 template.addAll(['--package-root', packageRoot]); |
| 70 } |
| 61 if (unsafe) { | 71 if (unsafe) { |
| 62 template.add('--unsafe-force-compile'); | 72 template.add('--unsafe-force-compile'); |
| 63 } | 73 } |
| 64 | 74 |
| 65 // Compute the transitive closure | 75 // Compute the transitive closure |
| 66 var total = new Stopwatch()..start(); | 76 var total = new Stopwatch()..start(); |
| 67 var partial = new Stopwatch()..start(); | 77 var partial = new Stopwatch()..start(); |
| 68 | 78 |
| 69 // TODO(vsm): We're using the analyzer just to compute the import/export/part | 79 // TODO(vsm): We're using the analyzer just to compute the import/export/part |
| 70 // dependence graph. This is expensive. Is there a lighterweight way to do | 80 // dependence graph. This is expensive. Is there a lighterweight way to do |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 var uri = _resolveDirective(d); | 282 var uri = _resolveDirective(d); |
| 273 processDependence(entryPoint, canonicalize(uri, entryDir)); | 283 processDependence(entryPoint, canonicalize(uri, entryDir)); |
| 274 transitiveFiles(uri, entryDir, packageRoot); | 284 transitiveFiles(uri, entryDir, packageRoot); |
| 275 } else if (d is PartDirective) { | 285 } else if (d is PartDirective) { |
| 276 var uri = _resolveDirective(d); | 286 var uri = _resolveDirective(d); |
| 277 processFile(canonicalize(uri, entryDir)); | 287 processFile(canonicalize(uri, entryDir)); |
| 278 } | 288 } |
| 279 } | 289 } |
| 280 } | 290 } |
| 281 } | 291 } |
| OLD | NEW |