mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:21:54 +00:00
Modify dartanalyzer scripts to look more like dart2js scripts.
The dartanalyzer script (and its Windows companion, dartanalyzer.bat) now support: - Executing from snapshot if present, otherwise from source (needed for buildbot tests). - Passing in the appropriate package root when executind from source. - Passing in VM tuning parameters to speed up analysis. - Passing through extra DART_VM_OPTIONS to the VM. Also, the old editor/tools/analyzer script has been removed and the test infrastructure now uses sdk/bin/dartanalyzer, in the same way that it works for dart2js. R=ahe@google.com, johnniwinther@google.com, ricow@google.com Review URL: https://codereview.chromium.org//628363002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41150 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
33c65f8fc6
commit
b9116653bd
|
@ -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.
|
||||
|
||||
# Run dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's
|
||||
# Run dartanalyzer.dart on the Dart VM. This script assumes the Dart repo's
|
||||
# directory structure.
|
||||
|
||||
function follow_links() {
|
||||
|
@ -24,8 +24,38 @@ SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)"
|
|||
|
||||
SDK_ARG="--dart-sdk=$SDK_DIR"
|
||||
|
||||
SNAPSHOT="$BIN_DIR/snapshots/dartanalyzer.dart.snapshot"
|
||||
|
||||
# We are running the snapshot in the built SDK.
|
||||
DART="$BIN_DIR/dart"
|
||||
exec "$DART" "$SNAPSHOT" "$SDK_ARG" "$@"
|
||||
|
||||
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)"
|
||||
|
||||
ANALYZER="$DART_ROOT/pkg/analyzer/bin/analyzer.dart"
|
||||
|
||||
if [ -z "$DART_CONFIGURATION" ];
|
||||
then
|
||||
DART_CONFIGURATION="ReleaseIA32"
|
||||
fi
|
||||
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
BUILD_DIR="$DART_ROOT/xcodebuild/$DART_CONFIGURATION"
|
||||
else
|
||||
BUILD_DIR="$DART_ROOT/out/$DART_CONFIGURATION"
|
||||
fi
|
||||
|
||||
PACKAGE_ROOT="$BUILD_DIR/packages/"
|
||||
|
||||
exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "--package-root=$PACKAGE_ROOT" "$ANALYZER" "$SDK_ARG" "$@"
|
||||
|
|
|
@ -12,7 +12,6 @@ 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\dartanalyzer.dart.snapshot
|
||||
|
||||
rem Get absolute full name for SDK_DIR.
|
||||
for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi
|
||||
|
@ -22,7 +21,33 @@ if %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1%
|
|||
|
||||
set SDK_ARG=--dart-sdk=%SDK_DIR%
|
||||
|
||||
"%DART%" "%SNAPSHOT%" "%SDK_ARG%" %*
|
||||
set EXTRA_VM_OPTIONS=
|
||||
|
||||
if _%DARTANALYZER_DEVELOPER_MODE%_ == _1_ (
|
||||
set EXTRA_VM_OPTIONS=%EXTRA_VM_OPTIONS% --checked
|
||||
)
|
||||
|
||||
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 ANALYZER=%DART_ROOT%\pkg\analyzer\bin\analyzer.dart
|
||||
|
||||
rem DART_CONFIGURATION defaults to ReleaseIA32
|
||||
if "%DART_CONFIGURATION%"=="" set DART_CONFIGURATION=ReleaseIA32
|
||||
|
||||
set BUILD_DIR=%DART_ROOT%\build\%DART_CONFIGURATION%
|
||||
|
||||
set PACKAGE_ROOT=%BUILD_DIR%\packages
|
||||
|
||||
"%DART%" %EXTRA_VM_OPTIONS% "--package-root=%PACKAGE_ROOT%" "%ANALYZER%" "%SDK_ARG%" %*
|
||||
|
||||
endlocal
|
||||
|
||||
|
|
31
sdk/bin/dartanalyzer_sdk
Executable file
31
sdk/bin/dartanalyzer_sdk
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/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 dartanalyzer.dart 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/dartanalyzer.dart.snapshot"
|
||||
|
||||
# We are running the snapshot in the built SDK.
|
||||
DART="$BIN_DIR/dart"
|
||||
exec "$DART" "$SNAPSHOT" "$SDK_ARG" "$@"
|
52
sdk/bin/dartanalyzer_sdk.bat
Normal file
52
sdk/bin/dartanalyzer_sdk.bat
Normal file
|
@ -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\dartanalyzer.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 <JUNCTION> 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
|
|
@ -112,7 +112,8 @@ def CopyShellScript(src_file, dest_dir):
|
|||
|
||||
|
||||
def CopyDartScripts(home, sdk_root):
|
||||
for executable in ['dart2js', 'dartanalyzer', 'dartfmt', 'docgen', 'pub_sdk']:
|
||||
for executable in ['dart2js', 'dartanalyzer_sdk', 'dartfmt', 'docgen',
|
||||
'pub_sdk']:
|
||||
CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
|
||||
os.path.join(sdk_root, 'bin'))
|
||||
|
||||
|
|
|
@ -392,5 +392,24 @@ class DartBasedAnalyzerCompilerConfiguration
|
|||
'dart2analyzer', isDebug: isDebug, isChecked: isChecked,
|
||||
isHostChecked: isHostChecked, useSdk: useSdk);
|
||||
|
||||
String computeCompilerPath(String buildDir) => 'editor/tools/analyzer';
|
||||
String computeCompilerPath(String buildDir) {
|
||||
var prefix = 'sdk/bin';
|
||||
String suffix = executableScriptSuffix;
|
||||
if (isHostChecked) {
|
||||
if (useSdk) {
|
||||
throw "--host-checked and --use-sdk cannot be used together";
|
||||
}
|
||||
// The script dartanalyzer_developer is not included in the
|
||||
// shipped SDK, that is the script is not installed in
|
||||
// "$buildDir/dart-sdk/bin/"
|
||||
// TODO(paulberry): the script dartanalyzer_developer currently
|
||||
// points to the wrong place (the Java-based analyzer). Once
|
||||
// this is fixed, we should run dartanalyzer_developer when in
|
||||
// isHostChecked mode.
|
||||
}
|
||||
if (useSdk) {
|
||||
prefix = '$buildDir/dart-sdk/bin';
|
||||
}
|
||||
return '$prefix/dartanalyzer$suffix';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue