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 27 matching lines...) Expand all Loading... |
38 var outDir = args['out']; | 38 var outDir = args['out']; |
39 | 39 |
40 var options; | 40 var options; |
41 if (test == null) { | 41 if (test == null) { |
42 var transformOps = new TransformOptions( | 42 var transformOps = new TransformOptions( |
43 directlyIncludeJS: args['js'], | 43 directlyIncludeJS: args['js'], |
44 contentSecurityPolicy: args['csp'], | 44 contentSecurityPolicy: args['csp'], |
45 releaseMode: !args['debug']); | 45 releaseMode: !args['debug']); |
46 var phases = createDeployPhases(transformOps); | 46 var phases = createDeployPhases(transformOps); |
47 options = new BarbackOptions(phases, outDir, | 47 options = new BarbackOptions(phases, outDir, |
| 48 // TODO(sigmund): include here also smoke transformer when it's on by |
| 49 // default. |
48 packagePhases: {'polymer': phasesForPolymer}); | 50 packagePhases: {'polymer': phasesForPolymer}); |
49 } else { | 51 } else { |
50 options = _createTestOptions( | 52 options = _createTestOptions( |
51 test, outDir, args['js'], args['csp'], !args['debug']); | 53 test, outDir, args['js'], args['csp'], !args['debug']); |
52 } | 54 } |
53 if (options == null) exit(1); | 55 if (options == null) exit(1); |
54 | 56 |
55 print('polymer/deploy.dart: creating a deploy target for ' | 57 print('polymer/deploy.dart: creating a deploy target for ' |
56 '"${options.currentPackage}"'); | 58 '"${options.currentPackage}"'); |
57 | 59 |
(...skipping 12 matching lines...) Expand all Loading... |
70 // So we must find its package root, given the entry point. We can do this | 72 // So we must find its package root, given the entry point. We can do this |
71 // by walking up to find pubspec.yaml. | 73 // by walking up to find pubspec.yaml. |
72 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml'); | 74 var pubspecDir = _findDirWithFile(path.absolute(testDir), 'pubspec.yaml'); |
73 if (pubspecDir == null) { | 75 if (pubspecDir == null) { |
74 print('error: pubspec.yaml file not found, please run this script from ' | 76 print('error: pubspec.yaml file not found, please run this script from ' |
75 'your package root directory or a subdirectory.'); | 77 'your package root directory or a subdirectory.'); |
76 return null; | 78 return null; |
77 } | 79 } |
78 var packageName = readCurrentPackageFromPubspec(pubspecDir); | 80 var packageName = readCurrentPackageFromPubspec(pubspecDir); |
79 | 81 |
| 82 // Find the dart-root so we can include both polymer and smoke as additional |
| 83 // packages whose transformers we need to run. |
| 84 var pkgDir = path.join(_findDirWithDir(path.absolute(testDir), 'pkg'), 'pkg'); |
| 85 |
80 var phases = createDeployPhases(new TransformOptions( | 86 var phases = createDeployPhases(new TransformOptions( |
81 entryPoints: [path.relative(testFile, from: pubspecDir)], | 87 entryPoints: [path.relative(testFile, from: pubspecDir)], |
82 directlyIncludeJS: directlyIncludeJS, | 88 directlyIncludeJS: directlyIncludeJS, |
83 contentSecurityPolicy: contentSecurityPolicy, | 89 contentSecurityPolicy: contentSecurityPolicy, |
84 releaseMode: releaseMode)); | 90 releaseMode: releaseMode)); |
85 return new BarbackOptions(phases, outDir, | 91 return new BarbackOptions(phases, outDir, |
86 currentPackage: packageName, | 92 currentPackage: packageName, |
87 packageDirs: {packageName : pubspecDir}, | 93 packageDirs: { |
| 94 'polymer': path.join(pkgDir, 'polymer'), |
| 95 'smoke': path.join(pkgDir, 'smoke'), |
| 96 // packageName may be a duplicate of 'polymer', but that's ok, the |
| 97 // following will be the value used in the map (they should also be the |
| 98 // same value). |
| 99 packageName: pubspecDir, |
| 100 }, |
| 101 // TODO(sigmund): include here also smoke transformer when it's on by |
| 102 // default. |
88 packagePhases: {'polymer': phasesForPolymer}, | 103 packagePhases: {'polymer': phasesForPolymer}, |
89 transformTests: true); | 104 transformTests: true); |
90 } | 105 } |
91 | 106 |
92 String _findDirWithFile(String dir, String filename) { | 107 String _findDirWithFile(String dir, String filename) { |
93 while (!new File(path.join(dir, filename)).existsSync()) { | 108 while (!new File(path.join(dir, filename)).existsSync()) { |
94 var parentDir = path.dirname(dir); | 109 var parentDir = path.dirname(dir); |
95 // If we reached root and failed to find it, bail. | 110 // If we reached root and failed to find it, bail. |
96 if (parentDir == dir) return null; | 111 if (parentDir == dir) return null; |
97 dir = parentDir; | 112 dir = parentDir; |
98 } | 113 } |
99 return dir; | 114 return dir; |
100 } | 115 } |
101 | 116 |
| 117 String _findDirWithDir(String dir, String subdir) { |
| 118 while (!new Directory(path.join(dir, subdir)).existsSync()) { |
| 119 var parentDir = path.dirname(dir); |
| 120 // If we reached root and failed to find it, bail. |
| 121 if (parentDir == dir) return null; |
| 122 dir = parentDir; |
| 123 } |
| 124 return dir; |
| 125 } |
| 126 |
102 void _reportErrorAndExit(e, trace) { | 127 void _reportErrorAndExit(e, trace) { |
103 print('Uncaught error: $e'); | 128 print('Uncaught error: $e'); |
104 if (trace != null) print(trace); | 129 if (trace != null) print(trace); |
105 exit(1); | 130 exit(1); |
106 } | 131 } |
107 | 132 |
108 ArgResults _parseArgs(arguments) { | 133 ArgResults _parseArgs(arguments) { |
109 var parser = new ArgParser() | 134 var parser = new ArgParser() |
110 ..addFlag('help', abbr: 'h', help: 'Displays this help message.', | 135 ..addFlag('help', abbr: 'h', help: 'Displays this help message.', |
111 defaultsTo: false, negatable: false) | 136 defaultsTo: false, negatable: false) |
(...skipping 25 matching lines...) Expand all Loading... |
137 _showUsage(parser); | 162 _showUsage(parser); |
138 return null; | 163 return null; |
139 } | 164 } |
140 } | 165 } |
141 | 166 |
142 _showUsage(parser) { | 167 _showUsage(parser) { |
143 print('Usage: dart --package-root=packages/ ' | 168 print('Usage: dart --package-root=packages/ ' |
144 'package:polymer/deploy.dart [options]'); | 169 'package:polymer/deploy.dart [options]'); |
145 print(parser.getUsage()); | 170 print(parser.getUsage()); |
146 } | 171 } |
OLD | NEW |