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

Side by Side Diff: pkg/polymer/lib/builder.dart

Issue 52753003: Fix builder.dart - avoid breaking users, print a warning instead and continue (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 run the polymer linter and deploy tool. 6 * Common logic to make it easy to run the polymer linter and deploy tool.
7 * 7 *
8 * The functions in this library are designed to make it easier to create 8 * The functions in this library are designed to make it easier to create
9 * `build.dart` files. A `build.dart` file is a Dart script that can be invoked 9 * `build.dart` files. A `build.dart` file is a Dart script that can be invoked
10 * from the command line, but that can also invoked automatically by the Dart 10 * from the command line, but that can also invoked automatically by the Dart
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 * `options.forceDeploy` is true. 107 * `options.forceDeploy` is true.
108 * 108 *
109 * The linter and deploy steps needs to know the name of the [currentPackage] 109 * The linter and deploy steps needs to know the name of the [currentPackage]
110 * and the location where to find the code for any package it depends on 110 * and the location where to find the code for any package it depends on
111 * ([packageDirs]). This is inferred automatically, but can be overriden if 111 * ([packageDirs]). This is inferred automatically, but can be overriden if
112 * those arguments are provided. 112 * those arguments are provided.
113 */ 113 */
114 Future build({List<String> entryPoints, CommandLineOptions options, 114 Future build({List<String> entryPoints, CommandLineOptions options,
115 String currentPackage, Map<String, String> packageDirs}) { 115 String currentPackage, Map<String, String> packageDirs}) {
116 if (options == null) { 116 if (options == null) {
117 // The dart:io Options class has been removed, and command-line 117 print('warning: now that main takes arguments, you need to explicitly pass'
118 // arguments are only passed to main, as main(List<String> arguments). 118 ' options to build(). Running as if no options were passed.');
119 throw new UnsupportedError( 119 options = parseOptions([]);
120 "polymer builder tools must pass options to build()");
121 } 120 }
122 return lint(entryPoints: entryPoints, options: options, 121 return lint(entryPoints: entryPoints, options: options,
123 currentPackage: currentPackage, packageDirs: packageDirs).then((res) { 122 currentPackage: currentPackage, packageDirs: packageDirs).then((res) {
124 if (options.forceDeploy) { 123 if (options.forceDeploy) {
125 return deploy(entryPoints: entryPoints, options: options, 124 return deploy(entryPoints: entryPoints, options: options,
126 currentPackage: currentPackage, packageDirs: packageDirs); 125 currentPackage: currentPackage, packageDirs: packageDirs);
127 } 126 }
128 }); 127 });
129 } 128 }
130 129
131 130
132 /** 131 /**
133 * Runs the polymer linter on any relevant file in your package, 132 * Runs the polymer linter on any relevant file in your package,
134 * such as any .html file under 'lib/', 'asset/', and 'web/'. 133 * such as any .html file under 'lib/', 'asset/', and 'web/'.
135 * 134 *
136 * The [entryPoints] list contains files under web/ that should be treated as 135 * The [entryPoints] list contains files under web/ that should be treated as
137 * entry points. Each entry on this list is a relative path from the package 136 * entry points. Each entry on this list is a relative path from the package
138 * root (for example 'web/index.html'). If null, all files under 'web/' are 137 * root (for example 'web/index.html'). If null, all files under 'web/' are
139 * treated as possible entry points. 138 * treated as possible entry points.
140 * 139 *
141 * Options must be passed by passing the [options] argument. 140 * Options must be passed by passing the [options] argument.
142 * 141 *
143 * The linter needs to know the name of the [currentPackage] and the location 142 * The linter needs to know the name of the [currentPackage] and the location
144 * where to find the code for any package it depends on ([packageDirs]). This is 143 * where to find the code for any package it depends on ([packageDirs]). This is
145 * inferred automatically, but can be overriden if those arguments are provided. 144 * inferred automatically, but can be overriden if those arguments are provided.
146 */ 145 */
147 Future lint({List<String> entryPoints, CommandLineOptions options, 146 Future lint({List<String> entryPoints, CommandLineOptions options,
148 String currentPackage, Map<String, String> packageDirs}) { 147 String currentPackage, Map<String, String> packageDirs}) {
149 if (options == null) { 148 if (options == null) {
150 // The dart:io Options class has been removed, and command-line 149 print('warning: now that main takes arguments, you need to explicitly pass'
151 // arguments are only passed to main, as main(List<String> arguments). 150 ' options to lint(). Running as if no options were passed.');
152 throw new UnsupportedError( 151 options = parseOptions([]);
153 "polymer builder tools must pass options to lint()");
154 } 152 }
155 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec(); 153 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
156 var linterOptions = new TransformOptions(entryPoints: entryPoints); 154 var linterOptions = new TransformOptions(entryPoints: entryPoints);
157 var formatter = options.machineFormat ? jsonFormatter : consoleFormatter; 155 var formatter = options.machineFormat ? jsonFormatter : consoleFormatter;
158 var linter = new Linter(linterOptions, formatter); 156 var linter = new Linter(linterOptions, formatter);
159 return runBarback(new BarbackOptions([[linter]], null, 157 return runBarback(new BarbackOptions([[linter]], null,
160 currentPackage: currentPackage, packageDirs: packageDirs)).then((assets) { 158 currentPackage: currentPackage, packageDirs: packageDirs)).then((assets) {
161 var messages = {}; 159 var messages = {};
162 var futures = []; 160 var futures = [];
163 for (var asset in assets) { 161 for (var asset in assets) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 * Options must be passed by passing the [options] list. 198 * Options must be passed by passing the [options] list.
201 * 199 *
202 * The deploy step needs to know the name of the [currentPackage] and the 200 * The deploy step needs to know the name of the [currentPackage] and the
203 * location where to find the code for any package it depends on 201 * location where to find the code for any package it depends on
204 * ([packageDirs]). This is inferred automatically, but can be overriden if 202 * ([packageDirs]). This is inferred automatically, but can be overriden if
205 * those arguments are provided. 203 * those arguments are provided.
206 */ 204 */
207 Future deploy({List<String> entryPoints, CommandLineOptions options, 205 Future deploy({List<String> entryPoints, CommandLineOptions options,
208 String currentPackage, Map<String, String> packageDirs}) { 206 String currentPackage, Map<String, String> packageDirs}) {
209 if (options == null) { 207 if (options == null) {
210 // The dart:io Options class has been removed, and command-line 208 print('warning: now that main takes arguments, you need to explicitly pass'
211 // arguments are only passed to main, as main(List<String> arguments). 209 ' options to deploy(). Running as if no options were passed.');
212 throw new UnsupportedError( 210 options = parseOptions([]);
213 "polymer builder tools must pass options to lint()");
214 } 211 }
215 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec(); 212 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
216 213
217 var transformOptions = new TransformOptions( 214 var transformOptions = new TransformOptions(
218 entryPoints: entryPoints, 215 entryPoints: entryPoints,
219 directlyIncludeJS: options.directlyIncludeJS, 216 directlyIncludeJS: options.directlyIncludeJS,
220 contentSecurityPolicy: options.contentSecurityPolicy); 217 contentSecurityPolicy: options.contentSecurityPolicy);
221 218
222 var barbackOptions = new BarbackOptions( 219 var barbackOptions = new BarbackOptions(
223 new PolymerTransformerGroup(transformOptions).phases, 220 new PolymerTransformerGroup(transformOptions).phases,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 * are available so they can be used from your `build.dart`. For instance, see 286 * are available so they can be used from your `build.dart`. For instance, see
290 * the top-level library documentation for an example that uses the force-deploy 287 * the top-level library documentation for an example that uses the force-deploy
291 * option to conditionally call [deploy]. 288 * option to conditionally call [deploy].
292 * 289 *
293 * If this documentation becomes out of date, the best way to discover which 290 * If this documentation becomes out of date, the best way to discover which
294 * flags are supported is to invoke this function from your build.dart, and run 291 * flags are supported is to invoke this function from your build.dart, and run
295 * it with the `--help` command-line flag. 292 * it with the `--help` command-line flag.
296 */ 293 */
297 CommandLineOptions parseOptions([List<String> args]) { 294 CommandLineOptions parseOptions([List<String> args]) {
298 if (args == null) { 295 if (args == null) {
299 throw new UnsupportedError( 296 print('warning: the list of arguments from main(List<String> args) now '
300 "polymer builder tools must pass options from main(List<String> args)"); 297 'needs to be passed explicitly to parseOptions.');
298 args = [];
301 } 299 }
302 var parser = new ArgParser() 300 var parser = new ArgParser()
303 ..addOption('changed', help: 'The file has changed since the last build.', 301 ..addOption('changed', help: 'The file has changed since the last build.',
304 allowMultiple: true) 302 allowMultiple: true)
305 ..addOption('removed', help: 'The file was removed since the last build.', 303 ..addOption('removed', help: 'The file was removed since the last build.',
306 allowMultiple: true) 304 allowMultiple: true)
307 ..addFlag('clean', negatable: false, 305 ..addFlag('clean', negatable: false,
308 help: 'Remove any build artifacts (if any).') 306 help: 'Remove any build artifacts (if any).')
309 ..addFlag('full', negatable: false, help: 'perform a full build') 307 ..addFlag('full', negatable: false, help: 'perform a full build')
310 ..addFlag('machine', negatable: false, 308 ..addFlag('machine', negatable: false,
(...skipping 28 matching lines...) Expand all
339 } 337 }
340 if (res['help']) { 338 if (res['help']) {
341 print('A build script that invokes the polymer linter and deploy tools.'); 339 print('A build script that invokes the polymer linter and deploy tools.');
342 showUsage(); 340 showUsage();
343 exit(0); 341 exit(0);
344 } 342 }
345 return new CommandLineOptions(res['changed'], res['removed'], res['clean'], 343 return new CommandLineOptions(res['changed'], res['removed'], res['clean'],
346 res['full'], res['machine'], res['deploy'], res['out'], res['js'], 344 res['full'], res['machine'], res['deploy'], res['out'], res['js'],
347 res['csp']); 345 res['csp']);
348 } 346 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698