OLD | NEW |
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 create a `build.dart` for your project. | 6 * Common logic to make it easy to create a `build.dart` for your project. |
7 * | 7 * |
8 * The `build.dart` script is invoked automatically by the Editor whenever a | 8 * The `build.dart` script is invoked automatically by the Editor whenever a |
9 * file in the project changes. It must be placed in the root of a project | 9 * file in the project changes. It must be placed in the root of a project |
10 * (where pubspec.yaml lives) and should be named exactly 'build.dart'. | 10 * (where pubspec.yaml lives) and should be named exactly 'build.dart'. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 String _outDir(String file) => | 70 String _outDir(String file) => |
71 new Path(file).directoryPath.append('out').toString(); | 71 new Path(file).directoryPath.append('out').toString(); |
72 | 72 |
73 bool _isGeneratedFile(String filePath, List<Directory> outputDirs) { | 73 bool _isGeneratedFile(String filePath, List<Directory> outputDirs) { |
74 var path = new Path.fromNative(filePath); | 74 var path = new Path.fromNative(filePath); |
| 75 var dirPrefix = path.directoryPath.toString(); |
75 for (var dir in outputDirs) { | 76 for (var dir in outputDirs) { |
76 if (path.directoryPath.toString() == dir.path) return true; | 77 if (dirPrefix.startsWith(dir.path)) return true; |
77 } | 78 } |
78 return path.filename.startsWith('_'); | 79 return path.filename.startsWith('_'); |
79 } | 80 } |
80 | 81 |
81 bool _isInputFile(String path, List<Directory> outputDirs) { | 82 bool _isInputFile(String path, List<Directory> outputDirs) { |
82 return (path.endsWith(".dart") || path.endsWith(".html")) | 83 return (path.endsWith(".dart") || path.endsWith(".html")) |
83 && !_isGeneratedFile(path, outputDirs); | 84 && !_isGeneratedFile(path, outputDirs); |
84 } | 85 } |
85 | 86 |
86 /** Delete all generated files. */ | 87 /** Delete all generated files. */ |
(...skipping 25 matching lines...) Expand all Loading... |
112 ..addFlag("machine", negatable: false, | 113 ..addFlag("machine", negatable: false, |
113 help: "produce warnings in a machine parseable format") | 114 help: "produce warnings in a machine parseable format") |
114 ..addFlag("help", negatable: false, help: "displays this help and exit"); | 115 ..addFlag("help", negatable: false, help: "displays this help and exit"); |
115 var args = parser.parse(arguments); | 116 var args = parser.parse(arguments); |
116 if (args["help"]) { | 117 if (args["help"]) { |
117 print(parser.getUsage()); | 118 print(parser.getUsage()); |
118 exit(0); | 119 exit(0); |
119 } | 120 } |
120 return args; | 121 return args; |
121 } | 122 } |
OLD | NEW |