diff --git a/pkg/docgen/bin/docgen.dart b/pkg/docgen/bin/docgen.dart index ac6b3645ad9..8b5e59d9325 100644 --- a/pkg/docgen/bin/docgen.dart +++ b/pkg/docgen/bin/docgen.dart @@ -62,8 +62,8 @@ void main(List arguments) { * Print help if we are passed the help option or invalid arguments. */ void _printHelpAndExit() { - print(_initArgParser().getUsage()); - print('Usage: dart docgen.dart [OPTIONS] fooDir/barFile'); + print(_initArgParser().usage); + print('Usage: dartdocgen [OPTIONS] fooDir/barFile'); exit(0); } diff --git a/sdk/bin/dartdocgen b/sdk/bin/dartdocgen new file mode 100755 index 00000000000..bf807ad96d5 --- /dev/null +++ b/sdk/bin/dartdocgen @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright (c) 2014, 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. + +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)" + +unset SNAPSHOT + +SNAPSHOT="$BIN_DIR/snapshots/utils_wrapper.dart.snapshot" + +if test -f "$SNAPSHOT"; then + exec "$BIN_DIR"/dart \ + "--package-root=$BIN_DIR/../packages/" "--old_gen_heap_size=1024" \ + "$SNAPSHOT" \ + docgen "--sdk=$SDK_DIR" "$@" +else + exec "$BIN_DIR"/dart \ + "--package-root=$BIN_DIR/../packages/" "--old_gen_heap_size=1024" \ + "$BIN_DIR/../../pkg/docgen/bin/docgen.dart" "--sdk=$SDK_DIR" "$@" +fi diff --git a/sdk/bin/dartdocgen.bat b/sdk/bin/dartdocgen.bat new file mode 100644 index 00000000000..136b7f90319 --- /dev/null +++ b/sdk/bin/dartdocgen.bat @@ -0,0 +1,49 @@ +@echo off +REM Copyright (c) 2014, 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 + +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 DOCGEN=%SDK_DIR%\pkg\docgen\bin\docgen.dart +set DART=%BIN_DIR%\dart +set SNAPSHOT=%BIN_DIR%\snapshots\utils_wrapper.dart.snapshot + +if not defined DART_CONFIGURATION set DART_CONFIGURATION=ReleaseIA32 + +set BUILD_DIR=%SDK_DIR%\..\build\%DART_CONFIGURATION% +if exist "%SNAPSHOT%" ( + "%DART%" "%SNAPSHOT%" "docgen" "--sdk=%SDK_DIR%" %* +) else ( + "%BUILD_DIR%\dart-sdk\bin\dart" "--package-root=%BUILD_DIR%\packages" "%DOCGEN%" "--sdk=%SDK_DIR%" %* +) + +endlocal + +exit /b %errorlevel% + +:follow_links +setlocal +for %%i in (%1) do set result=%%~fi +set current= +for /f "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/docgen b/sdk/bin/docgen index bf807ad96d5..c6c545542d7 100755 --- a/sdk/bin/docgen +++ b/sdk/bin/docgen @@ -3,34 +3,5 @@ # 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. -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)" - -unset SNAPSHOT - -SNAPSHOT="$BIN_DIR/snapshots/utils_wrapper.dart.snapshot" - -if test -f "$SNAPSHOT"; then - exec "$BIN_DIR"/dart \ - "--package-root=$BIN_DIR/../packages/" "--old_gen_heap_size=1024" \ - "$SNAPSHOT" \ - docgen "--sdk=$SDK_DIR" "$@" -else - exec "$BIN_DIR"/dart \ - "--package-root=$BIN_DIR/../packages/" "--old_gen_heap_size=1024" \ - "$BIN_DIR/../../pkg/docgen/bin/docgen.dart" "--sdk=$SDK_DIR" "$@" -fi +echo "The 'docgen' name is deprecated. Prefer 'dartdocgen' instead." +dartdocgen "$@" diff --git a/sdk/bin/docgen.bat b/sdk/bin/docgen.bat index 136b7f90319..63a214fdad0 100644 --- a/sdk/bin/docgen.bat +++ b/sdk/bin/docgen.bat @@ -3,47 +3,5 @@ REM Copyright (c) 2014, 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 - -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 DOCGEN=%SDK_DIR%\pkg\docgen\bin\docgen.dart -set DART=%BIN_DIR%\dart -set SNAPSHOT=%BIN_DIR%\snapshots\utils_wrapper.dart.snapshot - -if not defined DART_CONFIGURATION set DART_CONFIGURATION=ReleaseIA32 - -set BUILD_DIR=%SDK_DIR%\..\build\%DART_CONFIGURATION% -if exist "%SNAPSHOT%" ( - "%DART%" "%SNAPSHOT%" "docgen" "--sdk=%SDK_DIR%" %* -) else ( - "%BUILD_DIR%\dart-sdk\bin\dart" "--package-root=%BUILD_DIR%\packages" "%DOCGEN%" "--sdk=%SDK_DIR%" %* -) - -endlocal - -exit /b %errorlevel% - -:follow_links -setlocal -for %%i in (%1) do set result=%%~fi -set current= -for /f "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 +echo "The 'docgen.bat' name is deprecated. Prefer 'dartdocgen.bat' instead." +dartdocgen %* diff --git a/tools/create_sdk.py b/tools/create_sdk.py index c39dd336dd6..81be9defb4d 100755 --- a/tools/create_sdk.py +++ b/tools/create_sdk.py @@ -113,7 +113,7 @@ def CopyShellScript(src_file, dest_dir): def CopyDartScripts(home, sdk_root): for executable in ['dart2js_sdk', 'dartanalyzer_sdk', 'dartfmt', 'docgen', - 'pub_sdk']: + 'dartdocgen', 'pub_sdk']: CopyShellScript(os.path.join(home, 'sdk', 'bin', executable), os.path.join(sdk_root, 'bin')) diff --git a/utils/apidoc/docgen.gyp b/utils/apidoc/docgen.gyp index 66a4fb60b9e..1fa26ab9a97 100644 --- a/utils/apidoc/docgen.gyp +++ b/utils/apidoc/docgen.gyp @@ -63,8 +63,12 @@ '../../sdk/bin/dart.bat', '../../sdk/bin/dart2js', '../../sdk/bin/dart2js.bat', + # TODO(alanknight): The docgen name is deprecated in favour of + # dartdocgen, and should be removed eventually. '../../sdk/bin/docgen', + '../../sdk/bin/dartdocgen', '../../sdk/bin/docgen.bat', + '../../sdk/bin/dartdocgen.bat', '../../tools/only_in_release_mode.py', '<(PRODUCT_DIR)/dart-sdk/README', '<(SHARED_INTERMEDIATE_DIR)/pkg_files.stamp', @@ -77,7 +81,7 @@ '../../tools/only_in_release_mode.py', '<@(_outputs)', '--', - '<(PRODUCT_DIR)/dart-sdk/bin/docgen<(script_suffix)', + '<(PRODUCT_DIR)/dart-sdk/bin/dartdocgen<(script_suffix)', '--out=<(PRODUCT_DIR)/api_docs/docgen', '--include-sdk', '--no-include-dependent-packages', @@ -90,7 +94,7 @@ '--exclude-lib=try', '../../pkg' ], - 'message': 'Running docgen: <(_action)', + 'message': 'Running dartdocgen: <(_action)', }, ], }