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

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

Issue 61193002: Add a build filter (only necessary HTML files are emitted) and logic to use .min.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase 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 | pkg/polymer/lib/deploy.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 // 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if (options == null) { 207 if (options == null) {
208 print('warning: now that main takes arguments, you need to explicitly pass' 208 print('warning: now that main takes arguments, you need to explicitly pass'
209 ' options to deploy(). Running as if no options were passed.'); 209 ' options to deploy(). Running as if no options were passed.');
210 options = parseOptions([]); 210 options = parseOptions([]);
211 } 211 }
212 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec(); 212 if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
213 213
214 var transformOptions = new TransformOptions( 214 var transformOptions = new TransformOptions(
215 entryPoints: entryPoints, 215 entryPoints: entryPoints,
216 directlyIncludeJS: options.directlyIncludeJS, 216 directlyIncludeJS: options.directlyIncludeJS,
217 contentSecurityPolicy: options.contentSecurityPolicy); 217 contentSecurityPolicy: options.contentSecurityPolicy,
218 releaseMode: options.releaseMode);
218 219
219 var barbackOptions = new BarbackOptions( 220 var barbackOptions = new BarbackOptions(
220 new PolymerTransformerGroup(transformOptions).phases, 221 new PolymerTransformerGroup(transformOptions).phases,
221 options.outDir, currentPackage: currentPackage, 222 options.outDir, currentPackage: currentPackage,
222 packageDirs: packageDirs); 223 packageDirs: packageDirs);
223 return runBarback(barbackOptions) 224 return runBarback(barbackOptions)
224 .then((_) => print('Done! All files written to "${options.outDir}"')); 225 .then((_) => print('Done! All files written to "${options.outDir}"'));
225 } 226 }
226 227
227 228
(...skipping 25 matching lines...) Expand all
253 254
254 /** True to use the CSP-compliant JS file. */ 255 /** True to use the CSP-compliant JS file. */
255 final bool contentSecurityPolicy; 256 final bool contentSecurityPolicy;
256 257
257 /** 258 /**
258 * True to include the JS script tag directly, without the 259 * True to include the JS script tag directly, without the
259 * "packages/browser/dart.js" trampoline. 260 * "packages/browser/dart.js" trampoline.
260 */ 261 */
261 final bool directlyIncludeJS; 262 final bool directlyIncludeJS;
262 263
264 /**
265 * Run transformers in release mode. For instance, uses the minified versions
266 * of shadow_dom and custom-elements polyfills.
267 */
268 final bool releaseMode;
269
263 CommandLineOptions(this.changedFiles, this.removedFiles, this.clean, 270 CommandLineOptions(this.changedFiles, this.removedFiles, this.clean,
264 this.full, this.machineFormat, this.forceDeploy, this.outDir, 271 this.full, this.machineFormat, this.forceDeploy, this.outDir,
265 this.directlyIncludeJS, this.contentSecurityPolicy); 272 this.directlyIncludeJS, this.contentSecurityPolicy,
273 this.releaseMode);
266 } 274 }
267 275
268 /** 276 /**
269 * Parse command-line arguments and return a [CommandLineOptions] object. The 277 * Parse command-line arguments and return a [CommandLineOptions] object. The
270 * following flags are parsed by this method. 278 * following flags are parsed by this method.
271 * 279 *
272 * * `--changed file-path`: notify of a file change. 280 * * `--changed file-path`: notify of a file change.
273 * * `--removed file-path`: notify that a file was removed. 281 * * `--removed file-path`: notify that a file was removed.
274 * * `--clean`: remove temporary artifacts (if any) 282 * * `--clean`: remove temporary artifacts (if any)
275 * * `--full`: build everything, similar to marking every file as changed 283 * * `--full`: build everything, similar to marking every file as changed
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 help: 'Whether to force deploying.') 319 help: 'Whether to force deploying.')
312 ..addOption('out', abbr: 'o', help: 'Directory to generate files into.', 320 ..addOption('out', abbr: 'o', help: 'Directory to generate files into.',
313 defaultsTo: 'out') 321 defaultsTo: 'out')
314 ..addFlag('js', help: 322 ..addFlag('js', help:
315 'deploy replaces *.dart scripts with *.dart.js. This flag \n' 323 'deploy replaces *.dart scripts with *.dart.js. This flag \n'
316 'leaves "packages/browser/dart.js" to do the replacement at runtime.', 324 'leaves "packages/browser/dart.js" to do the replacement at runtime.',
317 defaultsTo: true) 325 defaultsTo: true)
318 ..addFlag('csp', help: 326 ..addFlag('csp', help:
319 'replaces *.dart with *.dart.precompiled.js to comply with \n' 327 'replaces *.dart with *.dart.precompiled.js to comply with \n'
320 'Content Security Policy restrictions.') 328 'Content Security Policy restrictions.')
329 ..addFlag('debug', help:
330 'run in debug mode. For example, use the debug versions of the \n'
331 'polyfills (shadow_dom.debug.js and custom-elements.debug.js) \n'
332 'instead of the minified versions.',
333 defaultsTo: false)
321 ..addFlag('help', abbr: 'h', 334 ..addFlag('help', abbr: 'h',
322 negatable: false, help: 'Displays this help and exit.'); 335 negatable: false, help: 'Displays this help and exit.');
323 336
324 showUsage() { 337 showUsage() {
325 print('Usage: dart build.dart [options]'); 338 print('Usage: dart build.dart [options]');
326 print('\nThese are valid options expected by build.dart:'); 339 print('\nThese are valid options expected by build.dart:');
327 print(parser.getUsage()); 340 print(parser.getUsage());
328 } 341 }
329 342
330 var res; 343 var res;
331 try { 344 try {
332 res = parser.parse(args); 345 res = parser.parse(args);
333 } on FormatException catch (e) { 346 } on FormatException catch (e) {
334 print(e.message); 347 print(e.message);
335 showUsage(); 348 showUsage();
336 exit(1); 349 exit(1);
337 } 350 }
338 if (res['help']) { 351 if (res['help']) {
339 print('A build script that invokes the polymer linter and deploy tools.'); 352 print('A build script that invokes the polymer linter and deploy tools.');
340 showUsage(); 353 showUsage();
341 exit(0); 354 exit(0);
342 } 355 }
343 return new CommandLineOptions(res['changed'], res['removed'], res['clean'], 356 return new CommandLineOptions(res['changed'], res['removed'], res['clean'],
344 res['full'], res['machine'], res['deploy'], res['out'], res['js'], 357 res['full'], res['machine'], res['deploy'], res['out'], res['js'],
345 res['csp']); 358 res['csp'], !res['debug']);
346 } 359 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/deploy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698