Skip to content

Commit

Permalink
Add deprecations notices to dart2native
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mit-mit authored and [email protected] committed May 25, 2021
1 parent 93f8558 commit cac00e9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions sdk/bin/dart2native
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sdk/bin/dart2native.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions tools/bots/aot_smoke_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tools/bots/dart_aot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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] : '世界';
Expand Down

0 comments on commit cac00e9

Please sign in to comment.