mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:59:16 +00:00
Remove dartanalyzer from built SDK.
Bug: https://github.com/dart-lang/sdk/issues/48457 Change-Id: Ic0d038299712989b8445859590ff870ce3bdc13a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249662 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Janice Collins <jcollins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
bc5a42db54
commit
822cd1cbd5
|
@ -1,5 +1,11 @@
|
|||
## 2.19.0
|
||||
|
||||
#### Dart command line
|
||||
|
||||
- **Breaking change** [#46100](https://github.com/dart-lang/sdk/issues/46100):
|
||||
The standalone `dartanalyzer` tool has been removed as previously
|
||||
announced. `dartanalyzer` is replaced by the `dart analyze` command.
|
||||
|
||||
### Language
|
||||
|
||||
- **Breaking Change** [#48167](https://github.com/dart-lang/sdk/issues/48167):
|
||||
|
|
|
@ -9,7 +9,6 @@ bin/ Binaries/scripts to compile, run, and manage Dart apps.
|
|||
dartaotruntime Minimal Dart runtime for running AOT modules
|
||||
dart2js Dart to JavaScript production compiler
|
||||
dartdevc Dart to Javascript development compiler
|
||||
dartanalyzer Dart static analyzer
|
||||
dartdoc Dart documentation generator
|
||||
|
||||
include/ header files that define the Dart embedding API for use by
|
||||
|
|
|
@ -85,7 +85,7 @@ List<String> _selectBuildTargets(Configuration inner) {
|
|||
Compiler.fasta: ['create_sdk', 'dartdevc_test', 'kernel_platform_files'],
|
||||
Compiler.dartdevk: ['dartdevc_test'],
|
||||
Compiler.dart2js: ['create_sdk'],
|
||||
Compiler.dart2analyzer: ['create_sdk'],
|
||||
Compiler.dart2analyzer: ['create_sdk', 'utils/dartanalyzer'],
|
||||
Compiler.specParser: <String>[],
|
||||
};
|
||||
final result = [...targetsForCompilers[compiler]!];
|
||||
|
|
|
@ -559,20 +559,37 @@ class BrowserTestCommand extends Command {
|
|||
}
|
||||
|
||||
class AnalysisCommand extends ProcessCommand {
|
||||
final List<String> commonAnalyzerCliArguments;
|
||||
|
||||
AnalysisCommand(String executable, List<String> arguments,
|
||||
Map<String, String> environmentOverrides, {int index = 0})
|
||||
this.commonAnalyzerCliArguments, Map<String, String> environmentOverrides,
|
||||
{int index = 0})
|
||||
: super('dart2analyzer', executable, arguments, environmentOverrides,
|
||||
null, index);
|
||||
|
||||
AnalysisCommand indexedCopy(int index) =>
|
||||
AnalysisCommand(executable, arguments, environmentOverrides,
|
||||
index: index);
|
||||
AnalysisCommand indexedCopy(int index) => AnalysisCommand(
|
||||
executable, arguments, commonAnalyzerCliArguments, environmentOverrides,
|
||||
index: index);
|
||||
|
||||
CommandOutput createOutput(int exitCode, bool timedOut, List<int> stdout,
|
||||
List<int> stderr, Duration time, bool compilationSkipped,
|
||||
[int? pid = 0]) =>
|
||||
AnalysisCommandOutput(
|
||||
this, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
|
||||
|
||||
@override
|
||||
List<String> get batchArguments => commonAnalyzerCliArguments;
|
||||
|
||||
@override
|
||||
List<String> get nonBatchArguments => commonAnalyzerCliArguments;
|
||||
|
||||
@override
|
||||
bool _equal(covariant ProcessCommand other) {
|
||||
return other is AnalysisCommand &&
|
||||
super._equal(other) &&
|
||||
deepJsonCompare(
|
||||
commonAnalyzerCliArguments, other.commonAnalyzerCliArguments);
|
||||
}
|
||||
}
|
||||
|
||||
class CompareAnalyzerCfeCommand extends ProcessCommand {
|
||||
|
|
|
@ -1188,6 +1188,7 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration {
|
|||
|
||||
int get timeoutMultiplier => 4;
|
||||
|
||||
@override
|
||||
String computeCompilerPath() {
|
||||
var prefix = 'sdk/bin';
|
||||
if (_isHostChecked) {
|
||||
|
@ -1196,31 +1197,55 @@ class AnalyzerCompilerConfiguration extends CompilerConfiguration {
|
|||
if (_useSdk) {
|
||||
prefix = '${_configuration.buildDirectory}/dart-sdk/bin';
|
||||
}
|
||||
return '$prefix/dartanalyzer$shellScriptExtension';
|
||||
return '$prefix/dart$shellScriptExtension';
|
||||
}
|
||||
|
||||
String computeAnalyzerCliPath() {
|
||||
if (_useSdk) {
|
||||
// This is a non-standard use of _useSdk, as dartanalyzer is not part
|
||||
// of the SDK anymore, but there is no way to specify "use generated
|
||||
// snapshot" directly.
|
||||
return '${_configuration.buildDirectory}/gen/dartanalyzer.dart.snapshot';
|
||||
}
|
||||
return 'pkg/analyzer_cli/bin/analyzer.dart';
|
||||
}
|
||||
|
||||
late final String compilerPath = computeCompilerPath();
|
||||
|
||||
// TODO(jcollins-g): move most of this into analyzer.dart defaults once it
|
||||
// becomes an unpublished utility.
|
||||
late final List<String> analyzerCliCommonArgs = [
|
||||
...computeDartOptions(),
|
||||
computeAnalyzerCliPath(),
|
||||
...computeDartAnalyzerOptions(),
|
||||
];
|
||||
|
||||
/// [arguments].last must be the Dart source file.
|
||||
CommandArtifact computeCompilationArtifact(String tempDir,
|
||||
List<String> arguments, Map<String, String> environmentOverrides) {
|
||||
var args = [
|
||||
...arguments,
|
||||
// Since this is not a real compilation, no artifacts are produced.
|
||||
return CommandArtifact([
|
||||
AnalysisCommand(
|
||||
compilerPath, arguments, analyzerCliCommonArgs, environmentOverrides)
|
||||
], arguments.last, 'application/vnd.dart');
|
||||
}
|
||||
|
||||
/// Arguments passed to the Dart VM.
|
||||
List<String> computeDartOptions() {
|
||||
return _useSdk ? [] : ['--packages=.dart_tool/package_config.json'];
|
||||
}
|
||||
|
||||
/// Arguments passed to the snapshot or CLI dart file.
|
||||
List<String> computeDartAnalyzerOptions() {
|
||||
return [
|
||||
// analyzer.dart requires normalized path for dart-sdk.
|
||||
if (!_useSdk) ...[
|
||||
'--use-analysis-driver-memory-byte-store',
|
||||
'--dart-sdk=${Repository.dir.absolute.join(Path('sdk'))}'
|
||||
],
|
||||
if (_configuration.useAnalyzerCfe) '--use-cfe',
|
||||
if (_configuration.useAnalyzerFastaParser) '--use-fasta-parser',
|
||||
];
|
||||
|
||||
// Since this is not a real compilation, no artifacts are produced.
|
||||
return CommandArtifact(
|
||||
[AnalysisCommand(computeCompilerPath(), args, environmentOverrides)],
|
||||
args.singleWhere((arg) => arg.endsWith('.dart')),
|
||||
'application/vnd.dart');
|
||||
}
|
||||
|
||||
List<String> computeRuntimeArguments(
|
||||
RuntimeConfiguration runtimeConfiguration,
|
||||
TestFile testFile,
|
||||
List<String> vmOptions,
|
||||
List<String> originalArguments,
|
||||
CommandArtifact? artifact) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
sdk/BUILD.gn
10
sdk/BUILD.gn
|
@ -37,13 +37,11 @@ declare_args() {
|
|||
# ......dart.lib (import library for VM native extensions on Windows)
|
||||
# ......dartaotruntime or dartaotruntime.exe (executable)
|
||||
# ......dart2js
|
||||
# ......dartanalyzer
|
||||
# ......dartdevc
|
||||
# ......utils/gen_snapshot or utils/gen_snapshot.exe (if not on ia32)
|
||||
# ......snapshots/
|
||||
# ........analysis_server.dart.snapshot
|
||||
# ........dart2js.dart.snapshot
|
||||
# ........dartanalyzer.dart.snapshot
|
||||
# ........dartdev.dart.snapshot
|
||||
# ........dartdev.dill
|
||||
# ........dartdevc.dart.snapshot
|
||||
|
@ -88,9 +86,9 @@ declare_args() {
|
|||
# ......api_readme.md
|
||||
|
||||
# Scripts that go under bin/
|
||||
_platform_sdk_scripts = [ "dartanalyzer" ]
|
||||
_platform_sdk_scripts = []
|
||||
|
||||
_full_sdk_scripts = [ "dartanalyzer" ]
|
||||
_full_sdk_scripts = []
|
||||
|
||||
# Snapshots that go under bin/snapshots
|
||||
_platform_sdk_snapshots = [
|
||||
|
@ -98,10 +96,6 @@ _platform_sdk_snapshots = [
|
|||
"analysis_server",
|
||||
"../utils/analysis_server",
|
||||
],
|
||||
[
|
||||
"dartanalyzer",
|
||||
"../utils/dartanalyzer:generate_dartanalyzer_snapshot",
|
||||
],
|
||||
[
|
||||
"dartdev",
|
||||
"../utils/dartdev:dartdev",
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
#!/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 dartanalyzer.dart on the Dart VM. This script assumes the Dart repo's
|
||||
# directory structure.
|
||||
|
||||
echo "Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'." 1>&2
|
||||
|
||||
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
|
||||
EXTRA_VM_OPTIONS+=("--enable_experiment=non-nullable")
|
||||
|
||||
case $0 in
|
||||
*_developer)
|
||||
EXTRA_VM_OPTIONS+=('--enable-asserts')
|
||||
;;
|
||||
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_cli/bin/analyzer.dart"
|
||||
|
||||
DEV_OPTIONS="--use-analysis-driver-memory-byte-store"
|
||||
|
||||
exec "$DART" "--packages=$DART_ROOT/.packages" "${EXTRA_VM_OPTIONS[@]}" "$ANALYZER" "$DEV_OPTIONS" "$SDK_ARG" "$@"
|
|
@ -1,72 +0,0 @@
|
|||
@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.
|
||||
|
||||
echo Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'. 1>&2
|
||||
|
||||
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=
|
||||
|
||||
if _%DARTANALYZER_DEVELOPER_MODE%_ == _1_ (
|
||||
set EXTRA_VM_OPTIONS=%EXTRA_VM_OPTIONS% --enable_asserts
|
||||
)
|
||||
|
||||
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_cli\bin\analyzer.dart
|
||||
|
||||
"%DART%" "--packages=%DART_ROOT%\.packages" %EXTRA_VM_OPTIONS% "%ANALYZER%" "%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\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
|
|
@ -1,33 +0,0 @@
|
|||
#!/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 dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's
|
||||
# directory structure.
|
||||
|
||||
echo "Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'." 1>&2
|
||||
|
||||
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" --enable_experiment=non-nullable "$SNAPSHOT" "$SDK_ARG" "$@"
|
|
@ -1,54 +0,0 @@
|
|||
@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.
|
||||
|
||||
echo Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'. 1>&2
|
||||
|
||||
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\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
|
|
@ -3262,7 +3262,8 @@
|
|||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": [
|
||||
"create_sdk"
|
||||
"create_sdk",
|
||||
"utils/dartanalyzer"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -3352,7 +3353,8 @@
|
|||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": [
|
||||
"create_sdk"
|
||||
"create_sdk",
|
||||
"utils/dartanalyzer"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ from sys import argv
|
|||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
import utils
|
||||
|
||||
dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
|
||||
dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', '64')
|
||||
if utils.IsWindows():
|
||||
dart_bin = os.path.join(dart_out_dir, 'dart.exe')
|
||||
else:
|
||||
|
@ -43,10 +43,9 @@ def help():
|
|||
def analyze():
|
||||
''' Runs the dart analyzer. '''
|
||||
return call([
|
||||
os.path.join(dart_out_dir, 'dart-sdk', 'bin', 'dartanalyzer'),
|
||||
os.path.join('tests', 'html', 'element_test.dart'),
|
||||
'--dart-sdk=sdk',
|
||||
'--show-package-warnings',
|
||||
os.path.join(dart_out_dir, 'dart-sdk', 'bin', 'dart'),
|
||||
'analyze',
|
||||
os.path.join('tests', 'lib', 'html', 'element_test.dart'),
|
||||
])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue