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

Side by Side Diff: pkg/polymer/lib/src/build/runner.dart

Issue 372983006: Add file-filter flag to polymer deploy (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months 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/deploy.dart ('k') | tools/testing/dart/test_suite.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 /// Definitions used to run the polymer linter and deploy tools without using 5 /// Definitions used to run the polymer linter and deploy tools without using
6 /// pub serve or pub deploy. 6 /// pub serve or pub deploy.
7 library polymer.src.build.runner; 7 library polymer.src.build.runner;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 20 matching lines...) Expand all
31 /// Mapping between package names and the path in the file system where 31 /// Mapping between package names and the path in the file system where
32 /// to find the sources of such package. 32 /// to find the sources of such package.
33 final Map<String, String> packageDirs; 33 final Map<String, String> packageDirs;
34 34
35 /// Whether to run transformers on the test folder. 35 /// Whether to run transformers on the test folder.
36 final bool transformTests; 36 final bool transformTests;
37 37
38 /// Directory where to generate code, if any. 38 /// Directory where to generate code, if any.
39 final String outDir; 39 final String outDir;
40 40
41 /// Disregard files that match these filters when copying in non
42 /// transformed files
43 List<String> fileFilter;
44
41 /// Whether to print error messages using a json-format that tools, such as 45 /// Whether to print error messages using a json-format that tools, such as
42 /// the Dart Editor, can process. 46 /// the Dart Editor, can process.
43 final bool machineFormat; 47 final bool machineFormat;
44 48
45 /// Whether to follow symlinks when listing directories. By default this is 49 /// Whether to follow symlinks when listing directories. By default this is
46 /// false because directories have symlinks for the packages directory created 50 /// false because directories have symlinks for the packages directory created
47 /// by pub, but it can be turned on for custom uses of this library. 51 /// by pub, but it can be turned on for custom uses of this library.
48 final bool followLinks; 52 final bool followLinks;
49 53
50 /// Phases of transformers to apply to packages other than the current 54 /// Phases of transformers to apply to packages other than the current
51 /// package, keyed by the package name. 55 /// package, keyed by the package name.
52 final Map<String, List<List<Transformer>>> packagePhases; 56 final Map<String, List<List<Transformer>>> packagePhases;
53 57
54 BarbackOptions(this.phases, this.outDir, {currentPackage, String packageHome, 58 BarbackOptions(this.phases, this.outDir, {currentPackage, String packageHome,
55 packageDirs, this.transformTests: false, this.machineFormat: false, 59 packageDirs, this.transformTests: false, this.machineFormat: false,
56 this.followLinks: false, 60 this.followLinks: false,
57 this.packagePhases: const {}}) 61 this.packagePhases: const {},
62 this.fileFilter: const []})
58 : currentPackage = (currentPackage != null 63 : currentPackage = (currentPackage != null
59 ? currentPackage : readCurrentPackageFromPubspec()), 64 ? currentPackage : readCurrentPackageFromPubspec()),
60 packageHome = packageHome, 65 packageHome = packageHome,
61 packageDirs = (packageDirs != null 66 packageDirs = (packageDirs != null
62 ? packageDirs : readPackageDirsFromPub(packageHome, currentPackage)); 67 ? packageDirs : readPackageDirsFromPub(packageHome, currentPackage));
63 68
64 } 69 }
65 70
66 /// Creates a barback system as specified by [options] and runs it. Returns a 71 /// Creates a barback system as specified by [options] and runs it. Returns a
67 /// future that contains the list of assets generated after barback runs to 72 /// future that contains the list of assets generated after barback runs to
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 120
116 if (currentPackage == null) { 121 if (currentPackage == null) {
117 currentPackage = readCurrentPackageFromPubspec(packageHome); 122 currentPackage = readCurrentPackageFromPubspec(packageHome);
118 } 123 }
119 map[currentPackage] = packageHome; 124 map[currentPackage] = packageHome;
120 125
121 Directory.current = cachedDir; 126 Directory.current = cachedDir;
122 return map; 127 return map;
123 } 128 }
124 129
130 bool shouldSkip(List<String> filters, String path) {
131 return filters.any((filter) => path.contains(filter));
132 }
133
125 /// Return the relative path of each file under [subDir] in [package]. 134 /// Return the relative path of each file under [subDir] in [package].
126 Iterable<String> _listPackageDir(String package, String subDir, 135 Iterable<String> _listPackageDir(String package, String subDir,
127 BarbackOptions options) { 136 BarbackOptions options) {
128 var packageDir = options.packageDirs[package]; 137 var packageDir = options.packageDirs[package];
129 if (packageDir == null) return const []; 138 if (packageDir == null) return const [];
130 var dir = new Directory(path.join(packageDir, subDir)); 139 var dir = new Directory(path.join(packageDir, subDir));
131 if (!dir.existsSync()) return const []; 140 if (!dir.existsSync()) return const [];
132 return dir.listSync(recursive: true, followLinks: options.followLinks) 141 return dir.listSync(recursive: true, followLinks: options.followLinks)
133 .where((f) => f is File) 142 .where((f) => f is File)
143 .where((f) => !shouldSkip(options.fileFilter, f.path))
134 .map((f) => path.relative(f.path, from: packageDir)); 144 .map((f) => path.relative(f.path, from: packageDir));
135 } 145 }
136 146
137 /// A simple provider that reads files directly from the pub cache. 147 /// A simple provider that reads files directly from the pub cache.
138 class _PackageProvider implements PackageProvider { 148 class _PackageProvider implements PackageProvider {
139 Map<String, String> packageDirs; 149 Map<String, String> packageDirs;
140 Iterable<String> get packages => packageDirs.keys; 150 Iterable<String> get packages => packageDirs.keys;
141 151
142 _PackageProvider(this.packageDirs); 152 _PackageProvider(this.packageDirs);
143 153
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 290 }
281 291
282 /// Emits a 'packages' directory directly under `out/packages` with the contents 292 /// Emits a 'packages' directory directly under `out/packages` with the contents
283 /// of every file that was not transformed by barback. 293 /// of every file that was not transformed by barback.
284 Future _emitPackagesDir(BarbackOptions options) { 294 Future _emitPackagesDir(BarbackOptions options) {
285 var outPackages = path.join(options.outDir, 'packages'); 295 var outPackages = path.join(options.outDir, 'packages');
286 _ensureDir(outPackages); 296 _ensureDir(outPackages);
287 297
288 // Copy all the files we didn't process 298 // Copy all the files we didn't process
289 var dirs = options.packageDirs; 299 var dirs = options.packageDirs;
290
291 return Future.forEach(dirs.keys, (package) { 300 return Future.forEach(dirs.keys, (package) {
292 return Future.forEach(_listPackageDir(package, 'lib', options), (relpath) { 301 return Future.forEach(_listPackageDir(package, 'lib', options), (relpath) {
293 var inpath = path.join(dirs[package], relpath); 302 var inpath = path.join(dirs[package], relpath);
294 var outpath = path.join(outPackages, package, relpath.substring(4)); 303 var outpath = path.join(outPackages, package, relpath.substring(4));
295 return _copyFile(inpath, outpath); 304 return _copyFile(inpath, outpath);
296 }); 305 });
297 }); 306 });
298 } 307 }
299 308
300 /// Ensure [dirpath] exists. 309 /// Ensure [dirpath] exists.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 output.write(entry.span.getLocationMessage(entry.message, 370 output.write(entry.span.getLocationMessage(entry.message,
362 useColors: useColors, 371 useColors: useColors,
363 color: levelColor)); 372 color: levelColor));
364 } 373 }
365 return output.toString(); 374 return output.toString();
366 } 375 }
367 376
368 const String _RED_COLOR = '\u001b[31m'; 377 const String _RED_COLOR = '\u001b[31m';
369 const String _MAGENTA_COLOR = '\u001b[35m'; 378 const String _MAGENTA_COLOR = '\u001b[35m';
370 const String _NO_COLOR = '\u001b[0m'; 379 const String _NO_COLOR = '\u001b[0m';
OLDNEW
« no previous file with comments | « pkg/polymer/lib/deploy.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698