Skip to content

Commit 42799b6

Browse files
jcollins-gcommit-bot@chromium.org
authored andcommitted
Add support for unmanaged packages to trial_migration.
Change-Id: I01fbfa251f8b7fdcaec90102b603641bf573c107 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127501 Commit-Queue: Janice Collins <jcollins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
1 parent 304eb2c commit 42799b6

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

pkg/nnbd_migration/tool/src/package.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ import 'dart:io';
99

1010
import 'package:path/path.dart' as path;
1111

12+
/// Return a resolved path including the home directory in place of tilde
13+
/// references.
14+
String resolveTildePath(String originalPath) {
15+
if (originalPath == null || !originalPath.startsWith('~/')) {
16+
return originalPath;
17+
}
18+
19+
String homeDir;
20+
21+
if (Platform.isWindows) {
22+
homeDir = path.absolute(Platform.environment['USERPROFILE']);
23+
} else {
24+
homeDir = path.absolute(Platform.environment['HOME']);
25+
}
26+
27+
return path.join(homeDir, originalPath.substring(2));
28+
}
29+
1230
/// Returns the path to the SDK repository this script is a part of.
1331
final String thisSdkRepo = () {
1432
var maybeSdkRepoDir = Platform.script.toFilePath();
@@ -24,6 +42,14 @@ final String thisSdkRepo = () {
2442

2543
Uri get thisSdkUri => Uri.file(thisSdkRepo);
2644

45+
/// Abstraction for an unmanaged package.
46+
class ManualPackage extends Package {
47+
ManualPackage(this.packagePath) : super(packagePath);
48+
49+
@override
50+
final String packagePath;
51+
}
52+
2753
/// Abstraction for a package fetched via Github.
2854
class GitHubPackage extends Package {
2955
GitHubPackage(String name, [String label]) : super(name) {

pkg/nnbd_migration/tool/trial_migration.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ main(List<String> args) async {
3232
help: 'Select the root of the SDK to analyze against for this run '
3333
'(compiled with --nnbd). For example: ../../xcodebuild/DebugX64NNBD/dart-sdk');
3434

35+
argParser.addMultiOption(
36+
'manual_packages',
37+
abbr: 'm',
38+
defaultsTo: [],
39+
help: 'Run migration against packages in these directories. Does not '
40+
'run pub get, any git commands, or any other preparation.',
41+
splitCommas: true,
42+
);
43+
3544
argParser.addMultiOption(
3645
'packages',
3746
abbr: 'p',
@@ -75,9 +84,12 @@ main(List<String> args) async {
7584
warnOnNoAssertions();
7685
warnOnNoSdkNnbd(sdk);
7786

78-
List<Package> packages = (parsedArgs['packages'] as Iterable<String>)
79-
.map((n) => SdkPackage(n))
80-
.toList(growable: false);
87+
List<Package> packages = [
88+
for (String package in parsedArgs['packages'] as Iterable<String>)
89+
SdkPackage(package),
90+
for (String package in parsedArgs['manual_packages'] as Iterable<String>)
91+
ManualPackage(package),
92+
];
8193

8294
String categoryOfInterest =
8395
parsedArgs.rest.isEmpty ? null : parsedArgs.rest.single;

0 commit comments

Comments
 (0)