浏览代码

BaseTools: Update PYTHON env to PYTHON_COMMAND

Update PYTHON env to PYTHON_COMMAND.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Liming Gao 5 年之前
父节点
当前提交
7aef7b7cbf
共有 41 个文件被更改,包括 194 次插入120 次删除
  1. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
  2. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
  3. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds
  4. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool
  5. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim
  6. 3 3
      BaseTools/Bin/CYGWIN_NT-5.1-i686/build
  7. 3 3
      BaseTools/BinWrappers/PosixLike/BPDG
  8. 3 3
      BaseTools/BinWrappers/PosixLike/Ecc
  9. 3 3
      BaseTools/BinWrappers/PosixLike/GenDepex
  10. 3 3
      BaseTools/BinWrappers/PosixLike/GenFds
  11. 3 3
      BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
  12. 3 3
      BaseTools/BinWrappers/PosixLike/GenerateCapsule
  13. 3 3
      BaseTools/BinWrappers/PosixLike/PatchPcdValue
  14. 3 3
      BaseTools/BinWrappers/PosixLike/Pkcs7Sign
  15. 3 3
      BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys
  16. 3 3
      BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign
  17. 3 3
      BaseTools/BinWrappers/PosixLike/TargetTool
  18. 3 3
      BaseTools/BinWrappers/PosixLike/Trim
  19. 3 3
      BaseTools/BinWrappers/PosixLike/UPT
  20. 3 3
      BaseTools/BinWrappers/PosixLike/build
  21. 1 1
      BaseTools/BinWrappers/WindowsLike/BPDG.bat
  22. 1 1
      BaseTools/BinWrappers/WindowsLike/Ecc.bat
  23. 1 1
      BaseTools/BinWrappers/WindowsLike/GenDepex.bat
  24. 1 1
      BaseTools/BinWrappers/WindowsLike/GenFds.bat
  25. 1 1
      BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
  26. 1 1
      BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat
  27. 1 1
      BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
  28. 1 1
      BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
  29. 1 1
      BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
  30. 1 1
      BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
  31. 1 1
      BaseTools/BinWrappers/WindowsLike/TargetTool.bat
  32. 1 1
      BaseTools/BinWrappers/WindowsLike/Trim.bat
  33. 1 1
      BaseTools/BinWrappers/WindowsLike/UPT.bat
  34. 1 1
      BaseTools/BinWrappers/WindowsLike/build.bat
  35. 8 4
      BaseTools/Makefile
  36. 8 4
      BaseTools/Source/C/Makefile
  37. 2 1
      BaseTools/Source/Python/build/build.py
  38. 1 1
      BaseTools/Tests/GNUmakefile
  39. 15 0
      BaseTools/Tests/PythonTest.py
  40. 56 24
      BaseTools/toolsetup.bat
  41. 30 12
      edksetup.sh

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc

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

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex

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

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds

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

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool

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

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim

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

+ 3 - 3
BaseTools/Bin/CYGWIN_NT-5.1-i686/build

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/BPDG

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/Ecc

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/GenDepex

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/GenFds

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/GenPatchPcdTable

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/GenerateCapsule

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/PatchPcdValue

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/Pkcs7Sign

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/TargetTool

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/Trim

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/UPT

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

+ 3 - 3
BaseTools/BinWrappers/PosixLike/build

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

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/BPDG.bat

@@ -1,4 +1,4 @@
 @setlocal
 @set ToolName=%~n0%
 @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
-@%PYTHON% -m %ToolName%.%ToolName% %*
+@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/Ecc.bat

@@ -1,4 +1,4 @@
 @setlocal
 @set ToolName=%~n0%
 @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
-@%PYTHON% -m %ToolName%.EccMain %*
+@%PYTHON_COMMAND% -m %ToolName%.EccMain %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/GenDepex.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\AutoGen\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/GenFds.bat

@@ -1,4 +1,4 @@
 @setlocal
 @set ToolName=%~n0%
 @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
-@%PYTHON% -m %ToolName%.%ToolName% %*
+@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat

@@ -1 +1 @@
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\Capsule\GenerateCapsule.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat

@@ -1 +1 @@
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/TargetTool.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/Trim.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/UPT.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 1 - 1
BaseTools/BinWrappers/WindowsLike/build.bat

@@ -1,3 +1,3 @@
 @setlocal
 @set ToolName=%~n0%
-@%PYTHON% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*

+ 8 - 4
BaseTools/Makefile

@@ -20,17 +20,21 @@ SUBDIRS = $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\Source\Python
 all: c
 
 c :
-  @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $(BASE_TOOLS_PATH)\Source\C
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $(BASE_TOOLS_PATH)\Source\C
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $(BASE_TOOLS_PATH)\Source\C
 
 
 subdirs: $(SUBDIRS)
-  @$(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $**
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $**
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  all $**
 
 .PHONY: clean
 clean:
-  $(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py clean $(SUBDIRS)
 
 .PHONY: cleanall
 cleanall:
-  $(PYTHON) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  cleanall $(SUBDIRS)
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  cleanall $(SUBDIRS)
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(BASE_TOOLS_PATH)\Source\C\Makefiles\NmakeSubdirs.py  cleanall $(SUBDIRS)
 

+ 8 - 4
BaseTools/Source/C/Makefile

@@ -38,7 +38,8 @@ libs: $(LIBRARIES)
 	@echo # Build libraries
 	@echo ######################
 	@if not exist $(LIB_PATH) mkdir $(LIB_PATH)
-	@$(PYTHON) Makefiles\NmakeSubdirs.py all $**
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py all $**
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**
 
 apps: $(APPLICATIONS)
 	@echo.
@@ -46,7 +47,8 @@ apps: $(APPLICATIONS)
 	@echo # Build executables
 	@echo ######################
 	@if not exist $(BIN_PATH) mkdir $(BIN_PATH)
-	@$(PYTHON) Makefiles\NmakeSubdirs.py all $**
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py all $**
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py all $**
 
 install: $(LIB_PATH) $(BIN_PATH)
 	@echo.
@@ -60,11 +62,13 @@ install: $(LIB_PATH) $(BIN_PATH)
 
 .PHONY: clean
 clean:
-  @$(PYTHON) Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe Makefiles\NmakeSubdirs.py clean $(LIBRARIES) $(APPLICATIONS)
 
 .PHONY: cleanall
 cleanall:
-  @$(PYTHON) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)
+  @if defined PYTHON_COMMAND $(PYTHON_COMMAND) $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)
+  @if not defined PYTHON_COMMAND $(PYTHON_HOME)\python.exe $(PYTHON_COMMAND) Makefiles\NmakeSubdirs.py cleanall $(LIBRARIES) $(APPLICATIONS)
 
 !INCLUDE Makefiles\ms.rule
 

+ 2 - 1
BaseTools/Source/Python/build/build.py

@@ -796,7 +796,8 @@ class Build():
             if PYTHON3_ENABLE != "TRUE":
                 PYTHON3_ENABLE = "FALSE"
             EdkLogger.quiet("%-16s = %s" % ("PYTHON3_ENABLE", PYTHON3_ENABLE))
-        EdkLogger.quiet("%-16s = %s" % ("PYTHON", os.environ["PYTHON"]))
+        if "PYTHON_COMMAND" in os.environ:
+            EdkLogger.quiet("%-16s = %s" % ("PYTHON_COMMAND", os.environ["PYTHON_COMMAND"]))
         self.InitPreBuild()
         self.InitPostBuild()
         if self.Prebuild:

+ 1 - 1
BaseTools/Tests/GNUmakefile

@@ -14,7 +14,7 @@
 all: test
 
 test:
-	@if command -v $(PYTHON) >/dev/null 1; then $(PYTHON) RunTests.py; else python RunTests.py; fi
+	@if command -v $(PYTHON_COMMAND) >/dev/null 1; then $(PYTHON_COMMAND) RunTests.py; else python RunTests.py; fi
 
 clean:
 	find . -name '*.pyc' -exec rm '{}' ';'

+ 15 - 0
BaseTools/Tests/PythonTest.py

@@ -0,0 +1,15 @@
+## @file
+# Test whether PYTHON_COMMAND is available
+#
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.  The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+if __name__ == '__main__':
+    print('TRUE')

+ 56 - 24
BaseTools/toolsetup.bat

@@ -286,43 +286,77 @@ goto check_build_environment
   )
 
 :defined_python
+if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
+  goto check_python_available
+)
 if defined PYTHON3_ENABLE (
   if "%PYTHON3_ENABLE%" EQU "TRUE" (
-    set PYTHON=py -3
-    %PYTHON% --version >NUL 2>&1
-    if %ERRORLEVEL% NEQ 0 (
+    set PYTHON_COMMAND=py -3
+    goto check_python_available
+  ) else (
+    goto check_python2
+  )
+)
+if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
+  set PYTHON_COMMAND=py -3
+  py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1
+  setlocal enabledelayedexpansion
+  set /p PythonCheck=<"PythonCheck.txt"
+  del PythonCheck.txt
+  if "!PythonCheck!" NEQ "TRUE" (
+    if not defined PYTHON_HOME if not defined PYTHONHOME (
+      endlocal
+      set PYTHON_COMMAND=
       echo.
-      echo !!! ERROR !!!  PYTHON3 is not installed or added to environment variables
+      echo !!! ERROR !!! Binary python tools are missing.
+      echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME
+      echo Environment variable is not set successfully.
+      echo They is required to build or execute the python tools.
       echo.
       goto end
     ) else (
-      goto check_freezer_path
+      goto check_python2
     )
-  ) 
+  ) else (
+    goto check_freezer_path
+  )
 )
 
