Skip to content

Commit

Permalink
Add support for unmanaged packages to trial_migration.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jcollins-g authored and commit-bot@chromium.org committed Dec 9, 2019
1 parent 304eb2c commit 42799b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
26 changes: 26 additions & 0 deletions pkg/nnbd_migration/tool/src/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ import 'dart:io';

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

/// Return a resolved path including the home directory in place of tilde
/// references.
String resolveTildePath(String originalPath) {
if (originalPath == null || !originalPath.startsWith('~/')) {
return originalPath;
}

String homeDir;

if (Platform.isWindows) {
homeDir = path.absolute(Platform.environment['USERPROFILE']);
} else {
homeDir = path.absolute(Platform.environment['HOME']);
}

return path.join(homeDir, originalPath.substring(2));
}

/// Returns the path to the SDK repository this script is a part of.
final String thisSdkRepo = () {
var maybeSdkRepoDir = Platform.script.toFilePath();
Expand All @@ -24,6 +42,14 @@ final String thisSdkRepo = () {

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

/// Abstraction for an unmanaged package.
class ManualPackage extends Package {
ManualPackage(this.packagePath) : super(packagePath);

@override
final String packagePath;
}

/// Abstraction for a package fetched via Github.
class GitHubPackage extends Package {
GitHubPackage(String name, [String label]) : super(name) {
Expand Down
18 changes: 15 additions & 3 deletions pkg/nnbd_migration/tool/trial_migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ main(List<String> args) async {
help: 'Select the root of the SDK to analyze against for this run '
'(compiled with --nnbd). For example: ../../xcodebuild/DebugX64NNBD/dart-sdk');

argParser.addMultiOption(
'manual_packages',
abbr: 'm',
defaultsTo: [],
help: 'Run migration against packages in these directories. Does not '
'run pub get, any git commands, or any other preparation.',
splitCommas: true,
);

argParser.addMultiOption(
'packages',
abbr: 'p',
Expand Down Expand Up @@ -75,9 +84,12 @@ main(List<String> args) async {
warnOnNoAssertions();
warnOnNoSdkNnbd(sdk);

List<Package> packages = (parsedArgs['packages'] as Iterable<String>)
.map((n) => SdkPackage(n))
.toList(growable: false);
List<Package> packages = [
for (String package in parsedArgs['packages'] as Iterable<String>)
SdkPackage(package),
for (String package in parsedArgs['manual_packages'] as Iterable<String>)
ManualPackage(package),
];

String categoryOfInterest =
parsedArgs.rest.isEmpty ? null : parsedArgs.rest.single;
Expand Down

0 comments on commit 42799b6

Please sign in to comment.