From cac00e9d956a6f7ef28628989912d971f6b908d4 Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Tue, 25 May 2021 13:20:30 +0000 Subject: [PATCH] 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 Reviewed-by: Martin Kustermann Reviewed-by: Ben Konyi Reviewed-by: Devon Carew --- CHANGELOG.md | 10 +++++++++- sdk/bin/dart2native | 2 ++ sdk/bin/dart2native.bat | 2 ++ tools/bots/aot_smoke_tests.dart | 27 +++++++++++++-------------- tools/bots/dart_aot_test.dart | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74f84b3f5f8..f8c7ddd1c209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/sdk/bin/dart2native b/sdk/bin/dart2native index 057490f10215..6f59f3f9d800 100755 --- a/sdk/bin/dart2native +++ b/sdk/bin/dart2native @@ -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 diff --git a/sdk/bin/dart2native.bat b/sdk/bin/dart2native.bat index 631dce8d0806..ca4d8d710df2 100644 --- a/sdk/bin/dart2native.bat +++ b/sdk/bin/dart2native.bat @@ -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 diff --git a/tools/bots/aot_smoke_tests.dart b/tools/bots/aot_smoke_tests.dart index b9a035e5688a..406fb087a0a5 100755 --- a/tools/bots/aot_smoke_tests.dart +++ b/tools/bots/aot_smoke_tests.dart @@ -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 withTempDir(Future fun(String dir)) async { final Directory tempDir = Directory.systemTemp.createTempSync(); @@ -32,14 +31,14 @@ Future withTempDir(Future fun(String dir)) async { } void main(List 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 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 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); } }); diff --git a/tools/bots/dart_aot_test.dart b/tools/bots/dart_aot_test.dart index a1657c160e72..9449b274c2a3 100755 --- a/tools/bots/dart_aot_test.dart +++ b/tools/bots/dart_aot_test.dart @@ -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 args) async { final String who = !args.isEmpty ? args[0] : '世界';