Skip to content

Commit cac00e9

Browse files
mit-mitcommit-bot@chromium.org
authored andcommitted
Add deprecations notices to dart2native
Related to: #46100 Change-Id: I2bcd4aadfbc96fa6ba265aec04cd60e3e81eef41 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199429 Commit-Queue: Michael Thomsen <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Reviewed-by: Ben Konyi <[email protected]> Reviewed-by: Devon Carew <[email protected]>
1 parent 93f8558 commit cac00e9

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@
5050

5151
#### Dart command line
5252

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

sdk/bin/dart2native

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
# Run dart2native.dart.snapshot on the Dart VM
77

8+
echo "Warning: 'dart2native' is deprecated. Please use 'dart compile exe'." 1>&2
9+
810
function follow_links() {
911
file="$1"
1012
while [ -h "$file" ]; do

sdk/bin/dart2native.bat

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ REM Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
33
REM for details. All rights reserved. Use of this source code is governed by a
44
REM BSD-style license that can be found in the LICENSE file.
55

6+
echo Warning: 'dart2native' is deprecated. Please use 'dart compile exe'. 1>&2
7+
68
setlocal
79
rem Handle the case where dart-sdk/bin has been symlinked to.
810
set DIR_NAME_WITH_SLASH=%~dp0

tools/bots/aot_smoke_tests.dart

+13-14
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import 'package:path/path.dart' as path;
1515
import 'package:test/test.dart';
1616

1717
final String newline = Platform.isWindows ? '\r\n' : '\n';
18-
final String scriptSuffix = Platform.isWindows ? ".bat" : "";
1918
final String executableSuffix = Platform.isWindows ? ".exe" : "";
2019
final String sdkBinDir = path.dirname(Platform.executable);
2120
final String dartaotruntime =
2221
path.join(sdkBinDir, 'dartaotruntime${executableSuffix}');
23-
final String dart2native = path.join(sdkBinDir, 'dart2native${scriptSuffix}');
22+
final String dart = path.join(sdkBinDir, 'dart${executableSuffix}');
2423

2524
Future<void> withTempDir(Future fun(String dir)) async {
2625
final Directory tempDir = Directory.systemTemp.createTempSync();
@@ -32,14 +31,14 @@ Future<void> withTempDir(Future fun(String dir)) async {
3231
}
3332

3433
void main(List<String> args) {
35-
test("dart2native: Can compile and run AOT", () async {
34+
test("Dart native: Can compile and run AOT snapshot", () async {
3635
await withTempDir((String tmp) async {
3736
final String testCode = path.join('tools', 'bots', 'dart_aot_test.dart');
3837
final String tmpAot = path.join(tmp, 'dart_aot_test.aot');
3938

4039
{
41-
final ProcessResult result = await Process.run(dart2native,
42-
[testCode, '--output', tmpAot, '--output-kind', 'aot']);
40+
final ProcessResult result = await Process.run(
41+
dart, ['compile', 'aot-snapshot', testCode, '--output', tmpAot]);
4342
expect(result.stderr, '');
4443
expect(result.exitCode, 0);
4544
}
@@ -55,14 +54,14 @@ void main(List<String> args) {
5554
});
5655
});
5756

58-
test("dart2native: Can compile and run exe", () async {
57+
test("Dart native: Can compile and run exe", () async {
5958
await withTempDir((String tmp) async {
6059
final String testCode = path.join('tools', 'bots', 'dart_aot_test.dart');
6160
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
6261

6362
{
64-
final ProcessResult result =
65-
await Process.run(dart2native, [testCode, '--output', tmpExe]);
63+
final ProcessResult result = await Process.run(
64+
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
6665
expect(result.stderr, '');
6766
expect(result.exitCode, 0);
6867
}
@@ -77,27 +76,27 @@ void main(List<String> args) {
7776
});
7877
});
7978

80-
test("dart2native: Returns non-zero on missing file.", () async {
79+
test("Dart native: Returns non-zero on missing file.", () async {
8180
await withTempDir((String tmp) async {
8281
final String testCode = path.join(tmp, 'does_not_exist.dart');
8382
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
8483

8584
{
86-
final ProcessResult result =
87-
await Process.run(dart2native, [testCode, '--output', tmpExe]);
85+
final ProcessResult result = await Process.run(
86+
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
8887
expect(result.exitCode, isNonZero);
8988
}
9089
});
9190
});
9291

93-
test("dart2native: Returns non-zero on non-file.", () async {
92+
test("Dart native: Returns non-zero on non-file.", () async {
9493
await withTempDir((String tmp) async {
9594
final String testCode = tmp; // This is a directory, not a file.
9695
final String tmpExe = path.join(tmp, 'dart_aot_test.exe');
9796

9897
{
99-
final ProcessResult result =
100-
await Process.run(dart2native, [testCode, '--output', tmpExe]);
98+
final ProcessResult result = await Process.run(
99+
dart, ['compile', 'exe', testCode, '--output', tmpExe]);
101100
expect(result.exitCode, isNonZero);
102101
}
103102
});

tools/bots/dart_aot_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// for details. All rights reserved. Use of this source code is governed by a
44
// BSD-style license that can be found in the LICENSE file.
55

6-
// Test program for Dart AOT (dart2native, dartaotruntime).
6+
// Test program for Dart AOT (dart compile, dartaotruntime).
77

88
void main(List<String> args) async {
99
final String who = !args.isEmpty ? args[0] : '世界';

0 commit comments

Comments
 (0)