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

Side by Side Diff: lib/component_build.dart

Issue 11450020: (Fix #215) better error printing in editor & extension, adds mapping for editor (Closed) Base URL: git@github.com:dart-lang/dart-web-components.git@master
Patch Set: Created 8 years 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Common logic to make it easy to create a `build.dart` for your project. 6 * Common logic to make it easy to create a `build.dart` for your project.
7 * 7 *
8 * The `build.dart` script is invoked automatically by the Editor whenever a 8 * The `build.dart` script is invoked automatically by the Editor whenever a
9 * file in the project changes. It must be placed in the root of a project 9 * file in the project changes. It must be placed in the root of a project
10 * (where pubspec.yaml lives) and should be named exactly 'build.dart'. 10 * (where pubspec.yaml lives) and should be named exactly 'build.dart'.
(...skipping 19 matching lines...) Expand all
30 * live will be scanned for generated files to delete them. 30 * live will be scanned for generated files to delete them.
31 */ 31 */
32 // TODO(jmesserly): we need a better way to automatically detect input files 32 // TODO(jmesserly): we need a better way to automatically detect input files
33 void build(List<String> arguments, List<String> entryPoints) { 33 void build(List<String> arguments, List<String> entryPoints) {
34 var args = _processArgs(arguments); 34 var args = _processArgs(arguments);
35 35
36 var trackDirs = <Directory>[]; 36 var trackDirs = <Directory>[];
37 var changedFiles = args["changed"]; 37 var changedFiles = args["changed"];
38 var removedFiles = args["removed"]; 38 var removedFiles = args["removed"];
39 var cleanBuild = args["clean"]; 39 var cleanBuild = args["clean"];
40 var machineFormat = args["machine"];
40 var fullBuild = changedFiles.isEmpty && removedFiles.isEmpty && !cleanBuild; 41 var fullBuild = changedFiles.isEmpty && removedFiles.isEmpty && !cleanBuild;
41 42
42 for (var file in entryPoints) { 43 for (var file in entryPoints) {
43 trackDirs.add(new Directory(_outDir(file))); 44 trackDirs.add(new Directory(_outDir(file)));
44 } 45 }
45 46
46 if (cleanBuild) { 47 if (cleanBuild) {
47 _handleCleanCommand(trackDirs); 48 _handleCleanCommand(trackDirs);
48 } else if (fullBuild || changedFiles.some((f) => _isInputFile(f, trackDirs)) 49 } else if (fullBuild || changedFiles.some((f) => _isInputFile(f, trackDirs))
49 || removedFiles.some((f) => _isInputFile(f, trackDirs))) { 50 || removedFiles.some((f) => _isInputFile(f, trackDirs))) {
50 // TODO(sigmund): allow colors if we find a way to detect reliably where
51 // colors are supported (e.g. we are not running in the editor or in
52 // windows)
53 for (var file in entryPoints) { 51 for (var file in entryPoints) {
54 dwc.run(['--no-colors', '-o', _outDir(file), file]); 52 var path = new Path(file);
53 var outDir = path.directoryPath.append('out');
54 var args = [];
55 if (machineFormat) args.add('--json_format');
56 if (Platform.operatingSystem == 'windows') args.add('--no-colors');
57 args.addAll(['-o', outDir.toString(), file]);
58 dwc.run(args);
59
60 if (machineFormat) {
61 // Print for the Dart Editor the mapping from the input entry point file
62 // and its corresponding output.
63 var out = outDir.append(path.filename);
64 print('[{"method":"mapping","params":{"from":"$file","to":"$out"}}]');
65 }
55 } 66 }
56 } 67 }
57 } 68 }
58 69
59 String _outDir(String file) => 70 String _outDir(String file) =>
60 new Path(file).directoryPath.append('out').toString(); 71 new Path(file).directoryPath.append('out').toString();
61 72
62 bool _isGeneratedFile(String filePath, List<Directory> outputDirs) { 73 bool _isGeneratedFile(String filePath, List<Directory> outputDirs) {
63 var path = new Path.fromNative(filePath); 74 var path = new Path.fromNative(filePath);
64 for (var dir in outputDirs) { 75 for (var dir in outputDirs) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ..addFlag("machine", negatable: false, 112 ..addFlag("machine", negatable: false,
102 help: "produce warnings in a machine parseable format") 113 help: "produce warnings in a machine parseable format")
103 ..addFlag("help", negatable: false, help: "displays this help and exit"); 114 ..addFlag("help", negatable: false, help: "displays this help and exit");
104 var args = parser.parse(arguments); 115 var args = parser.parse(arguments);
105 if (args["help"]) { 116 if (args["help"]) {
106 print(parser.getUsage()); 117 print(parser.getUsage());
107 exit(0); 118 exit(0);
108 } 119 }
109 return args; 120 return args;
110 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698