Remove deprecated packageRoot API, which doesn't work in Dart 2

Bug: https://github.com/dart-lang/sdk/issues/47769
Change-Id: I1cbd7761e7119c07f2697d7624bec703ba4c4641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221340
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
This commit is contained in:
Michael Thomsen 2021-12-07 14:44:49 +00:00 committed by Commit Bot
parent afc70dbeef
commit 71e3dac037
19 changed files with 21 additions and 159 deletions

View file

@ -12,6 +12,18 @@
error with an existing stack trace, instead of creating
a new stack trace.
#### `dart:io`
- **Breaking Change** [#47769](https://github.com/dart-lang/sdk/issues/47769):
The `Platform.packageRoot` API has been removed. I had been marked deprecated in
2018, as it doesn't work with any Dart 2.x release.
#### `dart:isolate`
- **Breaking Change** [#47769](https://github.com/dart-lang/sdk/issues/47769):
The `Isolate.packageRoot` API has been removed. I had been marked deprecated in
2018, as it doesn't work with any Dart 2.x release.
### Tools
#### Dart command line

2
DEPS
View file

@ -135,7 +135,7 @@ vars = {
"package_config_rev": "fb736aa12316dd2d882b202a438a6946a4b4bea0",
"path_rev": "c20d73c3516d3a0061c90f14b761ff532b9bf707",
"pedantic_rev": "66f2f6c27581c7936482e83be80b27be2719901c",
"platform_rev": "c20e6fa315e9f8820e51c0ae721f63aff33b8e17",
"platform_rev": "1ffad63428bbd1b3ecaa15926bacfb724023648c",
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_rev": "7abe634002a1ba8a0928eded086062f1307ccfae",
"process_rev": "56ece43b53b64c63ae51ec184b76bd5360c28d0b",

View file

@ -67,10 +67,6 @@ class DriverOptions {
/// The path to a `.packages` configuration file
String? packageConfigPath;
/// The path to the package root.
@Deprecated('https://github.com/dart-lang/sdk/issues/41197')
String? packageRootPath;
/// Whether to use Dart's Strong Mode analyzer.
bool strongMode = true;

View file

@ -1192,7 +1192,6 @@ class Isolate {
bool errorsAreFatal = true,
bool? checked,
Map<String, String>? environment,
@deprecated Uri? packageRoot,
Uri? packageConfig,
bool automaticPackageResolution = false,
String? debugName,

View file

@ -283,14 +283,8 @@ abstract class GeneratedContent {
if (generateNeeded) {
print('Please regenerate using:');
var executable = Platform.executable;
var packageRoot = '';
// ignore: deprecated_member_use
if (Platform.packageRoot != null) {
// ignore: deprecated_member_use
packageRoot = ' --package-root=${Platform.packageRoot}';
}
var generateScript = normalize(joinAll(posix.split(generatorPath)));
print(' $executable$packageRoot $generateScript ${args.join(" ")}');
print(' $executable $generateScript ${args.join(" ")}');
fail('Error codes need to be generated');
} else {
print('All generated files up to date.');

View file

@ -168,8 +168,6 @@ class CompilerOptions implements DiagnosticOptions {
}
/// Location of the package configuration file.
///
/// If not null then [packageRoot] should be null.
Uri? packageConfig;
/// List of kernel files to load.

View file

@ -6,6 +6,7 @@
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart' as path;
List<String> dart2JsCommand(List<String> args) {
@ -16,9 +17,7 @@ List<String> dart2JsCommand(List<String> args) {
String dart2jsPath =
path.normalize(path.join(basePath, 'pkg/compiler/lib/src/dart2js.dart'));
List command = <String>[];
if (Platform.packageRoot != null) {
command.add('--package-root=${Platform.packageRoot}');
} else if (Platform.packageConfig != null) {
if (Platform.packageConfig != null) {
command.add('--packages=${Platform.packageConfig}');
}
command.add(dart2jsPath);

View file

@ -205,11 +205,6 @@ class Platform {
/// Provides a new list every time the value is read.
static List<String> get executableArguments => _Platform.executableArguments;
/// This returns `null`, as `packages/` directories are no longer supported.
///
@Deprecated('packages/ directory resolution is not supported in Dart 2')
static String? get packageRoot => null; // TODO(mfairhurst): remove this
/// The `--packages` flag passed to the executable used to run the script
/// in this isolate.
///

View file

@ -18,8 +18,8 @@
/// {@category VM}
library dart.isolate;
import "dart:async";
import "dart:_internal" show Since;
import "dart:async";
import "dart:typed_data" show ByteBuffer, TypedData, Uint8List;
part "capability.dart";
@ -158,13 +158,6 @@ class Isolate {
/// is a sure way to hang your program.
external static Isolate get current;
/// The package root of the current isolate, if any.
///
/// This getter returns `null`, as the `packages/` directory is not supported
/// in Dart 2.
@Deprecated('packages/ directory resolution is not supported in Dart 2.')
external static Future<Uri?> get packageRoot;
/// The location of the package configuration of the current isolate, if any.
///
/// If the isolate has not been setup for package resolution,

View file

@ -1,51 +0,0 @@
// Copyright (c) 2016, 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 'dart:isolate';
final PACKAGE_URI = "package:foo/bar.dart";
main([args, port]) async {
if (port != null) {
testPackageResolution(port);
return;
}
var p = new RawReceivePort();
Isolate.spawnUri(Platform.script, [], p.sendPort,
automaticPackageResolution: true);
p.handler = (msg) {
p.close();
if (msg is! List) {
print(msg.runtimeType);
throw "Failure return from spawned isolate:\n\n$msg";
}
if (msg[0] != null) {
throw "Bad package root in child isolate: ${msg[0]}.\n"
"Expected: null";
}
if (msg[1] != null) {
throw "Package path not matching: ${msg[1]}\n"
"Expected: null";
}
print("SUCCESS");
};
print("Spawning isolate's package root: ${await Isolate.packageRoot}");
}
testPackageResolution(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageRoot = await Isolate.packageRoot;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package root: $packageRoot");
print("Spawned isolate's resolved package path: $resolvedPkg");
port.send([packageRoot?.toString(), resolvedPkg?.toString()]);
} catch (e, s) {
port.send("$e\n$s\n");
}
}

View file

@ -32,16 +32,13 @@ main([args, port]) async {
}
print("SUCCESS");
};
print("Spawning isolate's package root: ${await Isolate.packageRoot}");
}
testPackageResolution(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -31,12 +31,10 @@ main([args, port]) async {
testBadResolvePackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var badPackageUri = Uri.parse("package:asdf/qwerty.dart");
var resolvedPkg = await Isolate.resolvePackageUri(badPackageUri);
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -7,8 +7,8 @@
import 'dart:io';
import 'dart:isolate';
import "package:foo/foo.dart";
import "package:bar/bar.dart";
import "package:foo/foo.dart";
var CONFIG_URI = "package:bar/spawned_packages/";
@ -18,8 +18,7 @@ main([args, port]) async {
return;
}
var p = new RawReceivePort();
Isolate.spawnUri(Platform.script, [], p.sendPort,
packageRoot: Uri.parse(CONFIG_URI));
Isolate.spawnUri(Platform.script, [], p.sendPort);
p.handler = (msg) {
p.close();
if (msg is! List) {
@ -45,11 +44,9 @@ main([args, port]) async {
testCorrectBarPackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(CONFIG_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -45,11 +45,9 @@ main([args, port]) async {
testCorrectBarPackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(CONFIG_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -1,53 +0,0 @@
// Copyright (c) 2016, 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.
// @dart = 2.9
import 'dart:io';
import 'dart:isolate';
final PACKAGE_URI = "package:foo/bar.dart";
main([args, port]) async {
if (port != null) {
testPackageResolution(port);
return;
}
var p = new RawReceivePort();
Isolate.spawnUri(Platform.script, [], p.sendPort,
automaticPackageResolution: true);
p.handler = (msg) {
p.close();
if (msg is! List) {
print(msg.runtimeType);
throw "Failure return from spawned isolate:\n\n$msg";
}
if (msg[0] != null) {
throw "Bad package root in child isolate: ${msg[0]}.\n"
"Expected: null";
}
if (msg[1] != null) {
throw "Package path not matching: ${msg[1]}\n"
"Expected: null";
}
print("SUCCESS");
};
print("Spawning isolate's package root: ${await Isolate.packageRoot}");
}
testPackageResolution(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageRoot = await Isolate.packageRoot;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package root: $packageRoot");
print("Spawned isolate's resolved package path: $resolvedPkg");
port.send([packageRoot?.toString(), resolvedPkg?.toString()]);
} catch (e, s) {
port.send("$e\n$s\n");
}
}

View file

@ -34,16 +34,13 @@ main([args, port]) async {
}
print("SUCCESS");
};
print("Spawning isolate's package root: ${await Isolate.packageRoot}");
}
testPackageResolution(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(PACKAGE_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -33,12 +33,10 @@ main([args, port]) async {
testBadResolvePackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var badPackageUri = Uri.parse("package:asdf/qwerty.dart");
var resolvedPkg = await Isolate.resolvePackageUri(badPackageUri);
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -9,8 +9,8 @@
import 'dart:io';
import 'dart:isolate';
import "package:foo/foo.dart";
import "package:bar/bar.dart";
import "package:foo/foo.dart";
var CONFIG_URI = "package:bar/spawned_packages/";
@ -20,8 +20,7 @@ main([args, port]) async {
return;
}
var p = new RawReceivePort();
Isolate.spawnUri(Platform.script, [], p.sendPort,
packageRoot: Uri.parse(CONFIG_URI));
Isolate.spawnUri(Platform.script, [], p.sendPort);
p.handler = (msg) {
p.close();
if (msg is! List) {
@ -47,11 +46,9 @@ main([args, port]) async {
testCorrectBarPackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(CONFIG_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");

View file

@ -47,11 +47,9 @@ main([args, port]) async {
testCorrectBarPackage(port) async {
try {
var packageRootStr = Platform.packageRoot;
var packageConfigStr = Platform.packageConfig;
var packageConfig = await Isolate.packageConfig;
var resolvedPkg = await Isolate.resolvePackageUri(Uri.parse(CONFIG_URI));
print("Spawned isolate's package root flag: $packageRootStr");
print("Spawned isolate's package config flag: $packageConfigStr");
print("Spawned isolate's loaded package config: $packageConfig");
print("Spawned isolate's resolved package path: $resolvedPkg");