mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:32:49 +00:00
6607655382
The files in `command/*` were moved as part of https://dart-review.googlesource.com/c/sdk/+/154360. This CL responds to Slava's comment "FWIW having this files in bin violates pub layout guidelines and looks pretty different from all other packages we have: bin/ is a folder for scripts. Libraries should live in lib." I verified in DevTools that with this change, we can still import files from package:vm_snapshot_analysis and run on the web (as long as we do not import files that depend on dart:io - lib/commands/utils.dart) Change-Id: I8c4f2a55c9cf346260fa5b80116c21993ccfc249 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154481 Reviewed-by: Vyacheslav Egorov <vegorov@google.com> Commit-Queue: Kenzie Schmoll <kenzieschmoll@google.com>
48 lines
1.6 KiB
Dart
Executable file
48 lines
1.6 KiB
Dart
Executable file
#!/usr/bin/env dart
|
|
|
|
// Copyright (c) 2020, 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:args/command_runner.dart';
|
|
|
|
import 'package:vm_snapshot_analysis/src/commands/compare.dart';
|
|
import 'package:vm_snapshot_analysis/src/commands/explain.dart';
|
|
import 'package:vm_snapshot_analysis/src/commands/summary.dart';
|
|
import 'package:vm_snapshot_analysis/src/commands/treemap.dart';
|
|
|
|
final _executableName = () {
|
|
// There is no reliable way to detect executable name across different modes
|
|
// of running this script. This code handles two most common ways:
|
|
//
|
|
// * Running from source
|
|
// * Running a wrapper script created by
|
|
//
|
|
// pub global activate vm_snapshot_analysis
|
|
//
|
|
// Note that this does not properly handle the case of installing this
|
|
// package from path (pub global activate --source path ...), but
|
|
// we consider that uncommon.
|
|
final scriptName = Platform.script.pathSegments.last;
|
|
if (scriptName.endsWith('.dart')) {
|
|
return scriptName;
|
|
}
|
|
return 'snapshot_analysis';
|
|
}();
|
|
|
|
final runner = CommandRunner(
|
|
_executableName, 'Tools for binary size analysis of Dart VM AOT snapshots.')
|
|
..addCommand(TreemapCommand())
|
|
..addCommand(CompareCommand())
|
|
..addCommand(SummaryCommand())
|
|
..addCommand(ExplainCommand());
|
|
|
|
void main(List<String> args) async {
|
|
try {
|
|
await runner.run(args);
|
|
} on UsageException catch (e) {
|
|
print(e.toString());
|
|
}
|
|
}
|