回复: [edk2-devel] [Patch 1/1] BaseTools/ECC: Add antlr version check

gaoliming gaoliming at byosoft.com.cn
Thu Feb 18 03:20:17 UTC 2021


Bob:
  Can you mention python version in the error message? So, the developer can
know to install antlr for python 3 or python 2.

  Besides, this change is also required in BaseTools\BinPipWrappers scripts.


Thanks
Liming
> -----邮件原件-----
> 发件人: bounce+27952+71401+4905953+8761045 at groups.io
> <bounce+27952+71401+4905953+8761045 at groups.io> 代表 Bob Feng
> 发送时间: 2021年2月7日 15:31
> 收件人: devel at edk2.groups.io
> 抄送: Liming Gao <gaoliming at byosoft.com.cn>; Yuwei Chen
> <yuwei.chen at intel.com>
> 主题: [edk2-devel] [Patch 1/1] BaseTools/ECC: Add antlr version check
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3201
> 
> ECC requires a specific version of Antlr installed.
> This patch is to add a checker in the Ecc command wrapper
> to check if the ECC required version of antlr is installed.
> 
> Signed-off-by: Bob Feng <bob.c.feng at intel.com>
> Cc: Liming Gao <gaoliming at byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen at intel.com>
> ---
>  BaseTools/BinWrappers/PosixLike/Ecc       | 22
> +++++++++++++++++++++-
>  BaseTools/BinWrappers/WindowsLike/Ecc.bat | 14 +++++++++++++-
>  2 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/BinWrappers/PosixLike/Ecc
> b/BaseTools/BinWrappers/PosixLike/Ecc
> index 15edf52106bd..8a3539b8a604 100755
> --- a/BaseTools/BinWrappers/PosixLike/Ecc
> +++ b/BaseTools/BinWrappers/PosixLike/Ecc
> @@ -9,6 +9,26 @@ fi
>  full_cmd=${BASH_SOURCE:-$0} # see
> http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a
> good choice here
>  dir=$(dirname "$full_cmd")
>  cmd=${full_cmd##*/}
> 
>  export
> PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
> -exec "${python_exe:-python}" -m $cmd.EccMain "$@"
> +pyver=`${python_exe} -c "import sys; print(sys.version_info.major)"`
> +if [ $pyver == 3 ]; then
> +    echo "Checking the antlr4-python3-runtime version..."
> +    antlrver=`pip3 list | grep antlr4-python3-runtime`
> +    echo "Installed antlr4-python3-runtime version $antlrver"
> +    if [ "$antlrver"="antlr4-python3-runtime (4.7.1)" ]; then
> +        exec "${python_exe:-python}" -m $cmd.EccMain "$@"
> +    else
> +        echo "Please install antlr4-python3-runtime=4.7.1 for ECC usage"
> +    fi
> +else
> +    echo "Checking the antlr-python-runtime version..."
> +    antlrver=`pip list | grep antlr-python-runtime`
> +    echo "Installed antlr-python-runtime version $antlrver"
> +    if [ "$antlrver"="antlr-python-runtime (3.0.1)" ]; then
> +        exec "${python_exe:-python}" -m $cmd.EccMain "$@"
> +    else
> +        echo "Please install antlr-python-runtime=3.0.1 for ECC usage"
> +    fi
> +fi
> +
> diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> index ba1a15b3b8b0..bd739ef8e2b9 100644
> --- a/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> +++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> @@ -1,4 +1,16 @@
>  @setlocal
>  @set ToolName=%~n0%
>  @set
> PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
> -@%PYTHON_COMMAND% -m %ToolName%.EccMain %*
> + at for /f ' %%i in ('%PYTHON_COMMAND% -c "import sys;
> print(sys.version_info.major)"') do @set pyver=%%i
> + at IF %pyver%==3 (
> + at echo Checking the antlr4-python3-runtime version...
> + at for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr
> antlr4-python3-runtime') do @set antlr4version=%%i
> + at echo Installed antlr4-python3-runtime version %antlr4version%
> + at IF "%antlr4version%"=="4.7.1" (@%PYTHON_COMMAND%
> -m %ToolName%.EccMain %*) ELSE (Echo Please install
> antlr4-python3-runtime=4.7.1 for ECC usage)
> +) ELSE (
> + at echo Checking the antlr-python-runtime version...
> + at for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr
> antlr-python-runtime') do set antlr3version=%%i
> + at echo Installed antlr-python-runtime version %antlr3version%
> + at IF "%antlr3version%"=="3.0.1" (@%PYTHON_COMMAND%
> -m %ToolName%.EccMain %*) ELSE (Echo Please install
> antlr-python-runtime=3.0.1 for ECC usage)
> +)
> +
> --
> 2.29.1.windows.1
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71764): https://edk2.groups.io/g/devel/message/71764
Mute This Topic: https://groups.io/mt/80721902/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list