From 54fdd559d805cfa43bb970d14ea471ac3a3a582e Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 4 Sep 2019 00:40:20 +0000 Subject: [PATCH] Revert "Add dart2native tool for building either an aot file or a stand-alone executable." This reverts commit a6141ff5c908aaf09fdd192c472bab0c3f4f1070. Reason for revert: Blocking Dart SDK -> Flutter engine roll. See logs here: https://github.com/flutter/engine/pull/11836/checks?check_run_id=210988794 Original change's description: > Add dart2native tool for building either an aot file or a stand-alone executable. > > *dart2aot has been rewritten in Dart accompanied by a trampoline script. > *dart2exec is still missing implementation. > > Change-Id: I4b662ce86c7365fa4d043b48a691881c8ef08a8c > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108601 > Commit-Queue: Sarah Zakarias > Reviewed-by: Clement Skau TBR=cskau@google.com,zarah@google.com Change-Id: I4c5946ce0f0a66484e243b98cdcb7e2b24e2d705 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115340 Reviewed-by: Ben Konyi Commit-Queue: Ben Konyi --- pkg/dart2native/bin/dart2aot.dart | 81 ---------------------------- pkg/dart2native/bin/dart2native.dart | 70 ------------------------ pkg/dart2native/pubspec.yaml | 16 ------ sdk/BUILD.gn | 26 --------- sdk/bin/dart2native | 25 --------- sdk/bin/dart2native.bat | 43 --------------- utils/dart2native/BUILD.gn | 19 ------- 7 files changed, 280 deletions(-) delete mode 100644 pkg/dart2native/bin/dart2aot.dart delete mode 100644 pkg/dart2native/bin/dart2native.dart delete mode 100644 pkg/dart2native/pubspec.yaml delete mode 100755 sdk/bin/dart2native delete mode 100644 sdk/bin/dart2native.bat delete mode 100644 utils/dart2native/BUILD.gn diff --git a/pkg/dart2native/bin/dart2aot.dart b/pkg/dart2native/bin/dart2aot.dart deleted file mode 100644 index b406184475d..00000000000 --- a/pkg/dart2native/bin/dart2aot.dart +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env dart -// Copyright (c) 2019, 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 'package:args/args.dart'; -import 'package:path/path.dart'; - -const clearLine = '\r\x1b[2K'; - -void aot(String sourceFile, String snapshotFile, bool enableAsserts, - bool buildElf, bool tfa, bool noTfa, String packages, List ds) { - if (!FileSystemEntity.isFileSync(sourceFile)) { - print('Error: $sourceFile is not a file'); - return; - } - - String genSnapshotOption = buildElf - ? '--snapshot-kind=app-aot-assembly' - : '--snapshot-kind=app-aot-blobs'; - String genSnapshotFilename = buildElf - ? '--assembly=$snapshotFile.S' - : '--blobs_container_filename=$snapshotFile'; - - String snapDir = dirname(Platform.script.path); - String binDir = canonicalize(join(snapDir, '..')); - String sdkDir = canonicalize(join(binDir, '..')); - String dartCommand = join(binDir, 'dart'); - String snapshot = join(snapDir, 'gen_kernel.dart.snapshot'); - - stdout.write('${clearLine}Generating AOT snapshot'); - List dartArgs = [ - snapshot, - '--platform', - '${sdkDir}//lib/_internal/vm_platform_strong.dill', - '--aot', - '-Ddart.vm.product=true', - if (tfa) '--tfa', - if (noTfa) '--no-tfa', - ...ds, - if (packages != null) ...['--packages', packages], - '-o', - '$snapshotFile.dill', - sourceFile - ]; - - var cmdResult = Process.runSync(dartCommand, dartArgs); - if (cmdResult.exitCode != 0) { - print('\nGenerating AOT snapshot failed\n'); - print(cmdResult.stdout); - print(cmdResult.stderr); - return; - } - - stdout.write("${clearLine}Generating AOT .dill"); - String genSnapshotCommand = join(binDir, 'utils', 'gen_snapshot'); - List genSnapshotArgs = [ - genSnapshotOption, - genSnapshotFilename, - if (enableAsserts) '--enable-asserts', - '$snapshotFile.dill' - ]; - cmdResult = Process.runSync(genSnapshotCommand, genSnapshotArgs); - if (cmdResult.exitCode != 0) { - print('\nGenerating AOT .dill failed\n'); - print(cmdResult.stdout); - print(cmdResult.stderr); - return; - } - stdout.write("${clearLine}Done.\n"); - stdout.flush(); -} - -void setupAOTArgs(ArgParser parser) { - parser.addFlag('build-elf'); - parser.addFlag('enable-asserts'); - parser.addFlag('tfa'); - parser.addFlag('no-tfa'); - parser.addOption('packages'); -} diff --git a/pkg/dart2native/bin/dart2native.dart b/pkg/dart2native/bin/dart2native.dart deleted file mode 100644 index ac9cf354808..00000000000 --- a/pkg/dart2native/bin/dart2native.dart +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env dart -// Copyright (c) 2019, 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 'package:args/args.dart'; -import 'dart2aot.dart'; - -typedef void Command(ArgResults args, List ds); - -void main(List args) { - Map commands = {}; - commands['aot'] = callAOT; - - // Read -D args that the ArgParser can't handle. - List ds = []; - args = filterDArgs(args, ds); - - ArgParser parser = ArgParser(); - parser.addFlag('help'); - ArgParser aotParser = parser.addCommand('aot'); - setupAOTArgs(aotParser); - - ArgResults result = null; - try { - result = parser.parse(args); - } catch (ArgParserException) { - // We handle this case as result == null below. - } - - if (result == null || result.command == null || result['help']) { - print('dart2native \n'); - print(' command: '); - print(' aot - Compile script into one ahead of time dart snapshot'); - return; - } - - if (commands.containsKey(result.command.name)) { - commands[result.command.name](result.command, ds); - return; - } -} - -void callAOT(ArgResults args, List ds) { - List rest = args.rest; - if (rest.length != 2) { - print( - 'Usage: dart2native aot [options] \n'); - print( - 'Dart AOT (ahead-of-time) compile Dart source code into native machine code.'); - return; - } - - aot(rest[0], rest[1], args['build-elf'], args['enable-asserts'], args['tfa'], - args['no-tfa'], args['packages'], ds); -} - -List filterDArgs(List args, List ds) { - List result = []; - - args.forEach((String arg) { - if (!arg.startsWith('-D')) { - result.add(arg); - } else { - ds.add(arg); - } - }); - - return result; -} diff --git a/pkg/dart2native/pubspec.yaml b/pkg/dart2native/pubspec.yaml deleted file mode 100644 index be267fc4206..00000000000 --- a/pkg/dart2native/pubspec.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: dart2native -version: 0.0.1 -author: Dart Team -homepage: https://github.com/dart-lang/sdk/tree/master/pkg/aot - - -# Add the bin/dart2native.dart script to the scripts pub installs. -executables: - dart2native: - -dependencies: - args: ^1.4.0 - path: - -dev_dependencies: - diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 818906b98b5..19afbe542d1 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -116,10 +116,6 @@ _platform_sdk_snapshots = [ "dartanalyzer", "../utils/dartanalyzer:generate_dartanalyzer_snapshot", ], - [ - "dart2native", - "../utils/dart2native:generate_dart2native_snapshot", - ], [ "dartdoc", "../utils/dartdoc", @@ -159,10 +155,6 @@ _full_sdk_snapshots = [ "dartanalyzer", "../utils/dartanalyzer:generate_dartanalyzer_snapshot", ], - [ - "dart2native", - "../utils/dart2native:generate_dart2native_snapshot", - ], [ "dartdevc", "../utils/dartdevc", @@ -452,23 +444,6 @@ copy("copy_dart2aot") { ] } -copy("copy_dart2native") { - deps = [ - ":copy_gen_kernel_snapshot", - ":copy_gen_snapshot", - ] - ext = "" - if (is_win) { - ext = ".bat" - } - sources = [ - "bin/dart2native$ext", - ] - outputs = [ - "$root_out_dir/dart-sdk/bin/{{source_file_part}}", - ] -} - copy("copy_gen_kernel_snapshot") { deps = [ "../utils/gen_kernel", @@ -1005,7 +980,6 @@ group("create_common_sdk") { ":copy_analysis_summaries", ":copy_api_readme", ":copy_dart", - ":copy_dart2native", ":copy_dartdoc_files", ":copy_headers", ":copy_libraries_dart", diff --git a/sdk/bin/dart2native b/sdk/bin/dart2native deleted file mode 100755 index 29f29d751f7..00000000000 --- a/sdk/bin/dart2native +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2019, 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. - -# Run dart2native.dart.snapshot on the Dart VM - -function follow_links() { - file="$1" - while [ -h "$file" ]; do - # On Mac OS, readlink -f doesn't work. - file="$(readlink "$file")" - done - echo "$file" -} - -# Unlike $0, $BASH_SOURCE points to the absolute path of this file. -PROG_NAME="$(follow_links "$BASH_SOURCE")" - -# Handle the case where dart-sdk/bin has been symlinked to. -BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" -SNAPSHOTS_DIR="${BIN_DIR}/snapshots" -DART="$BIN_DIR/dart" - -exec "$DART" "${SNAPSHOTS_DIR}/dart2native.dart.snapshot" $* diff --git a/sdk/bin/dart2native.bat b/sdk/bin/dart2native.bat deleted file mode 100644 index 631dce8d080..00000000000 --- a/sdk/bin/dart2native.bat +++ /dev/null @@ -1,43 +0,0 @@ -@echo off -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. - -setlocal -rem Handle the case where dart-sdk/bin has been symlinked to. -set DIR_NAME_WITH_SLASH=%~dp0 -set DIR_NAME=%DIR_NAME_WITH_SLASH:~0,-1%% -call :follow_links "%DIR_NAME%", RETURNED_BIN_DIR -rem Get rid of surrounding quotes. -for %%i in ("%RETURNED_BIN_DIR%") do set BIN_DIR=%%~fi - -set DART=%BIN_DIR%\dart - -"%DART%" "%BIN_DIR%\snapshots\dart2native.dart.snapshot" %* - -endlocal - -exit /b %errorlevel% - -rem Follow the symbolic links (junctions points) using `dir to determine the -rem canonical path. Output with a link looks something like this -rem -rem 01/03/2013 10:11 PM abc def -rem [c:\dart_bleeding\dart-repo.9\dart\out\ReleaseIA32\dart-sdk] -rem -rem So in the output of 'dir /a:l "targetdir"' we are looking for a filename -rem surrounded by right angle bracket and left square bracket. Once we get -rem the filename, which is name of the link, we recursively follow that. -:follow_links -setlocal -for %%i in (%1) do set result=%%~fi -set current= -for /f "usebackq tokens=2 delims=[]" %%i in (`dir /a:l "%~dp1" 2^>nul ^ - ^| %SystemRoot%\System32\find.exe "> %~n1 [" 2^>nul`) do ( - set current=%%i -) -if not "%current%"=="" call :follow_links "%current%", result -endlocal & set %~2=%result% -goto :eof - -:end diff --git a/utils/dart2native/BUILD.gn b/utils/dart2native/BUILD.gn deleted file mode 100644 index fcc4efb5a17..00000000000 --- a/utils/dart2native/BUILD.gn +++ /dev/null @@ -1,19 +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("../application_snapshot.gni") - -group("dart2native") { - deps = [ - ":generate_dart2native_snapshot", - ] -} - -application_snapshot("generate_dart2native_snapshot") { - main_dart = "../../pkg/dart2native/bin/dart2native.dart" - training_args = [ - "--help", - ] - name = "dart2native" -}