| 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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (arg.endsWith(".foo")) { | 112 if (arg.endsWith(".foo")) { |
| 113 print("processing: ${arg}"); | 113 print("processing: ${arg}"); |
| 114 | 114 |
| 115 File file = new File(arg); | 115 File file = new File(arg); |
| 116 | 116 |
| 117 String contents = file.readAsStringSync(); | 117 String contents = file.readAsStringSync(); |
| 118 | 118 |
| 119 File outFile = new File("${arg}bar"); | 119 File outFile = new File("${arg}bar"); |
| 120 | 120 |
| 121 var out = outFile.openWrite(); | 121 var out = outFile.openWrite(); |
| 122 out.addString("// processed from ${file.name}:\n"); | 122 out.addString("// processed from ${file.path}:\n"); |
| 123 if (contents != null) { | 123 if (contents != null) { |
| 124 out.addString(contents); | 124 out.addString(contents); |
| 125 } | 125 } |
| 126 out.close(); | 126 out.close(); |
| 127 | 127 |
| 128 _findErrors(arg); | 128 _findErrors(arg); |
| 129 | 129 |
| 130 print("wrote: ${outFile.name}"); | 130 print("wrote: ${outFile.path}"); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 void _findErrors(String arg) { | 134 void _findErrors(String arg) { |
| 135 File file = new File(arg); | 135 File file = new File(arg); |
| 136 | 136 |
| 137 List lines = file.readAsLinesSync(); | 137 List lines = file.readAsLinesSync(); |
| 138 | 138 |
| 139 for (int i = 0; i < lines.length; i++) { | 139 for (int i = 0; i < lines.length; i++) { |
| 140 if (lines[i].contains("woot") && !lines[i].startsWith("//")) { | 140 if (lines[i].contains("woot") && !lines[i].startsWith("//")) { |
| 141 if (useMachineInterface) { | 141 if (useMachineInterface) { |
| 142 // Ideally, we should emit the charStart and charEnd params as well. | 142 // Ideally, we should emit the charStart and charEnd params as well. |
| 143 print('[{"method":"error","params":{"file":"$arg","line":${i+1},' | 143 print('[{"method":"error","params":{"file":"$arg","line":${i+1},' |
| 144 '"message":"woot not supported"}}]'); | 144 '"message":"woot not supported"}}]'); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * If this file is a generated file (based on the extension), delete it. | 151 * If this file is a generated file (based on the extension), delete it. |
| 152 */ | 152 */ |
| 153 void _maybeClean(File file) { | 153 void _maybeClean(File file) { |
| 154 if (file.name.endsWith(".foobar")) { | 154 if (file.path.endsWith(".foobar")) { |
| 155 file.delete(); | 155 file.delete(); |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |