| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /// Command line tool to merge the SDK libraries and our patch files. | 6 /// Command line tool to merge the SDK libraries and our patch files. |
| 7 /// This is currently designed as an offline tool, but we could automate it. | 7 /// This is currently designed as an offline tool, but we could automate it. |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // (2) Dart SDK and patch sources. | 234 // (2) Dart SDK and patch sources. |
| 235 // We already collected all inputs from the second category in the deps | 235 // We already collected all inputs from the second category in the deps |
| 236 // set. To collect inputs from the first category we actually use Fasta: | 236 // set. To collect inputs from the first category we actually use Fasta: |
| 237 // we ask Fasta to outline patch_sdk.dart and generate a depfile which | 237 // we ask Fasta to outline patch_sdk.dart and generate a depfile which |
| 238 // would list all the sources. | 238 // would list all the sources. |
| 239 final depfile = "${outDir}.d"; | 239 final depfile = "${outDir}.d"; |
| 240 await CompilerCommandLine.withGlobalOptions("outline", [ | 240 await CompilerCommandLine.withGlobalOptions("outline", [ |
| 241 '--packages', | 241 '--packages', |
| 242 new Uri.file(packagesFile).toString(), | 242 new Uri.file(packagesFile).toString(), |
| 243 '--platform', | 243 '--platform', |
| 244 platform, // platform.dill that was just generated | 244 new Uri.file(platform).toString(), // platform.dill |
| 245 Platform.script.toString() // patch_sdk.dart | 245 Platform.script.toString() // patch_sdk.dart |
| 246 ], (CompilerContext c) async { | 246 ], (CompilerContext c) async { |
| 247 CompileTask task = | 247 CompileTask task = |
| 248 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); | 248 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); |
| 249 final kernelTarget = await task.buildOutline(null); | 249 final kernelTarget = await task.buildOutline(null); |
| 250 await kernelTarget.writeDepsFile( | 250 await kernelTarget.writeDepsFile( |
| 251 new Uri.file(platform), new Uri.file(depfile)); | 251 new Uri.file(platform), new Uri.file(depfile)); |
| 252 }); | 252 }); |
| 253 | 253 |
| 254 // Read depfile generated by Fasta and append deps that we have collected | 254 // Read depfile generated by Fasta and append deps that we have collected |
| 255 // during generation of patched_sdk to it. | 255 // during generation of patched_sdk to it. |
| 256 final list = new File(depfile).readAsStringSync().split(':'); | 256 // Note: we are splitting by ': ' because Windows paths can start with |
| 257 // drive letter followed by a colon. |
| 258 final list = new File(depfile).readAsStringSync().split(': '); |
| 257 assert(list.length == 2); | 259 assert(list.length == 2); |
| 258 deps.addAll(list[1].split(' ').where((str) => str.isNotEmpty)); | 260 deps.addAll(list[1].split(' ').where((str) => str.isNotEmpty)); |
| 259 assert(list[0] == 'patched_sdk/platform.dill'); | 261 assert(list[0] == path.join('patched_sdk', 'platform.dill')); |
| 260 new File(depfile).writeAsStringSync("${list[0]}: ${deps.join(' ')}\n"); | 262 new File(depfile).writeAsStringSync("${list[0]}: ${deps.join(' ')}\n"); |
| 261 }, zoneSpecification: new ZoneSpecification(print: (_, _2, _3, line) { | 263 }, zoneSpecification: new ZoneSpecification(print: (_, _2, _3, line) { |
| 262 capturedLines.add(line); | 264 capturedLines.add(line); |
| 263 })); | 265 })); |
| 264 } catch (_) { | 266 } catch (_) { |
| 265 for (final line in capturedLines) { | 267 for (final line in capturedLines) { |
| 266 print(line); | 268 print(line); |
| 267 } | 269 } |
| 268 rethrow; | 270 rethrow; |
| 269 } | 271 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 if (diff != 0) return diff; | 609 if (diff != 0) return diff; |
| 608 return end - other.end; | 610 return end - other.end; |
| 609 } | 611 } |
| 610 } | 612 } |
| 611 | 613 |
| 612 List<SdkLibrary> _getSdkLibraries(String contents) { | 614 List<SdkLibrary> _getSdkLibraries(String contents) { |
| 613 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); | 615 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); |
| 614 parseCompilationUnit(contents).accept(libraryBuilder); | 616 parseCompilationUnit(contents).accept(libraryBuilder); |
| 615 return libraryBuilder.librariesMap.sdkLibraries; | 617 return libraryBuilder.librariesMap.sdkLibraries; |
| 616 } | 618 } |
| OLD | NEW |