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

Side by Side Diff: pkg/analyzer/tool/summary/build_sdk_summaries.dart

Issue 1979333002: Add a `strong-outputs` mode to build_sdk_summaries.dart. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'dart:io'; 1 import 'dart:io';
2 2
3 import 'package:analyzer/dart/ast/ast.dart'; 3 import 'package:analyzer/dart/ast/ast.dart';
4 import 'package:analyzer/dart/element/element.dart'; 4 import 'package:analyzer/dart/element/element.dart';
5 import 'package:analyzer/src/generated/engine.dart'; 5 import 'package:analyzer/src/generated/engine.dart';
6 import 'package:analyzer/src/generated/java_io.dart'; 6 import 'package:analyzer/src/generated/java_io.dart';
7 import 'package:analyzer/src/generated/sdk.dart'; 7 import 'package:analyzer/src/generated/sdk.dart';
8 import 'package:analyzer/src/generated/sdk_io.dart'; 8 import 'package:analyzer/src/generated/sdk_io.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/summary/flat_buffers.dart' as fb; 10 import 'package:analyzer/src/summary/flat_buffers.dart' as fb;
11 import 'package:analyzer/src/summary/index_unit.dart'; 11 import 'package:analyzer/src/summary/index_unit.dart';
12 import 'package:analyzer/src/summary/summarize_elements.dart'; 12 import 'package:analyzer/src/summary/summarize_elements.dart';
13 import 'package:path/path.dart'; 13 import 'package:path/path.dart';
14 14
15 main(List<String> args) { 15 main(List<String> args) {
16 if (args.length < 1) { 16 if (args.length < 1) {
17 _printUsage(); 17 _printUsage();
18 exitCode = 1; 18 exitCode = 1;
19 return; 19 return;
20 } 20 }
21 String command = args[0]; 21 String command = args[0];
22 if (command == 'multiple-outputs' && args.length >= 2 && args.length <= 3) { 22 if ((command == 'multiple-outputs' || command == 'strong-outputs') &&
23 args.length >= 2 &&
24 args.length <= 3) {
25 bool includeSpec = command != 'strong-outputs';
23 // 26 //
24 // Prepare the output path. 27 // Prepare the output path.
25 // 28 //
26 String outputDirectoryPath = args[1]; 29 String outputDirectoryPath = args[1];
27 if (!FileSystemEntity.isDirectorySync(outputDirectoryPath)) { 30 if (!FileSystemEntity.isDirectorySync(outputDirectoryPath)) {
28 print("'$outputDirectoryPath' is not a directory."); 31 print("'$outputDirectoryPath' is not a directory.");
29 _printUsage(); 32 _printUsage();
30 exitCode = 1; 33 exitCode = 1;
31 return; 34 return;
32 } 35 }
33 // 36 //
34 // Prepare results. 37 // Prepare results.
35 // 38 //
36 String sdkPath = args.length > 2 ? args[2] : null; 39 String sdkPath = args.length > 2 ? args[2] : null;
37 _Output output = _buildMultipleOutputs(sdkPath); 40 _Output output = _buildMultipleOutputs(sdkPath, includeSpec);
38 if (output == null) { 41 if (output == null) {
39 exitCode = 1; 42 exitCode = 1;
40 return; 43 return;
41 } 44 }
42 // 45 //
43 // Write results. 46 // Write results.
44 // 47 //
45 output.spec.writeMultiple(outputDirectoryPath, 'spec'); 48 if (includeSpec) {
49 output.spec.writeMultiple(outputDirectoryPath, 'spec');
50 }
46 output.strong.writeMultiple(outputDirectoryPath, 'strong'); 51 output.strong.writeMultiple(outputDirectoryPath, 'strong');
47 } else if (command == 'single-output' && 52 } else if (command == 'single-output' &&
48 args.length >= 2 && 53 args.length >= 2 &&
49 args.length <= 3) { 54 args.length <= 3) {
50 String outputPath = args[1]; 55 String outputPath = args[1];
51 String sdkPath = args.length > 2 ? args[2] : null; 56 String sdkPath = args.length > 2 ? args[2] : null;
52 // 57 //
53 // Prepare results. 58 // Prepare results.
54 // 59 //
55 _Output output = _buildMultipleOutputs(sdkPath); 60 _Output output = _buildMultipleOutputs(sdkPath, true);
56 if (output == null) { 61 if (output == null) {
57 exitCode = 1; 62 exitCode = 1;
58 return; 63 return;
59 } 64 }
60 // 65 //
61 // Write results. 66 // Write results.
62 // 67 //
63 fb.Builder builder = new fb.Builder(); 68 fb.Builder builder = new fb.Builder();
64 fb.Offset specSumOffset = builder.writeListUint8(output.spec.sum); 69 fb.Offset specSumOffset = builder.writeListUint8(output.spec.sum);
65 fb.Offset specIndexOffset = builder.writeListUint8(output.spec.index); 70 fb.Offset specIndexOffset = builder.writeListUint8(output.spec.index);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 /** 104 /**
100 * The name of the SDK summaries builder application. 105 * The name of the SDK summaries builder application.
101 */ 106 */
102 const BINARY_NAME = "build_sdk_summaries"; 107 const BINARY_NAME = "build_sdk_summaries";
103 108
104 const int _FIELD_SPEC_INDEX = 1; 109 const int _FIELD_SPEC_INDEX = 1;
105 const int _FIELD_SPEC_SUM = 0; 110 const int _FIELD_SPEC_SUM = 0;
106 const int _FIELD_STRONG_INDEX = 3; 111 const int _FIELD_STRONG_INDEX = 3;
107 const int _FIELD_STRONG_SUM = 2; 112 const int _FIELD_STRONG_SUM = 2;
108 113
109 _Output _buildMultipleOutputs(String sdkPath) { 114 _Output _buildMultipleOutputs(String sdkPath, bool includeSpec) {
110 // 115 //
111 // Validate the SDK path. 116 // Validate the SDK path.
112 // 117 //
113 if (sdkPath != null) { 118 if (sdkPath != null) {
114 if (!FileSystemEntity.isDirectorySync('$sdkPath/lib')) { 119 if (!FileSystemEntity.isDirectorySync('$sdkPath/lib')) {
115 print("'$sdkPath/lib' does not exist."); 120 print("'$sdkPath/lib' does not exist.");
116 _printUsage(); 121 _printUsage();
117 return null; 122 return null;
118 } 123 }
119 } else { 124 } else {
120 sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath(); 125 sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath();
121 } 126 }
122 // 127 //
123 // Build spec and strong outputs. 128 // Build spec and strong outputs.
124 // 129 //
125 _BuilderOutput spec = new _Builder(sdkPath, false).build(); 130 _BuilderOutput spec =
131 includeSpec ? new _Builder(sdkPath, false).build() : null;
126 _BuilderOutput strong = new _Builder(sdkPath, true).build(); 132 _BuilderOutput strong = new _Builder(sdkPath, true).build();
127 return new _Output(spec, strong); 133 return new _Output(spec, strong);
128 } 134 }
129 135
130 /** 136 /**
131 * Open the flat buffer in [inputPath] and extract the byte array in the [field] 137 * Open the flat buffer in [inputPath] and extract the byte array in the [field]
132 * into the [outputPath] file. 138 * into the [outputPath] file.
133 */ 139 */
134 void _extractSingleOutput(String inputPath, int field, String outputPath) { 140 void _extractSingleOutput(String inputPath, int field, String outputPath) {
135 List<int> bytes = new File(inputPath).readAsBytesSync(); 141 List<int> bytes = new File(inputPath).readAsBytesSync();
136 fb.BufferPointer root = new fb.BufferPointer.fromBytes(bytes); 142 fb.BufferPointer root = new fb.BufferPointer.fromBytes(bytes);
137 fb.BufferPointer table = root.derefObject(); 143 fb.BufferPointer table = root.derefObject();
138 List<int> fieldBytes = const fb.Uint8ListReader().vTableGet(table, field); 144 List<int> fieldBytes = const fb.Uint8ListReader().vTableGet(table, field);
139 new File(outputPath).writeAsBytesSync(fieldBytes, mode: FileMode.WRITE_ONLY); 145 new File(outputPath).writeAsBytesSync(fieldBytes, mode: FileMode.WRITE_ONLY);
140 } 146 }
141 147
142 /** 148 /**
143 * Print information about how to use the SDK summaries builder. 149 * Print information about how to use the SDK summaries builder.
144 */ 150 */
145 void _printUsage() { 151 void _printUsage() {
146 // print('Usage: $BINARY_NAME command output_directory_path [sdk_path]'); 152 // print('Usage: $BINARY_NAME command output_directory_path [sdk_path]');
147 print('Usage: $BINARY_NAME command arguments'); 153 print('Usage: $BINARY_NAME command arguments');
148 print('Where command can be one of the following:'); 154 print('Where command can be one of the following:');
149 print(' multiple-outputs output_directory_path [sdk_path]'); 155 print(' multiple-outputs output_directory_path [sdk_path]');
150 print(' Generate separate summary and index files.'); 156 print(' Generate separate summary and index files.');
157 print(' strong-outputs output_directory_path [sdk_path]');
158 print(' Generate separate summary and index files (strong mode only).');
151 print(' single-output output_file_path [sdk_path]'); 159 print(' single-output output_file_path [sdk_path]');
152 print(' Generate a single file with summary and index.'); 160 print(' Generate a single file with summary and index.');
153 print(' extract-spec-sum input_file output_file'); 161 print(' extract-spec-sum input_file output_file');
154 print(' Extract the spec-mode summary file.'); 162 print(' Extract the spec-mode summary file.');
155 print(' extract-strong-sum input_file output_file'); 163 print(' extract-strong-sum input_file output_file');
156 print(' Extract the strong-mode summary file.'); 164 print(' Extract the strong-mode summary file.');
157 print(' extract-spec-index input_file output_file'); 165 print(' extract-spec-index input_file output_file');
158 print(' Extract the spec-mode index file.'); 166 print(' Extract the spec-mode index file.');
159 print(' extract-strong-index input_file output_file'); 167 print(' extract-strong-index input_file output_file');
160 print(' Extract the strong-mode index file.'); 168 print(' Extract the strong-mode index file.');
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 263 }
256 } 264 }
257 } 265 }
258 266
259 class _Output { 267 class _Output {
260 final _BuilderOutput spec; 268 final _BuilderOutput spec;
261 final _BuilderOutput strong; 269 final _BuilderOutput strong;
262 270
263 _Output(this.spec, this.strong); 271 _Output(this.spec, this.strong);
264 } 272 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698