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>
This commit is contained in:
Liming Gao 2018-12-28 16:25:04 +08:00 committed by Feng, Bob C
parent d8238aaf86
commit 7aef7b7cbf
41 changed files with 195 additions and 121 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,17 +20,21 @@ SUBDIRS = $(BASE_TOOLS_PATH)\Source\C $(BASE_TOOLS_PATH)\Source\Python
all: c all: c
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) 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 .PHONY: clean
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 .PHONY: cleanall
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)

View File

@ -38,7 +38,8 @@ libs: $(LIBRARIES)
@echo # Build libraries @echo # Build libraries
@echo ###################### @echo ######################
@if not exist $(LIB_PATH) mkdir $(LIB_PATH) @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) apps: $(APPLICATIONS)
@echo. @echo.
@ -46,7 +47,8 @@ apps: $(APPLICATIONS)
@echo # Build executables @echo # Build executables
@echo ###################### @echo ######################
@if not exist $(BIN_PATH) mkdir $(BIN_PATH) @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) install: $(LIB_PATH) $(BIN_PATH)
@echo. @echo.
@ -60,11 +62,13 @@ install: $(LIB_PATH) $(BIN_PATH)
.PHONY: clean .PHONY: clean
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 .PHONY: cleanall
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 !INCLUDE Makefiles\ms.rule

View File

@ -796,7 +796,8 @@ class Build():
if PYTHON3_ENABLE != "TRUE": if PYTHON3_ENABLE != "TRUE":
PYTHON3_ENABLE = "FALSE" PYTHON3_ENABLE = "FALSE"
EdkLogger.quiet("%-16s = %s" % ("PYTHON3_ENABLE", PYTHON3_ENABLE)) 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.InitPreBuild()
self.InitPostBuild() self.InitPostBuild()
if self.Prebuild: if self.Prebuild:

View File

@ -14,7 +14,7 @@
all: test all: test
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: clean:
find . -name '*.pyc' -exec rm '{}' ';' find . -name '*.pyc' -exec rm '{}' ';'

View File

@ -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')

View File

@ -286,43 +286,77 @@ goto check_build_environment
) )
:defined_python :defined_python
if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
goto check_python_available
)
if defined PYTHON3_ENABLE ( if defined PYTHON3_ENABLE (
if "%PYTHON3_ENABLE%" EQU "TRUE" ( if "%PYTHON3_ENABLE%" EQU "TRUE" (
set PYTHON=py -3 set PYTHON_COMMAND=py -3
%PYTHON% --version >NUL 2>&1 goto check_python_available
if %ERRORLEVEL% NEQ 0 ( ) 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.
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. echo.
goto end goto end
) else ( ) else (
goto check_freezer_path goto check_python2
) )
) else (
goto check_freezer_path
) )
) )
:check_python2
endlocal
if defined PYTHON_HOME ( if defined PYTHON_HOME (
if EXIST "%PYTHON_HOME%" ( if EXIST "%PYTHON_HOME%" (
set PYTHON=%PYTHON_HOME%\python.exe set PYTHON_COMMAND=%PYTHON_HOME%\python.exe
goto check_freezer_path goto check_python_available
)
) )
)
if defined PYTHONHOME ( if defined PYTHONHOME (
if EXIST "%PYTHONHOME%" ( if EXIST "%PYTHONHOME%" (
set PYTHON_HOME=%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 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 :check_freezer_path
endlocal
if defined BASETOOLS_PYTHON_SOURCE goto print_python_info if defined BASETOOLS_PYTHON_SOURCE goto print_python_info
set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%" set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"
set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
@ -330,14 +364,12 @@ if defined PYTHONHOME (
:print_python_info :print_python_info
echo PATH = %PATH% echo PATH = %PATH%
if "%PYTHON3_ENABLE%" EQU "TRUE" ( if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (
echo PYTHON3_ENABLE = %PYTHON3_ENABLE% echo PYTHON3_ENABLE = %PYTHON3_ENABLE%
echo PYTHON3 = %PYTHON% echo PYTHON3 = %PYTHON_COMMAND%
) else ( ) else (
echo PYTHON3_ENABLE = %PYTHON3_ENABLE% echo PYTHON3_ENABLE = FALSE
if defined PYTHON_HOME ( echo PYTHON_COMMAND = %PYTHON_COMMAND%
echo PYTHON_HOME = %PYTHON_HOME%
)
) )
echo PYTHONPATH = %PYTHONPATH% echo PYTHONPATH = %PYTHONPATH%
echo. echo.

View File

@ -111,11 +111,9 @@ function SetupEnv()
fi fi
} }
function SetupPython() function SetupPython3()
{ {
if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ] if [ $origin_version ];then
then
if [ $origin_version ];then
origin_version= origin_version=
fi fi
for python in $(whereis python3) for python in $(whereis python3)
@ -127,18 +125,35 @@ function SetupPython()
fi fi
if [ -z $origin_version ];then if [ -z $origin_version ];then
origin_version=$python_version origin_version=$python_version
export PYTHON=$python export PYTHON_COMMAND=$python
continue continue
fi fi
ret=`echo "$origin_version < $python_version" |bc` ret=`echo "$origin_version < $python_version" |bc`
if [ "$ret" -eq 1 ]; then if [ "$ret" -eq 1 ]; then
origin_version=$python_version origin_version=$python_version
export PYTHON=$python export PYTHON_COMMAND=$python
fi fi
done 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 fi
if [ -z $PYTHON3_ENABLE ] || [ $PYTHON3_ENABLE != TRUE ] if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE == TRUE ]
then
SetupPython3
fi
if [ $PYTHON3_ENABLE ] && [ $PYTHON3_ENABLE != TRUE ]
then then
if [ $origin_version ];then if [ $origin_version ];then
origin_version= origin_version=
@ -153,16 +168,19 @@ function SetupPython()
if [ -z $origin_version ] if [ -z $origin_version ]
then then
origin_version=$python_version origin_version=$python_version
export PYTHON=$python export PYTHON_COMMAND=$python
continue continue
fi fi
ret=`echo "$origin_version < $python_version" |bc` ret=`echo "$origin_version < $python_version" |bc`
if [ "$ret" -eq 1 ]; then if [ "$ret" -eq 1 ]; then
origin_version=$python_version origin_version=$python_version
export PYTHON=$python export PYTHON_COMMAND=$python
fi fi
done done
return 0
fi fi
SetupPython3
} }
function SourceEnv() function SourceEnv()