BaseTools: Update windows and linux run scripts file to use Python3

Modify windows script, PosixLike script, edksetup.sh, edksetup.bat to
use Python3

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yunhua Feng 2018-09-05 17:27:05 +08:00 committed by Yonghong Zhu
parent 8be15c61e8
commit 04c47cd401
30 changed files with 110 additions and 65 deletions

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
#python `dirname $0`/RunToolFromSource.py `basename $0` $*
# If a python2 command is available, use it in preference to python
if command -v python2 >/dev/null 2>&1; then
python_exe=python2
# If a PYTHON3 command is available, use it in preference to python
if command -v $PYTHON3 >/dev/null 2>&1; then
python_exe=$PYTHON3
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

View File

@ -1,4 +1,4 @@
@setlocal
@set ToolName=%~n0%
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
@%PYTHON3% -m %ToolName%.%ToolName% %*

View File

@ -1,4 +1,4 @@
@setlocal
@set ToolName=%~n0%
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
@%PYTHON_HOME%\python.exe -m %ToolName%.EccMain %*
@%PYTHON3% -m %ToolName%.EccMain %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*

View File

@ -1,4 +1,4 @@
@setlocal
@set ToolName=%~n0%
@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
@%PYTHON3% -m %ToolName%.%ToolName% %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1 +1 @@
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1 +1 @@
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -1,3 +1,3 @@
@setlocal
@set ToolName=%~n0%
@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

View File

@ -299,18 +299,32 @@ goto end
)
)
if not defined PYTHON_HOME (
if defined PYTHONHOME (
set PYTHON_HOME=%PYTHONHOME%
) else (
echo.
echo !!! ERROR !!! Binary python tools are missing. PYTHON_HOME environment variable is not set.
echo PYTHON_HOME is required to build or execute the python tools.
echo.
goto end
set PYTHON3=py -3
:check_python_version
%PYTHON3% --version >NUL 2>&1
if %ERRORLEVEL% NEQ 0 (
if defined PYTHON_HOME (
if EXIST "%PYTHON_HOME%" (
set PYTHON3=%PYTHON_HOME%\python.exe
)
)
)
%PYTHON3% --version >NUL 2>&1
if %ERRORLEVEL% NEQ 0 (
echo.
echo !!! ERROR !!! %PYTHON3% not install.
echo.
goto end
)
FOR /F "TOKENS=1,2" %%i IN ('%PYTHON3% --version') DO set VERSION=%%j
if /I "%VERSION%" LSS "3.6" (
echo.
echo !!! ERROR !!! python version should greater than or equal to version 3.6.
echo.
goto end
)
:check_freezer_path
@REM We have Python, now test for FreezePython application
if not defined PYTHON_FREEZER_PATH (
echo.

View File

@ -111,10 +111,41 @@ function SetupEnv()
fi
}
function SetupPython3()
{
for python in $(whereis python3)
do
python=$(echo $python | grep "[[:digit:]]$" || true)
python_version=${python##*python}
if [ -z "${python_version}" ];then
continue
fi
if [ -z $origin_version ];then
origin_version=$python_version
export PYTHON3=$python
continue
fi
ret=`echo "$origin_version < $python_version" |bc`
if [ "$ret" -eq 1 ]; then
origin_version=$python_version
export PYTHON3=$python
fi
done
if [ -z "$origin_version" ] || [ `echo "$origin_version < 3.6" |bc` -eq 1 ]; then
echo
echo ERROR!!!, python version should greater than or equal to version 3.6.
echo
return 1
fi
}
function SourceEnv()
{
SetWorkspace &&
SetupEnv
SetupPython3
}
I=$#