+:check_python2
+endlocal
 if defined PYTHON_HOME (
   if EXIST "%PYTHON_HOME%" (
-    set PYTHON=%PYTHON_HOME%\python.exe
-    goto check_freezer_path
-    )
+    set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
+    goto check_python_available
   )
+)
 if defined PYTHONHOME (
   if EXIST "%PYTHONHOME%" (
     set PYTHON_HOME=%PYTHONHOME%
-    set PYTHON=%PYTHON_HOME%\python.exe
+    set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
+    goto check_python_available
+  )
+)
+echo.
+echo !!! ERROR !!!  PYTHON_HOME is not defined or The value of this variable does not exist
+echo.
+goto end
+:check_python_available
+%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1
+  setlocal enabledelayedexpansion
+  set /p PythonCheck=<"PythonCheck.txt"
+  del PythonCheck.txt
+  if "!PythonCheck!" NEQ "TRUE" (
+    echo.
+    echo ! ERROR !  "%PYTHON_COMMAND%" is not installed or added to environment variables
+    echo.
+    goto end
+  ) else (
     goto check_freezer_path
-    )
   )
-  
-  echo.
-  echo !!! ERROR !!! Binary python tools are missing.
-  echo PYTHON_HOME or PYTHON3_ENABLE environment variable is not set successfully.
-  echo PYTHON_HOME or PYTHON3_ENABLE is required to build or execute the python tools.
-  echo.
-  goto end
 
 :check_freezer_path
+  endlocal
   if defined BASETOOLS_PYTHON_SOURCE goto print_python_info
   set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
   set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
@@ -330,14 +364,12 @@ if defined PYTHONHOME (
 
 :print_python_info
   echo                PATH = %PATH%
-  if "%PYTHON3_ENABLE%" EQU "TRUE" (
+  if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (
     echo      PYTHON3_ENABLE = %PYTHON3_ENABLE%
-    echo             PYTHON3 = %PYTHON%
+    echo             PYTHON3 = %PYTHON_COMMAND%
   ) else (
-    echo      PYTHON3_ENABLE = %PYTHON3_ENABLE%
-    if defined PYTHON_HOME (
-      echo         PYTHON_HOME = %PYTHON_HOME%
-    )
+    echo      PYTHON3_ENABLE = FALSE
+    echo      PYTHON_COMMAND = %PYTHON_COMMAND%
   )
   echo          PYTHONPATH = %PYTHONPATH%
   echo.

+ 30 - 12
edksetup.sh

@@ -90,7 +90,7 @@ function SetupEnv()
   then
     . $WORKSPACE/BaseTools/BuildEnv
   elif [ -n "$PACKAGES_PATH" ]
-  then 
+  then
     PATH_LIST=$PACKAGES_PATH
     PATH_LIST=${PATH_LIST//:/ }
     for DIR in $PATH_LIST
@@ -111,11 +111,9 @@ function SetupEnv()
   fi
 }
 
-function SetupPython()
-{    
-  if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
-  then
-    if [ $origin_version ];then
+function SetupPython3()
+{
+  if [ $origin_version ];then
       origin_version=
     fi
     for python in $(whereis python3)
@@ -127,18 +125,35 @@ function SetupPython()
       fi
       if [ -z $origin_version ];then
         origin_version=$python_version
-        export PYTHON=$python
+        export PYTHON_COMMAND=$python
         continue
       fi
       ret=`echo "$origin_version < $python_version" |bc`
       if [ "$ret" -eq 1 ]; then
         origin_version=$python_version
-        export PYTHON=$python
+        export PYTHON_COMMAND=$python
       fi
     done
+    return 0
+}
+
+function SetupPython()
+{
+  if [ $PYTHON_COMMAND ] && [ -z $PYTHON3_ENABLE ];then
+    if ( command -v $PYTHON_COMMAND >/dev/null 2>&1 );then
+      return 0
+    else
+      echo $PYTHON_COMMAND Cannot be used to build or execute the python tools.
+      return 1
+    fi
   fi
-  
-  if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ]
+
+  if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
+  then
+    SetupPython3
+  fi
+
+  if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE ]
   then
     if [ $origin_version ];then
       origin_version=
@@ -153,16 +168,19 @@ function SetupPython()
       if [ -z $origin_version ]
       then
         origin_version=$python_version
-        export PYTHON=$python
+        export PYTHON_COMMAND=$python
         continue
       fi
       ret=`echo "$origin_version < $python_version" |bc`
       if [ "$ret" -eq 1 ]; then
         origin_version=$python_version
-        export PYTHON=$python
+        export PYTHON_COMMAND=$python
       fi
     done
+    return 0
   fi
+
+  SetupPython3
 }
 
 function SourceEnv()