Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 20 matching lines...) Expand all Loading... | |
| 31 import 'src/build/runner.dart'; | 31 import 'src/build/runner.dart'; |
| 32 import 'transformer.dart'; | 32 import 'transformer.dart'; |
| 33 | 33 |
| 34 main() { | 34 main() { |
| 35 var args = _parseArgs(new Options().arguments); | 35 var args = _parseArgs(new Options().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 transformOps = new TransformOptions( | 41 var options; |
| 42 directlyIncludeJS: args['js'], | 42 if (test == null) { |
| 43 contentSecurityPolicy: args['csp']); | 43 var transformOps = new TransformOptions( |
| 44 | 44 directlyIncludeJS: args['js'], |
| 45 var options = (test == null) | 45 contentSecurityPolicy: args['csp']); |
| 46 ? new BarbackOptions(createDeployPhases(transformOps), outDir) | 46 options = new BarbackOptions(createDeployPhases(transformOps), outDir); |
| 47 : _createTestOptions(transformOps, test, outDir); | 47 } else { |
| 48 options = _createTestOptions(test, outDir, args['js'], args['csp']); | |
| 49 } | |
| 48 if (options == null) exit(1); | 50 if (options == null) exit(1); |
| 49 | 51 |
| 50 print('polymer/deploy.dart: creating a deploy target for ' | 52 print('polymer/deploy.dart: creating a deploy target for ' |
| 51 '"${options.currentPackage}"'); | 53 '"${options.currentPackage}"'); |
| 52 | 54 |
| 53 runBarback(options) | 55 runBarback(options) |
| 54 .then((_) => print('Done! All files written to "$outDir"')) | 56 .then((_) => print('Done! All files written to "$outDir"')) |
| 55 .catchError(_reportErrorAndExit); | 57 .catchError(_reportErrorAndExit); |
| 56 } | 58 } |
| 57 | 59 |
| 58 createDeployPhases(options) => new PolymerTransformerGroup(options).phases; | 60 createDeployPhases(options) => new PolymerTransformerGroup(options).phases; |
| 59 | 61 |
| 60 BarbackOptions _createTestOptions(TransformOptions transformOps, | 62 BarbackOptions _createTestOptions(String testFile, String outDir, |
| 61 String testFile, String outDir) { | 63 bool directlyIncludeJS, bool contentSecurityPolicy) { |
| 62 var testDir = path.normalize(path.dirname(testFile)); | 64 var testDir = path.normalize(path.dirname(testFile)); |
| 63 | 65 |
| 64 // A test must be allowed to import things in the package. | 66 // A test must be allowed to import things in the package. |
| 65 // So we must find its package root, given the entry point. We can do this | 67 // So we must find its package root, given the entry point. We can do this |
| 66 // by walking up to find pubspec.yaml. | 68 // by walking up to find pubspec.yaml. |
| 67 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml'); | 69 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml'); |
| 68 if (pubspecDir == null) { | 70 if (pubspecDir == null) { |
| 69 print('error: pubspec.yaml file not found, please run this script from ' | 71 print('error: pubspec.yaml file not found, please run this script from ' |
| 70 'your package root directory or a subdirectory.'); | 72 'your package root directory or a subdirectory.'); |
| 71 return null; | 73 return null; |
| 72 } | 74 } |
| 73 | 75 |
| 74 transformOps.entryPoints = [path.relative(testFile, from: pubspecDir)]; | 76 var phases = createDeployPhases(new TransformOptions( |
|
Siggi Cherem (dart-lang)
2013/10/22 18:57:58
I didn't realize this yesterday, but the problem
| |
| 75 var phases = createDeployPhases(transformOps); | 77 entryPoints: [path.relative(testFile, from: pubspecDir)], |
| 78 directlyIncludeJS: directlyIncludeJS, | |
| 79 contentSecurityPolicy: contentSecurityPolicy)); | |
| 76 return new BarbackOptions(phases, outDir, | 80 return new BarbackOptions(phases, outDir, |
| 77 currentPackage: '_test', | 81 currentPackage: '_test', |
| 78 packageDirs: {'_test' : pubspecDir}, | 82 packageDirs: {'_test' : pubspecDir}, |
| 79 transformTests: true); | 83 transformTests: true); |
| 80 } | 84 } |
| 81 | 85 |
| 82 String _findDirWithFile(String dir, String filename) { | 86 String _findDirWithFile(String dir, String filename) { |
| 83 while (!new File(path.join(dir, filename)).existsSync()) { | 87 while (!new File(path.join(dir, filename)).existsSync()) { |
| 84 var parentDir = path.dirname(dir); | 88 var parentDir = path.dirname(dir); |
| 85 // If we reached root and failed to find it, bail. | 89 // If we reached root and failed to find it, bail. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 _showUsage(parser); | 128 _showUsage(parser); |
| 125 return null; | 129 return null; |
| 126 } | 130 } |
| 127 } | 131 } |
| 128 | 132 |
| 129 _showUsage(parser) { | 133 _showUsage(parser) { |
| 130 print('Usage: dart --package-root=packages/ ' | 134 print('Usage: dart --package-root=packages/ ' |
| 131 'package:polymer/deploy.dart [options]'); | 135 'package:polymer/deploy.dart [options]'); |
| 132 print(parser.getUsage()); | 136 print(parser.getUsage()); |
| 133 } | 137 } |
| OLD | NEW |