* [Patch 1/1] BaseTools/ECC: Add antlr version check
@ 2021-02-07 7:30 Bob Feng
2021-02-18 3:20 ` 回复: [edk2-devel] " gaoliming
0 siblings, 1 reply; 2+ messages in thread
From: Bob Feng @ 2021-02-07 7:30 UTC (permalink / raw)
To: devel; +Cc: Liming Gao, Yuwei Chen
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@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@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 %*
+@for /f ' %%i in ('%PYTHON_COMMAND% -c "import sys; print(sys.version_info.major)"') do @set pyver=%%i
+@IF %pyver%==3 (
+@echo Checking the antlr4-python3-runtime version...
+@for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr antlr4-python3-runtime') do @set antlr4version=%%i
+@echo Installed antlr4-python3-runtime version %antlr4version%
+@IF "%antlr4version%"=="4.7.1" (@%PYTHON_COMMAND% -m %ToolName%.EccMain %*) ELSE (Echo Please install antlr4-python3-runtime=4.7.1 for ECC usage)
+) ELSE (
+@echo Checking the antlr-python-runtime version...
+@for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr antlr-python-runtime') do set antlr3version=%%i
+@echo Installed antlr-python-runtime version %antlr3version%
+@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* 回复: [edk2-devel] [Patch 1/1] BaseTools/ECC: Add antlr version check
2021-02-07 7:30 [Patch 1/1] BaseTools/ECC: Add antlr version check Bob Feng
@ 2021-02-18 3:20 ` gaoliming
0 siblings, 0 replies; 2+ messages in thread
From: gaoliming @ 2021-02-18 3:20 UTC (permalink / raw)
To: devel, bob.c.feng; +Cc: 'Yuwei Chen'
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@groups.io
> <bounce+27952+71401+4905953+8761045@groups.io> 代表 Bob Feng
> 发送时间: 2021年2月7日 15:31
> 收件人: devel@edk2.groups.io
> 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Yuwei Chen
> <yuwei.chen@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@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Yuwei Chen <yuwei.chen@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 %*
> +@for /f ' %%i in ('%PYTHON_COMMAND% -c "import sys;
> print(sys.version_info.major)"') do @set pyver=%%i
> +@IF %pyver%==3 (
> +@echo Checking the antlr4-python3-runtime version...
> +@for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr
> antlr4-python3-runtime') do @set antlr4version=%%i
> +@echo Installed antlr4-python3-runtime version %antlr4version%
> +@IF "%antlr4version%"=="4.7.1" (@%PYTHON_COMMAND%
> -m %ToolName%.EccMain %*) ELSE (Echo Please install
> antlr4-python3-runtime=4.7.1 for ECC usage)
> +) ELSE (
> +@echo Checking the antlr-python-runtime version...
> +@for /f "tokens=2" %%i in ('%PYTHON_COMMAND% -m pip list -l ^| findstr
> antlr-python-runtime') do set antlr3version=%%i
> +@echo Installed antlr-python-runtime version %antlr3version%
> +@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
>
>
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-18 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-07 7:30 [Patch 1/1] BaseTools/ECC: Add antlr version check Bob Feng
2021-02-18 3:20 ` 回复: [edk2-devel] " gaoliming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox