Add deprecations notices to dart2native

Related to: https://github.com/dart-lang/sdk/issues/46100

Change-Id: I2bcd4aadfbc96fa6ba265aec04cd60e3e81eef41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199429
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
This commit is contained in:
Michael Thomsen 2021-05-25 13:20:30 +00:00 committed by commit-bot@chromium.org
parent 93f8558cb2
commit cac00e9d95
5 changed files with 27 additions and 16 deletions

View file

@ -50,7 +50,15 @@
#### Dart command line
- The `dart create` command has been updated to create projects that use the new
* **Breaking Change** [#46100][]: The standalone `dart2native` has been marked
deprecated, and now prints a warning message. It's replacement is the `dart
compile exe` and `dart compile aot-snapshot` commands, which offer the same
functionality. The `dart2native` tool will be discontinued (removed from the
Dart SDK) in Dart 2.15.
https://github.com/dart-lang/sdk/issues/46100
* The `dart create` command has been updated to create projects that use the new
'core' set of lints from `package:lints`. See https://dart.dev/go/core-lints
for more information about these lints.

View file

@ -5,6 +5,8 @@
# Run dart2native.dart.snapshot on the Dart VM
echo "Warning: 'dart2native' is deprecated. Please use 'dart compile exe'." 1>&2
function follow_links() {
file="$1"
while [ -h "$file" ]; do

View file

@ -3,6 +3,8 @@ REM Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
REM for details. All rights reserved. Use of this source code is governed by a
REM BSD-style license that can be found in the LICENSE file.
echo Warning: 'dart2native' is deprecated. Please use 'dart compile exe'. 1>&2
setlocal
rem Handle the case where dart-sdk/bin has been symlinked to.
set DIR_NAME_WITH_SLASH=%~dp0

View file

@ -15,12 +15,11 @@ import 'package:path/path.dart' as path;
import 'package:test/test.dart';
final String newline = Platform.isWindows ? '\r\n' : '\n';
final String scriptSuffix = Platform.isWindows ? ".bat" : "";
final String executableSuffix = Platform.isWindows ? ".exe" : "";
final String sdkBinDir = path.dirname(Platform.executable);
final String dartaotruntime =
path.join(sdkBinDir, 'dartaotruntime${executableSuffix}');
final String dart2native = path.join(sdkBinDir, 'dart2native${scriptSuffix}');
final String dart = path.join(sdkBinDir, 'dart${executableSuffix}');
Future<void> withTempDir(Future fun(String dir)) async {
final Directory tempDir = Directory.systemTemp.createTempSync();
@ -32,14 +31,14 @@ Future<void> withTempDir(Future fun(String dir)) async {
}
void main(List<String> args) {
test("dart2native: Can compile and run AOT", () async {
test("Dart native: Can compile and run AOT snapshot", () async {
await withTempDir((String tmp) async {
final String testCode = path.join('tools', 'bots', 'dart_aot_test.dart');
final String tmpAot = path.join(tmp, 'dart_aot_test.aot');
{
final ProcessResult result = await Process.run(dart2native,
[testCode, '--output', tmpAot, '--output-kind', 'aot']);
final ProcessResult result = await Process.run(
dart, ['compile', 'aot-snapshot', testCode, '--output', tmpAot]);
expect(result.stderr, '');
expect(result.exitCode, 0);
}
@ -55,14 +54,14 @@ void main(List<String> args) {
});
});
test("dart2native: Can compile and run exe", () async {
test("Dart native: Can compile and run exe", () async {
await withTempDir((String tmp) async {
final String testCode = path.join('tools', 'bots', 'dart_aot_test.dart');
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
{
final ProcessResult result =
await Process.run(dart2native, [testCode, '--output', tmpExe]);
final ProcessResult result = await Process.run(
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
expect(result.stderr, '');
expect(result.exitCode, 0);
}
@ -77,27 +76,27 @@ void main(List<String> args) {
});
});
test("dart2native: Returns non-zero on missing file.", () async {
test("Dart native: Returns non-zero on missing file.", () async {
await withTempDir((String tmp) async {
final String testCode = path.join(tmp, 'does_not_exist.dart');
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
{
final ProcessResult result =
await Process.run(dart2native, [testCode, '--output', tmpExe]);
final ProcessResult result = await Process.run(
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
expect(result.exitCode, isNonZero);
}
});
});
test("dart2native: Returns non-zero on non-file.", () async {
test("Dart native: Returns non-zero on non-file.", () async {
await withTempDir((String tmp) async {
final String testCode = tmp; // This is a directory, not a file.
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
{
final ProcessResult result =
await Process.run(dart2native, [testCode, '--output', tmpExe]);
final ProcessResult result = await Process.run(
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
expect(result.exitCode, isNonZero);
}
});

View file

@ -3,7 +3,7 @@
// 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.
// Test program for Dart AOT (dart2native, dartaotruntime).
// Test program for Dart AOT (dart compile, dartaotruntime).
void main(List<String> args) async {
final String who = !args.isEmpty ? args[0] : '世界';