dart-sdk/pkg/vm/bin/list_libraries.dart
Ryan Macnak 5d71308b78 [vm/tools] Don't duplicate "problems" metadata into split package files.
Add utility for enumerating libraries in a kernel binary.

Bug: MI4-1794
Change-Id: Iad65f236ef9d0d184323ffd2af92d311a97e525c
Reviewed-on: https://dart-review.googlesource.com/c/92865
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-02-13 19:16:36 +00:00

31 lines
840 B
Dart

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
final String _usage = '''
Usage: list_libraries input.dill
Lists libraries included in a kernel binary file.
''';
main(List<String> arguments) async {
if (arguments.length != 1) {
print(_usage);
exit(1);
}
final input = arguments[0];
final component = new Component();
final List<int> bytes = new File(input).readAsBytesSync();
new BinaryBuilder(bytes).readComponent(component);
for (final lib in component.libraries) {
print(lib.importUri);
}
}