Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: pkg/kernel/bin/dartk.dart

Issue 2669783002: Put tree-shaking behind a flag in dartk. (Closed)
Patch Set: Make named argument TargetFlags.treeShake default to false Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/kernel/lib/target/targets.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'batch_util.dart'; 9 import 'batch_util.dart';
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 defaultsTo: false) 70 defaultsTo: false)
71 ..addOption('D', 71 ..addOption('D',
72 abbr: 'D', 72 abbr: 'D',
73 allowMultiple: true, 73 allowMultiple: true,
74 help: 'Define an environment variable.', 74 help: 'Define an environment variable.',
75 hide: true) 75 hide: true)
76 ..addFlag('show-external', 76 ..addFlag('show-external',
77 help: 'When printing a library as text, also print its dependencies\n' 77 help: 'When printing a library as text, also print its dependencies\n'
78 'on external libraries.') 78 'on external libraries.')
79 ..addFlag('show-offsets', 79 ..addFlag('show-offsets',
80 help: 'When printing a library as text, also print node offsets'); 80 help: 'When printing a library as text, also print node offsets')
81 ..addFlag('tree-shake',
82 defaultsTo: false, help: 'Enable tree-shaking if the target supports it');
81 83
82 String getUsage() => """ 84 String getUsage() => """
83 Usage: dartk [options] FILE 85 Usage: dartk [options] FILE
84 86
85 Convert .dart or .dill files to kernel's IR and print out its textual 87 Convert .dart or .dill files to kernel's IR and print out its textual
86 or binary form. 88 or binary form.
87 89
88 Examples: 90 Examples:
89 dartk foo.dart # print text IR for foo.dart 91 dartk foo.dart # print text IR for foo.dart
90 dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill 92 dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 List<String> urlMapping = options['url-mapping'] as List<String>; 283 List<String> urlMapping = options['url-mapping'] as List<String>;
282 var customUriMappings = parseCustomUriMappings(urlMapping); 284 var customUriMappings = parseCustomUriMappings(urlMapping);
283 var repository = new Repository(); 285 var repository = new Repository();
284 286
285 Program program; 287 Program program;
286 288
287 var watch = new Stopwatch()..start(); 289 var watch = new Stopwatch()..start();
288 List<String> loadedFiles; 290 List<String> loadedFiles;
289 Function getLoadedFiles; 291 Function getLoadedFiles;
290 List errors = const []; 292 List errors = const [];
291 TargetFlags targetFlags = new TargetFlags(strongMode: options['strong']); 293 TargetFlags targetFlags = new TargetFlags(
294 strongMode: options['strong'], treeShake: options['tree-shake']);
292 Target target = getTarget(options['target'], targetFlags); 295 Target target = getTarget(options['target'], targetFlags);
293 296
294 var declaredVariables = <String, String>{}; 297 var declaredVariables = <String, String>{};
295 declaredVariables.addAll(target.extraDeclaredVariables); 298 declaredVariables.addAll(target.extraDeclaredVariables);
296 for (String define in options['D']) { 299 for (String define in options['D']) {
297 int separator = define.indexOf('='); 300 int separator = define.indexOf('=');
298 if (separator == -1) { 301 if (separator == -1) {
299 fail('Invalid define: -D$define. Format is -D<name>=<value>'); 302 fail('Invalid define: -D$define. Format is -D<name>=<value>');
300 } 303 }
301 String name = define.substring(0, separator); 304 String name = define.substring(0, separator);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 print('writer.time = $time ms'); 396 print('writer.time = $time ms');
394 } 397 }
395 398
396 await ioFuture; 399 await ioFuture;
397 400
398 if (shouldReportMetrics) { 401 if (shouldReportMetrics) {
399 int flushTime = watch.elapsedMilliseconds - time; 402 int flushTime = watch.elapsedMilliseconds - time;
400 print('writer.flush_time = $flushTime ms'); 403 print('writer.flush_time = $flushTime ms');
401 } 404 }
402 405
406 if (options['tolerant']) {
407 return CompilerOutcome.Ok;
408 }
409
403 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; 410 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok;
404 } 411 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/target/targets.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698