From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D6D962194D387 for ; Mon, 28 Jan 2019 18:06:56 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 18:06:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,535,1539673200"; d="scan'208";a="295229945" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga005.jf.intel.com with ESMTP; 28 Jan 2019 18:06:54 -0800 From: "Feng, Bob C" To: edk2-devel@lists.01.org Cc: Liming Gao Date: Tue, 29 Jan 2019 10:06:04 +0800 Message-Id: <20190129020610.14300-28-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 In-Reply-To: <20190129020610.14300-1-bob.c.feng@intel.com> References: <20190129020610.14300-1-bob.c.feng@intel.com> MIME-Version: 1.0 Subject: [Patch 27/33] BaseTools: Update PYTHON env to PYTHON_COMMAND X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2019 02:06:57 -0000 Content-Transfer-Encoding: 8bit From: Liming Gao Update PYTHON env to PYTHON_COMMAND. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao --- BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc | 6 +++--- BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex | 6 +++--- BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds | 6 +++--- BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool | 6 +++--- BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim | 6 +++--- BaseTools/Bin/CYGWIN_NT-5.1-i686/build | 6 +++--- BaseTools/BinWrappers/PosixLike/BPDG | 6 +++--- BaseTools/BinWrappers/PosixLike/Ecc | 6 +++--- BaseTools/BinWrappers/PosixLike/GenDepex | 6 +++--- BaseTools/BinWrappers/PosixLike/GenFds | 6 +++--- BaseTools/BinWrappers/PosixLike/GenPatchPcdTable | 6 +++--- BaseTools/BinWrappers/PosixLike/GenerateCapsule | 6 +++--- BaseTools/BinWrappers/PosixLike/PatchPcdValue | 6 +++--- BaseTools/BinWrappers/PosixLike/Pkcs7Sign | 6 +++--- BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys | 6 +++--- BaseTools/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 +- BaseTools/BinWrappers/WindowsLike/GenDepex.bat | 2 +- BaseTools/BinWrappers/WindowsLike/GenFds.bat | 2 +- BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat | 2 +- BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat | 2 +- BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat | 2 +- BaseTools/BinWrappers/WindowsLike/TargetTool.bat | 2 +- BaseTools/BinWrappers/WindowsLike/Trim.bat | 2 +- BaseTools/BinWrappers/WindowsLike/UPT.bat | 2 +- BaseTools/BinWrappers/WindowsLike/build.bat | 2 +- BaseTools/Makefile | 12 ++++++++---- BaseTools/Source/C/Makefile | 12 ++++++++---- BaseTools/Source/Python/build/build.py | 3 ++- BaseTools/Tests/GNUmakefile | 2 +- BaseTools/Tests/PythonTest.py | 15 +++++++++++++++ BaseTools/toolsetup.bat | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------ edksetup.sh | 42 ++++++++++++++++++++++++++++++------------ 41 files changed, 194 insertions(+), 120 deletions(-) diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc index 8532fe510d..1ba451cf5e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex index 8532fe510d..1ba451cf5e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds index 8532fe510d..1ba451cf5e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool index 8532fe510d..1ba451cf5e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim index 54e09c039b..b53b79bba4 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") exe=$(basename "$full_cmd") diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/build b/BaseTools/Bin/CYGWIN_NT-5.1-i686/build index 8532fe510d..1ba451cf5e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/build +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/build @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG index e9f570b52c..c894384908 100755 --- a/BaseTools/BinWrappers/PosixLike/BPDG +++ b/BaseTools/BinWrappers/PosixLike/BPDG @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc index ed4b7cd384..15edf52106 100755 --- a/BaseTools/BinWrappers/PosixLike/Ecc +++ b/BaseTools/BinWrappers/PosixLike/Ecc @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex index d99e54f222..183cf58224 100755 --- a/BaseTools/BinWrappers/PosixLike/GenDepex +++ b/BaseTools/BinWrappers/PosixLike/GenDepex @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds index e9f570b52c..c894384908 100755 --- a/BaseTools/BinWrappers/PosixLike/GenFds +++ b/BaseTools/BinWrappers/PosixLike/GenFds @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable +++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/GenerateCapsule b/BaseTools/BinWrappers/PosixLike/GenerateCapsule index 91bbd22738..023048c61d 100755 --- a/BaseTools/BinWrappers/PosixLike/GenerateCapsule +++ b/BaseTools/BinWrappers/PosixLike/GenerateCapsule @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/PatchPcdValue +++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/Pkcs7Sign +++ b/BaseTools/BinWrappers/PosixLike/Pkcs7Sign @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys index b42a126840..ea71c7c61a 100755 --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256GenerateKeys @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign +++ b/BaseTools/BinWrappers/PosixLike/Rsa2048Sha256Sign @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/TargetTool +++ b/BaseTools/BinWrappers/PosixLike/TargetTool @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim index d64b834006..1dd28e9662 100755 --- a/BaseTools/BinWrappers/PosixLike/Trim +++ b/BaseTools/BinWrappers/PosixLike/Trim @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") exe=$(basename "$full_cmd") diff --git a/BaseTools/BinWrappers/PosixLike/UPT b/BaseTools/BinWrappers/PosixLike/UPT index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/UPT +++ b/BaseTools/BinWrappers/PosixLike/UPT @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build index d8b8b8f145..f3770eed42 100755 --- a/BaseTools/BinWrappers/PosixLike/build +++ b/BaseTools/BinWrappers/PosixLike/build @@ -1,11 +1,11 @@ #!/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 dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} diff --git a/BaseTools/BinWrappers/WindowsLike/BPDG.bat b/BaseTools/BinWrappers/WindowsLike/BPDG.bat index 4a43e5353e..f43dba81f1 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% -m %ToolName%.%ToolName% %* +@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %* diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat b/BaseTools/BinWrappers/WindowsLike/Ecc.bat index e63ef50135..ba1a15b3b8 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% -m %ToolName%.EccMain %* +@%PYTHON_COMMAND% -m %ToolName%.EccMain %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat index 6c7250f008..f8f3eefacf 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat b/BaseTools/BinWrappers/WindowsLike/GenFds.bat index 4a43e5353e..f43dba81f1 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% -m %ToolName%.%ToolName% %* +@%PYTHON_COMMAND% -m %ToolName%.%ToolName% %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat b/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat index 1ab7d33f98..11b4a48aec 100644 --- a/BaseTools/BinWrappers/WindowsLike/GenerateCapsule.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat index 32da349b31..6d4443b608 100644 --- a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/Trim.bat b/BaseTools/BinWrappers/WindowsLike/Trim.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/Trim.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/UPT.bat b/BaseTools/BinWrappers/WindowsLike/UPT.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/UPT.bat +++ b/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 %* diff --git a/BaseTools/BinWrappers/WindowsLike/build.bat b/BaseTools/BinWrappers/WindowsLike/build.bat index 82e0a90d6c..9616cd893b 100644 --- a/BaseTools/BinWrappers/WindowsLike/build.bat +++ b/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 %* diff --git a/BaseTools/Makefile b/BaseTools/Makefile index 2569ea2ff4..de98e0b617 100644 --- a/BaseTools/Makefile +++ b/BaseTools/Makefile @@ -18,19 +18,23 @@ 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) diff --git a/BaseTools/Source/C/Makefile b/BaseTools/Source/C/Makefile index dd39661272..08f0081212 100644 --- a/BaseTools/Source/C/Makefile +++ b/BaseTools/Source/C/Makefile @@ -36,19 +36,21 @@ libs: $(LIBRARIES) @echo. @echo ###################### @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. @echo ###################### @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. @echo ###################### @echo # Install to $(SYS_LIB_PATH) @@ -58,13 +60,15 @@ install: $(LIB_PATH) $(BIN_PATH) @-xcopy $(BIN_PATH)\*.exe $(SYS_BIN_PATH) /I /D /E /F /Y > NUL 2>&1 @-xcopy $(BIN_PATH)\*.bat $(SYS_BIN_PATH) /I /D /E /F /Y > NUL 2>&1 .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 diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index b5b969e876..c2b22cca70 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -794,11 +794,12 @@ class Build(): if "PYTHON3_ENABLE" in os.environ: PYTHON3_ENABLE = os.environ["PYTHON3_ENABLE"] 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: EdkLogger.quiet("%-16s = %s" % ("PREBUILD", self.Prebuild)) if self.Postbuild: diff --git a/BaseTools/Tests/GNUmakefile b/BaseTools/Tests/GNUmakefile index d6f4e1908b..3eb52b3f83 100644 --- a/BaseTools/Tests/GNUmakefile +++ b/BaseTools/Tests/GNUmakefile @@ -12,10 +12,10 @@ # 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 '{}' ';' diff --git a/BaseTools/Tests/PythonTest.py b/BaseTools/Tests/PythonTest.py new file mode 100644 index 0000000000..cd49dc5b5d --- /dev/null +++ b/BaseTools/Tests/PythonTest.py @@ -0,0 +1,15 @@ +## @file +# Test whether PYTHON_COMMAND is available +# +# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+# 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') diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat index 811b23051f..6fe63e4baa 100755 --- a/BaseTools/toolsetup.bat +++ b/BaseTools/toolsetup.bat @@ -284,62 +284,94 @@ goto check_build_environment set BASE_TOOLS_PATH=%CD% ) ) :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 set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH% :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. :VisualStudioAvailable diff --git a/edksetup.sh b/edksetup.sh index bfa54ddf70..a8897d10f8 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -88,11 +88,11 @@ function SetupEnv() . $EDK_TOOLS_PATH/BuildEnv elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ] then . $WORKSPACE/BaseTools/BuildEnv elif [ -n "$PACKAGES_PATH" ] - then + then PATH_LIST=$PACKAGES_PATH PATH_LIST=${PATH_LIST//:/ } for DIR in $PATH_LIST do if [ -f "$DIR/BaseTools/BuildEnv" ] @@ -109,15 +109,13 @@ function SetupEnv() echo the EDK2 BuildEnv script. return 1 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) do python=$(echo $python | grep "[[:digit:]]$" || true) @@ -125,22 +123,39 @@ function SetupPython() if [ -z "${python_version}" ] || (! command -v $python >/dev/null 2>&1);then continue 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= fi for python in $(whereis python2) @@ -151,20 +166,23 @@ function SetupPython() continue 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 fi + + SetupPython3 } function SourceEnv() { SetWorkspace && -- 2.20.1.windows.1