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

Side by Side Diff: samples/build_dart/build.dart

Issue 2828603002: Format samples and samples-dev directories. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 library build_dart; 5 library build_dart;
6 6
7 import "dart:io"; 7 import "dart:io";
8 import "package:args/args.dart"; 8 import "package:args/args.dart";
9 9
10 bool cleanBuild; 10 bool cleanBuild;
(...skipping 24 matching lines...) Expand all
35 35
36 // Return a non-zero code to indicate a build failure. 36 // Return a non-zero code to indicate a build failure.
37 //exit(1); 37 //exit(1);
38 } 38 }
39 39
40 /** 40 /**
41 * Handle --changed, --removed, --clean, --full, and --help command-line args. 41 * Handle --changed, --removed, --clean, --full, and --help command-line args.
42 */ 42 */
43 void processArgs(List<String> arguments) { 43 void processArgs(List<String> arguments) {
44 var parser = new ArgParser(); 44 var parser = new ArgParser();
45 parser.addOption("changed", help: "the file has changed since the last build", 45 parser.addOption("changed",
46 allowMultiple: true); 46 help: "the file has changed since the last build", allowMultiple: true);
47 parser.addOption("removed", help: "the file was removed since the last build", 47 parser.addOption("removed",
48 allowMultiple: true); 48 help: "the file was removed since the last build", allowMultiple: true);
49 parser.addFlag("clean", negatable: false, help: "remove any build artifacts"); 49 parser.addFlag("clean", negatable: false, help: "remove any build artifacts");
50 parser.addFlag("full", negatable: false, help: "perform a full build"); 50 parser.addFlag("full", negatable: false, help: "perform a full build");
51 parser.addFlag("machine", 51 parser.addFlag("machine",
52 negatable: false, help: "produce warnings in a machine parseable format"); 52 negatable: false, help: "produce warnings in a machine parseable format");
53 parser.addFlag("help", negatable: false, help: "display this help and exit"); 53 parser.addFlag("help", negatable: false, help: "display this help and exit");
54 54
55 var args = parser.parse(arguments); 55 var args = parser.parse(arguments);
56 56
57 if (args["help"]) { 57 if (args["help"]) {
58 print(parser.getUsage()); 58 print(parser.getUsage());
59 exit(0); 59 exit(0);
60 } 60 }
61 61
62 changedFiles = args["changed"]; 62 changedFiles = args["changed"];
(...skipping 15 matching lines...) Expand all
78 }); 78 });
79 } 79 }
80 80
81 /** 81 /**
82 * Recursively scan the current directory looking for .foo files to process. 82 * Recursively scan the current directory looking for .foo files to process.
83 */ 83 */
84 void handleFullBuild() { 84 void handleFullBuild() {
85 var files = <String>[]; 85 var files = <String>[];
86 86
87 Directory.current.list(recursive: true).listen((entity) { 87 Directory.current.list(recursive: true).listen((entity) {
88 if (entity is File) { 88 if (entity is File) {
89 files.add((entity as File).resolveSymbolicLinksSync()); 89 files.add((entity as File).resolveSymbolicLinksSync());
90 } 90 }
91 }, 91 }, onDone: () => handleChangedFiles(files));
92 onDone: () => handleChangedFiles(files));
93 } 92 }
94 93
95 /** 94 /**
96 * Process the given list of changed files. 95 * Process the given list of changed files.
97 */ 96 */
98 void handleChangedFiles(List<String> files) { 97 void handleChangedFiles(List<String> files) {
99 files.forEach(_processFile); 98 files.forEach(_processFile);
100 } 99 }
101 100
102 /** 101 /**
103 * Process the given list of removed files. 102 * Process the given list of removed files.
104 */ 103 */
105 void handleRemovedFiles(List<String> files) { 104 void handleRemovedFiles(List<String> files) {}
106
107 }
108 105
109 /** 106 /**
110 * Convert a .foo file to a .foobar file. 107 * Convert a .foo file to a .foobar file.
111 */ 108 */
112 void _processFile(String arg) { 109 void _processFile(String arg) {
113 if (arg.endsWith(".foo")) { 110 if (arg.endsWith(".foo")) {
114 print("processing: ${arg}"); 111 print("processing: ${arg}");
115 112
116 File file = new File(arg); 113 File file = new File(arg);
117 114
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 146 }
150 147
151 /** 148 /**
152 * If this file is a generated file (based on the extension), delete it. 149 * If this file is a generated file (based on the extension), delete it.
153 */ 150 */
154 void _maybeClean(File file) { 151 void _maybeClean(File file) {
155 if (file.path.endsWith(".foobar")) { 152 if (file.path.endsWith(".foobar")) {
156 file.delete(); 153 file.delete();
157 } 154 }
158 } 155 }
OLDNEW
« no previous file with comments | « samples-dev/swarm/test/swarm_ui_lib/view/view_test.dart ('k') | samples/build_dart/test/build_dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698