From 04c47cd40111f85614ec51f6ba8d4e9a2f0fafde Mon Sep 17 00:00:00 2001 From: Yunhua Feng Date: Wed, 5 Sep 2018 17:27:05 +0800 Subject: [PATCH] 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 Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Liming Gao --- BaseTools/BinWrappers/PosixLike/BPDG | 6 ++-- BaseTools/BinWrappers/PosixLike/Ecc | 6 ++-- BaseTools/BinWrappers/PosixLike/GenDepex | 6 ++-- BaseTools/BinWrappers/PosixLike/GenFds | 6 ++-- .../BinWrappers/PosixLike/GenPatchPcdTable | 6 ++-- .../BinWrappers/PosixLike/GenerateCapsule | 6 ++-- BaseTools/BinWrappers/PosixLike/PatchPcdValue | 6 ++-- BaseTools/BinWrappers/PosixLike/Pkcs7Sign | 6 ++-- .../PosixLike/Rsa2048Sha256GenerateKeys | 6 ++-- .../BinWrappers/PosixLike/Rsa2048Sha256Sign | 6 ++-- BaseTools/BinWrappers/PosixLike/TargetTool | 6 ++-- BaseTools/BinWrappers/PosixLike/Trim | 6 ++-- BaseTools/BinWrappers/PosixLike/UPT | 6 ++-- BaseTools/BinWrappers/PosixLike/build | 6 ++-- BaseTools/BinWrappers/WindowsLike/BPDG.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Ecc.bat | 2 +- .../BinWrappers/WindowsLike/GenDepex.bat | 2 +- BaseTools/BinWrappers/WindowsLike/GenFds.bat | 2 +- .../WindowsLike/GenPatchPcdTable.bat | 2 +- .../WindowsLike/GenerateCapsule.bat | 2 +- .../BinWrappers/WindowsLike/PatchPcdValue.bat | 2 +- .../BinWrappers/WindowsLike/Pkcs7Sign.bat | 2 +- .../WindowsLike/Rsa2048Sha256GenerateKeys.bat | 2 +- .../WindowsLike/Rsa2048Sha256Sign.bat | 2 +- .../BinWrappers/WindowsLike/TargetTool.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Trim.bat | 2 +- BaseTools/BinWrappers/WindowsLike/UPT.bat | 2 +- BaseTools/BinWrappers/WindowsLike/build.bat | 2 +- BaseTools/toolsetup.bat | 32 +++++++++++++------ edksetup.sh | 31 ++++++++++++++++++ 30 files changed, 110 insertions(+), 65 deletions(-) diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG index 276c7ea207..99dcf99657 100755 --- a/BaseTools/BinWrappers/PosixLike/BPDG +++ b/BaseTools/BinWrappers/PosixLike/BPDG @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc index 1142964028..0032408fa1 100755 --- a/BaseTools/BinWrappers/PosixLike/Ecc +++ b/BaseTools/BinWrappers/PosixLike/Ecc @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex index dad174788b..f1bd62d7bd 100755 --- a/BaseTools/BinWrappers/PosixLike/GenDepex +++ b/BaseTools/BinWrappers/PosixLike/GenDepex @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds index 276c7ea207..99dcf99657 100755 --- a/BaseTools/BinWrappers/PosixLike/GenFds +++ b/BaseTools/BinWrappers/PosixLike/GenFds @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable +++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/GenerateCapsule b/BaseTools/BinWrappers/PosixLike/GenerateCapsule index 59a6c8ba43..3a1bd4d4e9 100755 --- a/BaseTools/BinWrappers/PosixLike/GenerateCapsule +++ b/BaseTools/BinWrappers/PosixLike/GenerateCapsule @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue +++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign +++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys index 1bc1054a34..0d7872d24d 100755 --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/TargetTool +++ b/BaseTools/BinWrappers/PosixLike/TargetTool @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim index 6c8dde5bec..f36bd69d26 100755 --- a/BaseTools/BinWrappers/PosixLike/Trim +++ b/BaseTools/BinWrappers/PosixLike/Trim @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/UPT +++ b/BaseTools/BinWrappers/PosixLike/UPT @@ -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 diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build index 01ae23ddeb..76effb6da0 100755 --- a/BaseTools/BinWrappers/PosixLike/build +++ b/BaseTools/BinWrappers/PosixLike/build @@ -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 diff --git a/BaseTools/BinWrappers/WindowsLike/BPDG.bat b/BaseTools/BinWrappers/WindowsLike/BPDG.bat index 98095cfbd4..8e2211e3c1 100644 --- a/BaseTools/BinWrappers/WindowsLike/BPDG.bat +++ b/BaseTools/BinWrappers/WindowsLike/BPDG.bat @@ -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% %* diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat b/BaseTools/BinWrappers/WindowsLike/Ecc.bat index 8705e7541e..151d9e730d 100644 --- a/BaseTools/BinWrappers/WindowsLike/Ecc.bat +++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat index ffc783d2be..e8e5753ce3 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat +++ b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat b/BaseTools/BinWrappers/WindowsLike/GenFds.bat index 98095cfbd4..8e2211e3c1 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenFds.bat +++ b/BaseTools/BinWrappers/WindowsLike/GenFds.bat @@ -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% %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat +++ b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat b/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat index ca442d181b..a498b1efc5 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat +++ b/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat @@ -1 +1 @@ -@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %* +@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %* diff --git a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat +++ b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat +++ b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat index df9336567c..c3323a742d 100644 --- a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat +++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat @@ -1 +1 @@ -@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %* +@%PYTHON3% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %* diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat +++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat +++ b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Trim.bat b/BaseTools/BinWrappers/WindowsLike/Trim.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/Trim.bat +++ b/BaseTools/BinWrappers/WindowsLike/Trim.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/UPT.bat b/BaseTools/BinWrappers/WindowsLike/UPT.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/UPT.bat +++ b/BaseTools/BinWrappers/WindowsLike/UPT.bat @@ -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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/build.bat b/BaseTools/BinWrappers/WindowsLike/build.bat index 9fbb704a6e..160347c700 100644 --- a/BaseTools/BinWrappers/WindowsLike/build.bat +++ b/BaseTools/BinWrappers/WindowsLike/build.bat @@ -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 %* diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat index 33d50f58ad..0d4028db78 100755 --- a/BaseTools/toolsetup.bat +++ b/BaseTools/toolsetup.bat @@ -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. diff --git a/edksetup.sh b/edksetup.sh index 93d6525758..d4e577e607 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -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=$#