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

Side by Side Diff: tool/patch_sdk.dart

Issue 1322333003: DDC: mostly incremental compilation, fixes #223 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 3 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 #!/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 library dev_compiler.tool.patch_sdk; 8 library dev_compiler.tool.patch_sdk;
9 9
10 import 'dart:io'; 10 import 'dart:io';
11 import 'dart:math' as math; 11 import 'dart:math' as math;
12 12
13 import 'package:analyzer/analyzer.dart'; 13 import 'package:analyzer/analyzer.dart';
14 import 'package:analyzer/src/generated/sdk.dart'; 14 import 'package:analyzer/src/generated/sdk.dart';
15 import 'package:path/path.dart' as path; 15 import 'package:path/path.dart' as path;
16 16
17 void main(List<String> argv) { 17 void main(List<String> argv) {
18 var self = path.relative(path.fromUri(Platform.script));
18 if (argv.length < 2) { 19 if (argv.length < 2) {
19 var self = path.relative(path.fromUri(Platform.script));
20 var toolDir = path.relative(path.dirname(path.fromUri(Platform.script))); 20 var toolDir = path.relative(path.dirname(path.fromUri(Platform.script)));
21 21
22 var inputExample = path.join(toolDir, 'input_sdk'); 22 var inputExample = path.join(toolDir, 'input_sdk');
23 var outExample = path.relative( 23 var outExample = path.relative(
24 path.normalize(path.join(toolDir, '..', 'test', 'generated_sdk'))); 24 path.normalize(path.join(toolDir, '..', 'test', 'generated_sdk')));
25 25
26 print('Usage: $self INPUT_DIR OUTPUT_DIR'); 26 print('Usage: $self INPUT_DIR OUTPUT_DIR');
27 print('For example:'); 27 print('For example:');
28 print('\$ $self $inputExample $outExample'); 28 print('\$ $self $inputExample $outExample');
29 29
30 inputExample = path.join(toolDir, 'min_sdk'); 30 inputExample = path.join(toolDir, 'min_sdk');
31 outExample = path.join(toolDir, 'out', 'min_sdk'); 31 outExample = path.join(toolDir, 'out', 'min_sdk');
32 print('\$ $self $inputExample $outExample'); 32 print('\$ $self $inputExample $outExample');
33 exit(1); 33 exit(1);
34 } 34 }
35 var selfLastModify = new File(self).lastModifiedSync().millisecondsSinceEpoch;
35 36
36 var input = argv[0]; 37 var input = argv[0];
37 var sdkLibIn = path.join(input, 'lib'); 38 var sdkLibIn = path.join(input, 'lib');
38 var patchIn = path.join(input, 'patch'); 39 var patchIn = path.join(input, 'patch');
39 var privateIn = path.join(input, 'private'); 40 var privateIn = path.join(input, 'private');
40 var sdkOut = path.join(argv[1], 'lib'); 41 var sdkOut = path.join(argv[1], 'lib');
41 42
42 var INTERNAL_PATH = '_internal/compiler/js_lib/'; 43 var INTERNAL_PATH = '_internal/compiler/js_lib/';
43 44
44 // Copy libraries.dart and version 45 // Copy libraries.dart and version
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 var patchPath = path.join( 96 var patchPath = path.join(
96 patchIn, path.basenameWithoutExtension(libraryIn) + '_patch.dart'); 97 patchIn, path.basenameWithoutExtension(libraryIn) + '_patch.dart');
97 98
98 var patchFile = new File(patchPath); 99 var patchFile = new File(patchPath);
99 bool patchExists = patchFile.existsSync(); 100 bool patchExists = patchFile.existsSync();
100 if (patchExists) { 101 if (patchExists) {
101 inputModifyTime = math.max(inputModifyTime, 102 inputModifyTime = math.max(inputModifyTime,
102 patchFile.lastModifiedSync().millisecondsSinceEpoch); 103 patchFile.lastModifiedSync().millisecondsSinceEpoch);
103 } 104 }
104 105
106 // If the patch_sdk itself was modified, take that into account.
107 inputModifyTime = math.max(inputModifyTime, selfLastModify);
108
105 // Compute output paths 109 // Compute output paths
106 outPaths = outPaths 110 outPaths = outPaths
107 .map((p) => path.join(sdkOut, path.relative(p, from: sdkLibIn))) 111 .map((p) => path.join(sdkOut, path.relative(p, from: sdkLibIn)))
108 .toList(); 112 .toList();
109 113
110 // Compare output modify time with input modify time. 114 // Compare output modify time with input modify time.
111 bool needsUpdate = false; 115 bool needsUpdate = false;
112 for (var outPath in outPaths) { 116 for (var outPath in outPaths) {
113 var outFile = new File(outPath); 117 var outFile = new File(outPath);
114 if (!outFile.existsSync() || 118 if (!outFile.existsSync() ||
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if (diff != 0) return diff; 428 if (diff != 0) return diff;
425 return end - other.end; 429 return end - other.end;
426 } 430 }
427 } 431 }
428 432
429 List<SdkLibrary> _getSdkLibraries(String contents) { 433 List<SdkLibrary> _getSdkLibraries(String contents) {
430 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); 434 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true);
431 parseCompilationUnit(contents).accept(libraryBuilder); 435 parseCompilationUnit(contents).accept(libraryBuilder);
432 return libraryBuilder.librariesMap.sdkLibraries; 436 return libraryBuilder.librariesMap.sdkLibraries;
433 } 437 }
OLDNEW
« lib/src/options.dart ('K') | « tool/build_sdk.sh ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698