diff --git a/DEPS b/DEPS index 9ed1e3ae01d..e0a16f3e689 100644 --- a/DEPS +++ b/DEPS @@ -41,7 +41,7 @@ vars = { "dartdoc_tag" : "@v0.9.0", "dart_services_rev" : "@7aea2574e6f3924bf409a80afb8ad52aa2be4f97", "dart_style_tag": "@0.2.4", - "dev_compiler_rev": "@0.1.9", + "dev_compiler_rev": "@0c5dd2d1e999c421d978a478e267aac6279e087a", "glob_rev": "@704cf75e4f26b417505c5c611bdaacd8808467dd", "html_tag" : "@0.12.1+1", "http_tag" : "@0.11.3+3", diff --git a/create_sdk.gyp b/create_sdk.gyp index b13addacb11..83ddc47f303 100644 --- a/create_sdk.gyp +++ b/create_sdk.gyp @@ -15,6 +15,7 @@ 'utils/dartdoc/dartdoc.gyp:dartdoc', 'utils/analysis_server/analysis_server.gyp:analysis_server', 'utils/dartanalyzer/dartanalyzer.gyp:dartanalyzer', + 'utils/dartdevc/dartdevc.gyp:dartdevc', ], 'actions': [ { @@ -38,6 +39,7 @@ '<(SHARED_INTERMEDIATE_DIR)/utils_wrapper.dart.snapshot', '<(SHARED_INTERMEDIATE_DIR)/pub.dart.snapshot', '<(SHARED_INTERMEDIATE_DIR)/dartanalyzer.dart.snapshot', + '<(SHARED_INTERMEDIATE_DIR)/dartdevc.dart.snapshot', '<(SHARED_INTERMEDIATE_DIR)/dartfmt.dart.snapshot', '<(SHARED_INTERMEDIATE_DIR)/analysis_server.dart.snapshot', '<(SHARED_INTERMEDIATE_DIR)/dartdoc.dart.snapshot', diff --git a/dart.gyp b/dart.gyp index 9ac4105dade..b8d3e43f99e 100644 --- a/dart.gyp +++ b/dart.gyp @@ -12,6 +12,7 @@ 'create_sdk', 'dart2js', 'dartanalyzer', + 'dartdevc', 'packages', 'runtime', 'samples', @@ -57,6 +58,13 @@ 'utils/dartanalyzer/dartanalyzer.gyp:dartanalyzer', ], }, + { + 'target_name': 'dartdevc', + 'type': 'none', + 'dependencies': [ + 'utils/dartdevc/dartdevc.gyp:dartdevc', + ], + }, { 'target_name': 'dartfmt', 'type': 'none', diff --git a/sdk/bin/dartdevc b/sdk/bin/dartdevc new file mode 100755 index 00000000000..331eb4ef395 --- /dev/null +++ b/sdk/bin/dartdevc @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# Copyright (c) 2013, 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 dev compiler on the Dart VM. This script assumes the Dart repo's +# directory structure. + +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)" +SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" + +SDK_ARG="--dart-sdk=$SDK_DIR" + +DART="$BIN_DIR/dart" + +unset EXTRA_VM_OPTIONS +declare -a EXTRA_VM_OPTIONS + +case $0 in + *_developer) + EXTRA_VM_OPTIONS+=('--checked') + ;; +esac + +# We allow extra vm options to be passed in through an environment variable. +if [[ $DART_VM_OPTIONS ]]; then + read -a OPTIONS <<< "$DART_VM_OPTIONS" + EXTRA_VM_OPTIONS+=("${OPTIONS[@]}") +fi + +DART_ROOT="$(cd "${SDK_DIR}/.." ; pwd -P)" + +DEV_COMPILER="$DART_ROOT/third_party/pkg/dev_compiler/bin/dartdevc.dart" + +if [[ `uname` == 'Darwin' ]]; +then + OUT_DIR="$DART_ROOT/xcodebuild/" +else + OUT_DIR="$DART_ROOT/out/" +fi + +if [ -z "$DART_CONFIGURATION" ]; +then + DIRS=$( ls "$OUT_DIR" ) + # list of possible configurations in decreasing desirability + CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32" + "ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE" "ReleaseMIPS" + "DebugARM" "DebugARM64" "DebugARMV5TE" "DebugMIPS") + DART_CONFIGURATION="None" + for CONFIG in ${CONFIGS[*]} + do + for DIR in $DIRS; + do + if [ "$CONFIG" = "$DIR" ]; + then + # choose most desirable configuration that is available and break + DART_CONFIGURATION="$DIR" + break 2 + fi + done + done + if [ "$DART_CONFIGURATION" = "None" ] + then + echo "No valid dart configuration found in $OUT_DIR" + exit 1 + fi +fi + +BUILD_DIR="$OUT_DIR$DART_CONFIGURATION" + +PACKAGE_ROOT="$BUILD_DIR/packages/" + +exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$DEV_COMPILER" "$SDK_ARG" "$@" diff --git a/sdk/bin/dartdevc.bat b/sdk/bin/dartdevc.bat new file mode 100644 index 00000000000..4e0200528b0 --- /dev/null +++ b/sdk/bin/dartdevc.bat @@ -0,0 +1,73 @@ +@echo off +REM Copyright (c) 2013, 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 + +rem Get absolute full name for SDK_DIR. +for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi + +rem Remove trailing backslash if there is one +if %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1% + +set SDK_ARG=--dart-sdk=%SDK_DIR% + +set EXTRA_VM_OPTIONS= + +rem We allow extra vm options to be passed in through an environment variable. +if not "_%DART_VM_OPTIONS%_" == "__" ( + set EXTRA_VM_OPTIONS=%EXTRA_VM_OPTIONS% %DART_VM_OPTIONS% +) + +rem Get absolute full name for DART_ROOT. +for %%i in ("%SDK_DIR%\..\") do set DART_ROOT=%%~fi + +rem Remove trailing backslash if there is one +if %DART_ROOT:~-1%==\ set DART_ROOT=%DART_ROOT:~0,-1% + +set DEV_COMPILER=%DART_ROOT%\third_party\pkg\dev_compiler\bin\dartdevc.dart + +rem DART_CONFIGURATION defaults to ReleaseX64 +if "%DART_CONFIGURATION%"=="" set DART_CONFIGURATION=ReleaseX64 + +set BUILD_DIR=%DART_ROOT%\build\%DART_CONFIGURATION% + +set PACKAGE_ROOT=%BUILD_DIR%\packages + +"%DART%" %EXTRA_VM_OPTIONS% "--package-root=%PACKAGE_ROOT%" "DEV_COMPILER%" "%SDK_ARG%" %* + +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\build\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 ^ + ^| find "> %~n1 ["`) do ( + set current=%%i +) +if not "%current%"=="" call :follow_links "%current%", result +endlocal & set %~2=%result% +goto :eof + +:end diff --git a/sdk/bin/dartdevc_sdk b/sdk/bin/dartdevc_sdk new file mode 100755 index 00000000000..7bc98dea599 --- /dev/null +++ b/sdk/bin/dartdevc_sdk @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Copyright (c) 2013, 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 dev compiler on the Dart VM. This script assumes the Dart SDK's +# directory structure. + +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)" +SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" + +SDK_ARG="--dart-sdk=$SDK_DIR" + +SNAPSHOT="$BIN_DIR/snapshots/dartdevc.dart.snapshot" + +# We are running the snapshot in the built SDK. +DART="$BIN_DIR/dart" +exec "$DART" "$SNAPSHOT" "$SDK_ARG" "$@" diff --git a/sdk/bin/dartdevc_sdk.bat b/sdk/bin/dartdevc_sdk.bat new file mode 100644 index 00000000000..72c20691474 --- /dev/null +++ b/sdk/bin/dartdevc_sdk.bat @@ -0,0 +1,52 @@ +@echo off +REM Copyright (c) 2013, 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 +set SNAPSHOT=%BIN_DIR%\snapshots\dartdevc.dart.snapshot + +rem Get absolute full name for SDK_DIR. +for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi + +rem Remove trailing backslash if there is one +if %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1% + +set SDK_ARG=--dart-sdk=%SDK_DIR% + +"%DART%" "%SNAPSHOT%" "%SDK_ARG%" %* + +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\build\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 ^ + ^| find "> %~n1 ["`) do ( + set current=%%i +) +if not "%current%"=="" call :follow_links "%current%", result +endlocal & set %~2=%result% +goto :eof + +:end diff --git a/tools/create_sdk.py b/tools/create_sdk.py index 0d72c9d9350..65f585e055f 100755 --- a/tools/create_sdk.py +++ b/tools/create_sdk.py @@ -19,6 +19,7 @@ # ......dartfmt # ......dart2js # ......dartanalyzer +# ......dartdevc # ......pub # ......snapshots/ # ........analysis_server.dart.snapshot @@ -26,6 +27,7 @@ # ........dartanalyzer.dart.snapshot # ........dartdoc.dart.snapshot # ........dartfmt.dart.snapshot +# ........dartdevc.dart.snapshot # ........pub.dart.snapshot # ........utils_wrapper.dart.snapshot #.........resources/ @@ -129,14 +131,14 @@ def CopyShellScript(src_file, dest_dir): def CopyDartScripts(home, sdk_root): for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt_sdk', - 'pub_sdk', 'dartdoc']: + 'pub_sdk', 'dartdoc', 'dartdevc_sdk']: CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), os.path.join(sdk_root, 'bin')) def CopySnapshots(snapshots, sdk_root): for snapshot in ['analysis_server', 'dart2js', 'dartanalyzer', 'dartfmt', - 'utils_wrapper', 'pub', 'dartdoc']: + 'utils_wrapper', 'pub', 'dartdoc', 'dartdevc']: snapshot += '.dart.snapshot' copyfile(join(snapshots, snapshot), join(sdk_root, 'bin', 'snapshots', snapshot)) diff --git a/utils/dartdevc/dartdevc.gyp b/utils/dartdevc/dartdevc.gyp new file mode 100644 index 00000000000..60e3f65ef2d --- /dev/null +++ b/utils/dartdevc/dartdevc.gyp @@ -0,0 +1,37 @@ +# 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. + +{ + 'targets': [ + { + 'target_name': 'dartdevc', + 'type': 'none', + 'dependencies': [ + '../../runtime/dart-runtime.gyp:dart', + '../../pkg/pkg.gyp:pkg_packages', + ], + 'actions': [ + { + 'action_name': 'generate_dartdevc_snapshot', + 'inputs': [ + '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)', + '../../sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart', + '