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

Side by Side Diff: pkg/polymer/lib/deploy.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 | « pkg/polymer/lib/builder.dart ('k') | pkg/polymer/lib/src/build/build_filter.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 * **Note**: If you already have a `build.dart` in your application, we 6 * **Note**: If you already have a `build.dart` in your application, we
7 * recommend to use the `package:polymer/builder.dart` library instead. 7 * recommend to use the `package:polymer/builder.dart` library instead.
8 8
9 * Temporary deploy command used to create a version of the app that can be 9 * Temporary deploy command used to create a version of the app that can be
10 * compiled with dart2js and deployed. Following pub layout conventions, this 10 * compiled with dart2js and deployed. Following pub layout conventions, this
(...skipping 24 matching lines...) Expand all
35 var args = _parseArgs(arguments); 35 var args = _parseArgs(arguments);
36 if (args == null) exit(1); 36 if (args == null) exit(1);
37 37
38 var test = args['test']; 38 var test = args['test'];
39 var outDir = args['out']; 39 var outDir = args['out'];
40 40
41 var options; 41 var options;
42 if (test == null) { 42 if (test == null) {
43 var transformOps = new TransformOptions( 43 var transformOps = new TransformOptions(
44 directlyIncludeJS: args['js'], 44 directlyIncludeJS: args['js'],
45 contentSecurityPolicy: args['csp']); 45 contentSecurityPolicy: args['csp'],
46 releaseMode: !args['debug']);
46 options = new BarbackOptions(createDeployPhases(transformOps), outDir); 47 options = new BarbackOptions(createDeployPhases(transformOps), outDir);
47 } else { 48 } else {
48 options = _createTestOptions(test, outDir, args['js'], args['csp']); 49 options = _createTestOptions(
50 test, outDir, args['js'], args['csp'], !args['debug']);
49 } 51 }
50 if (options == null) exit(1); 52 if (options == null) exit(1);
51 53
52 print('polymer/deploy.dart: creating a deploy target for ' 54 print('polymer/deploy.dart: creating a deploy target for '
53 '"${options.currentPackage}"'); 55 '"${options.currentPackage}"');
54 56
55 runBarback(options) 57 runBarback(options)
56 .then((_) => print('Done! All files written to "$outDir"')) 58 .then((_) => print('Done! All files written to "$outDir"'))
57 .catchError(_reportErrorAndExit); 59 .catchError(_reportErrorAndExit);
58 } 60 }
59 61
60 createDeployPhases(options) => new PolymerTransformerGroup(options).phases; 62 createDeployPhases(options) => new PolymerTransformerGroup(options).phases;
61 63
62 BarbackOptions _createTestOptions(String testFile, String outDir, 64 BarbackOptions _createTestOptions(String testFile, String outDir,
63 bool directlyIncludeJS, bool contentSecurityPolicy) { 65 bool directlyIncludeJS, bool contentSecurityPolicy, bool releaseMode) {
64 var testDir = path.normalize(path.dirname(testFile)); 66 var testDir = path.normalize(path.dirname(testFile));
65 67
66 // A test must be allowed to import things in the package. 68 // A test must be allowed to import things in the package.
67 // So we must find its package root, given the entry point. We can do this 69 // So we must find its package root, given the entry point. We can do this
68 // by walking up to find pubspec.yaml. 70 // by walking up to find pubspec.yaml.
69 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml'); 71 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml');
70 if (pubspecDir == null) { 72 if (pubspecDir == null) {
71 print('error: pubspec.yaml file not found, please run this script from ' 73 print('error: pubspec.yaml file not found, please run this script from '
72 'your package root directory or a subdirectory.'); 74 'your package root directory or a subdirectory.');
73 return null; 75 return null;
74 } 76 }
75 var packageName = readCurrentPackageFromPubspec(pubspecDir); 77 var packageName = readCurrentPackageFromPubspec(pubspecDir);
76 78
77 var phases = createDeployPhases(new TransformOptions( 79 var phases = createDeployPhases(new TransformOptions(
78 entryPoints: [path.relative(testFile, from: pubspecDir)], 80 entryPoints: [path.relative(testFile, from: pubspecDir)],
79 directlyIncludeJS: directlyIncludeJS, 81 directlyIncludeJS: directlyIncludeJS,
80 contentSecurityPolicy: contentSecurityPolicy)); 82 contentSecurityPolicy: contentSecurityPolicy,
83 releaseMode: releaseMode));
81 return new BarbackOptions(phases, outDir, 84 return new BarbackOptions(phases, outDir,
82 currentPackage: packageName, 85 currentPackage: packageName,
83 packageDirs: {packageName : pubspecDir}, 86 packageDirs: {packageName : pubspecDir},
84 transformTests: true); 87 transformTests: true);
85 } 88 }
86 89
87 String _findDirWithFile(String dir, String filename) { 90 String _findDirWithFile(String dir, String filename) {
88 while (!new File(path.join(dir, filename)).existsSync()) { 91 while (!new File(path.join(dir, filename)).existsSync()) {
89 var parentDir = path.dirname(dir); 92 var parentDir = path.dirname(dir);
90 // If we reached root and failed to find it, bail. 93 // If we reached root and failed to find it, bail.
(...skipping 15 matching lines...) Expand all
106 defaultsTo: false, negatable: false) 109 defaultsTo: false, negatable: false)
107 ..addOption('out', abbr: 'o', help: 'Directory to generate files into.', 110 ..addOption('out', abbr: 'o', help: 'Directory to generate files into.',
108 defaultsTo: 'out') 111 defaultsTo: 'out')
109 ..addOption('test', help: 'Deploy the test at the given path.\n' 112 ..addOption('test', help: 'Deploy the test at the given path.\n'
110 'Note: currently this will deploy all tests in its directory,\n' 113 'Note: currently this will deploy all tests in its directory,\n'
111 'but it will eventually deploy only the specified test.') 114 'but it will eventually deploy only the specified test.')
112 ..addFlag('js', help: 115 ..addFlag('js', help:
113 'deploy replaces *.dart scripts with *.dart.js. This flag \n' 116 'deploy replaces *.dart scripts with *.dart.js. This flag \n'
114 'leaves "packages/browser/dart.js" to do the replacement at runtime.', 117 'leaves "packages/browser/dart.js" to do the replacement at runtime.',
115 defaultsTo: true) 118 defaultsTo: true)
119 ..addFlag('debug', help:
120 'run in debug mode. For example, use the debug versions of the \n'
121 'polyfills (shadow_dom.debug.js and custom-elements.debug.js) \n'
122 'instead of the minified versions.',
123 defaultsTo: false)
116 ..addFlag('csp', help: 124 ..addFlag('csp', help:
117 'replaces *.dart with *.dart.precompiled.js to comply with \n' 125 'replaces *.dart with *.dart.precompiled.js to comply with \n'
118 'Content Security Policy restrictions.'); 126 'Content Security Policy restrictions.');
119 try { 127 try {
120 var results = parser.parse(arguments); 128 var results = parser.parse(arguments);
121 if (results['help']) { 129 if (results['help']) {
122 _showUsage(parser); 130 _showUsage(parser);
123 return null; 131 return null;
124 } 132 }
125 return results; 133 return results;
126 } on FormatException catch (e) { 134 } on FormatException catch (e) {
127 print(e.message); 135 print(e.message);
128 _showUsage(parser); 136 _showUsage(parser);
129 return null; 137 return null;
130 } 138 }
131 } 139 }
132 140
133 _showUsage(parser) { 141 _showUsage(parser) {
134 print('Usage: dart --package-root=packages/ ' 142 print('Usage: dart --package-root=packages/ '
135 'package:polymer/deploy.dart [options]'); 143 'package:polymer/deploy.dart [options]');
136 print(parser.getUsage()); 144 print(parser.getUsage());
137 } 145 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/builder.dart ('k') | pkg/polymer/lib/src/build/build_filter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698