public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/4] Add support for running python tools from source on Windows
@ 2016-09-12 16:03 Liming Gao
  2016-09-12 16:03 ` [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source Liming Gao
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Liming Gao @ 2016-09-12 16:03 UTC (permalink / raw)
  To: edk2-devel

When Python tool exe files don't exist, toolsetup.bat will configure 
PYTHONPATH to python source code, and set BaseTools\BinWrappers\WindowsLike
into system PATH directory. Then, windows batch files will be used to 
run python tools from source files. 

Liming Gao (4):
  BaseTools: Add Windows batch files to run python tool from Source
  BaseTools: Update python tool to call external tools with shell true
    mode
  BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH
  BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python
    source

 BaseTools/BinWrappers/WindowsLike/BPDG.bat         |   3 +
 BaseTools/BinWrappers/WindowsLike/Ecc.bat          |   3 +
 BaseTools/BinWrappers/WindowsLike/GenDepex.bat     |   3 +
 BaseTools/BinWrappers/WindowsLike/GenFds.bat       |   3 +
 .../BinWrappers/WindowsLike/GenPatchPcdTable.bat   |   3 +
 .../BinWrappers/WindowsLike/PatchPcdValue.bat      |   3 +
 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat    |   3 +
 .../WindowsLike/Rsa2048Sha256GenerateKeys.bat      |   1 +
 .../BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat  |   3 +
 BaseTools/BinWrappers/WindowsLike/TargetTool.bat   |   3 +
 BaseTools/BinWrappers/WindowsLike/Trim.bat         |   3 +
 BaseTools/BinWrappers/WindowsLike/UPT.bat          |   3 +
 BaseTools/BinWrappers/WindowsLike/build.bat        |   3 +
 BaseTools/Source/Python/Common/VpdInfoFile.py      |   7 +-
 BaseTools/Source/Python/Makefile                   |  17 +++-
 BaseTools/Source/Python/build/build.py             |   5 +-
 BaseTools/toolsetup.bat                            | 101 +++++++++------------
 17 files changed, 100 insertions(+), 67 deletions(-)
 create mode 100644 BaseTools/BinWrappers/WindowsLike/BPDG.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Ecc.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenDepex.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenFds.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/TargetTool.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Trim.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/UPT.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/build.bat

-- 
2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source
  2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
@ 2016-09-12 16:03 ` Liming Gao
  2016-09-12 23:59   ` Bjorge, Erik C
  2016-09-12 16:03 ` [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode Liming Gao
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Liming Gao @ 2016-09-12 16:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yonghong Zhu, Michael Kinney, Erik Bjorge

Add 13 windows batch files for every python tool.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/BinWrappers/WindowsLike/BPDG.bat                      | 3 +++
 BaseTools/BinWrappers/WindowsLike/Ecc.bat                       | 3 +++
 BaseTools/BinWrappers/WindowsLike/GenDepex.bat                  | 3 +++
 BaseTools/BinWrappers/WindowsLike/GenFds.bat                    | 3 +++
 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat          | 3 +++
 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat             | 3 +++
 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat                 | 3 +++
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat | 1 +
 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat         | 3 +++
 BaseTools/BinWrappers/WindowsLike/TargetTool.bat                | 3 +++
 BaseTools/BinWrappers/WindowsLike/Trim.bat                      | 3 +++
 BaseTools/BinWrappers/WindowsLike/UPT.bat                       | 3 +++
 BaseTools/BinWrappers/WindowsLike/build.bat                     | 3 +++
 13 files changed, 37 insertions(+)
 create mode 100644 BaseTools/BinWrappers/WindowsLike/BPDG.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Ecc.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenDepex.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenFds.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/TargetTool.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Trim.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/UPT.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/build.bat

diff --git a/BaseTools/BinWrappers/WindowsLike/BPDG.bat b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
new file mode 100644
index 0000000..df93365
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
@@ -0,0 +1 @@
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateKeys.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/Trim.bat b/BaseTools/BinWrappers/WindowsLike/Trim.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/Trim.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/UPT.bat b/BaseTools/BinWrappers/WindowsLike/UPT.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/UPT.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
diff --git a/BaseTools/BinWrappers/WindowsLike/build.bat b/BaseTools/BinWrappers/WindowsLike/build.bat
new file mode 100644
index 0000000..9fbb704
--- /dev/null
+++ b/BaseTools/BinWrappers/WindowsLike/build.bat
@@ -0,0 +1,3 @@
+@setlocal
+@set ToolName=%~n0%
+@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode
  2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
  2016-09-12 16:03 ` [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source Liming Gao
@ 2016-09-12 16:03 ` Liming Gao
  2016-09-13  0:00   ` Bjorge, Erik C
  2016-09-12 16:03 ` [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH Liming Gao
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Liming Gao @ 2016-09-12 16:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yonghong Zhu, Michael Kinney, Erik Bjorge

Python tool may run from source as the dos batch files. So, update python
code to call external tools with shell true mode.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Common/VpdInfoFile.py | 7 ++++---
 BaseTools/Source/Python/build/build.py        | 5 ++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index cc79ee2..d45fb4c 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -233,14 +233,15 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
     OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
           
     try:
-        PopenObject = subprocess.Popen([ToolPath,
+        PopenObject = subprocess.Popen(' '.join([ToolPath,
                                         '-o', OutputBinFileName, 
                                         '-m', OutputMapFileName,
                                         '-q',
                                         '-f',
-                                        VpdFileName],
+                                        VpdFileName]),
                                         stdout=subprocess.PIPE, 
-                                        stderr= subprocess.PIPE)
+                                        stderr= subprocess.PIPE,
+                                        shell=True)
     except Exception, X:
         EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X)))
     (out, error) = PopenObject.communicate()
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index be02119..20f726f 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -266,14 +266,13 @@ def LaunchCommand(Command, WorkingDir):
     # ubuntu may fail with an error message that the command is not found.
     # So here we may need convert command from string to list instance.
     if not isinstance(Command, list):
-        if platform.system() != 'Windows':
-            Command = Command.split()
+        Command = Command.split()
 
     Proc = None
     EndOfProcedure = None
     try:
         # launch the command
-        Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1)
+        Proc = Popen(' '.join(Command), stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
 
         # launch two threads to read the STDOUT and STDERR
         EndOfProcedure = Event()
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH
  2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
  2016-09-12 16:03 ` [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source Liming Gao
  2016-09-12 16:03 ` [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode Liming Gao
@ 2016-09-12 16:03 ` Liming Gao
  2016-09-13  0:00   ` Bjorge, Erik C
  2016-09-12 16:03 ` [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source Liming Gao
  2016-09-21  2:50 ` [Patch 0/4] Add support for running python tools from source on Windows Zhu, Yonghong
  4 siblings, 1 reply; 10+ messages in thread
From: Liming Gao @ 2016-09-12 16:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yonghong Zhu, Michael Kinney, Erik Bjorge

If PYTHON_FREEZER_PATH is not set, Python tools will not be freeze.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Makefile | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Makefile b/BaseTools/Source/Python/Makefile
index 28be671..e7755cd 100644
--- a/BaseTools/Source/Python/Makefile
+++ b/BaseTools/Source/Python/Makefile
@@ -11,16 +11,17 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
-!IFNDEF PYTHON_FREEZER_PATH
-!ERROR PYTHON_FREEZER_PATH must be defined!
+!IFNDEF PYTHON_HOME
+!ERROR PYTHON_HOME must be defined!
 !ENDIF
 
+!IFDEF PYTHON_FREEZER_PATH
 !IF EXIST ($(PYTHON_FREEZER_PATH)\cxfreeze)
 # Using cx_Freeze 4.2.3 with Python 2.7.2
 FREEZE=$(PYTHON_HOME)\python $(PYTHON_FREEZER_PATH)\cxfreeze
 !ELSE
-# Using cx_Freeze 3.0.3 with Python 2.5.4
-FREEZE=$(PYTHON_FREEZER_PATH)\FreezePython.exe
+!ERROR PYTHON_FREEZER_PATH does not exist!
+!ENDIF
 !ENDIF
 
 MODULES=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_8,encodings.utf_16_le,encodings.latin_1,encodings.ascii
@@ -236,7 +237,14 @@ CMD_UPT=$(BASE_TOOLS_PATH)\Source\Python\UPT\Core\DependencyRules.py \
     $(BASE_TOOLS_PATH)\Source\Python\UPT\Xml\XmlParser.py \
     $(BASE_TOOLS_PATH)\Source\Python\UPT\Xml\XmlParserMisc.py
 
+!IFDEF PYTHON_FREEZER_PATH
 all: SetPythonPath $(APPLICATIONS)
+!ELSE
+all:
+  @echo.
+  @echo !!! WARNING !!! PYTHON_FREEZER_PATH is not set.
+  @echo Cannot make executable from Python code, executing python scripts instead !!!
+!ENDIF
 
 SetPythonPath:
   set PYTHONPATH=$(BASE_TOOLS_PATH)\Source\Python
@@ -310,5 +318,6 @@ $(BIN_DIR)\TestRoot.pub.pem: $(BASE_TOOLS_PATH)\Source\Python\Pkcs7Sign\TestRoot
 clean:
 cleanall:  
   @del /f /q $(BIN_DIR)\*.pyd $(BIN_DIR)\*.dll
+  @del /f /q $(BASE_TOOLS_PATH)\Source\Python\*.pyc
   @for %%i in ($(APPLICATIONS)) do @del /f /q %%i
 
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source
  2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
                   ` (2 preceding siblings ...)
  2016-09-12 16:03 ` [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH Liming Gao
@ 2016-09-12 16:03 ` Liming Gao
  2016-09-13  0:13   ` Bjorge, Erik C
  2016-09-21  2:50 ` [Patch 0/4] Add support for running python tools from source on Windows Zhu, Yonghong
  4 siblings, 1 reply; 10+ messages in thread
From: Liming Gao @ 2016-09-12 16:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yonghong Zhu, Michael Kinney, Erik Bjorge

When python tool exe doesn't exist, toolsetup.bat will set up PYTHONPATH,
and set python tool dos script directory into system PATH.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/toolsetup.bat | 101 +++++++++++++++++++++---------------------------
 1 file changed, 44 insertions(+), 57 deletions(-)

diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index a64938d..6d416d4 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -247,39 +247,38 @@ if defined FORCE_REBUILD goto check_build_environment
 if defined REBUILD goto check_build_environment
 if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
 
-IF NOT EXIST "%EDK_TOOLS_BIN%\BootSectImage.exe" goto check_build_environment
+IF NOT EXIST "%EDK_TOOLS_BIN%\BootSectImage.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\EfiLdrImage.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenBootSector.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
+IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
+
+goto check_python_tools
+
+:check_c_tools
+  echo.
+  echo Binary C tools are missing. They are requried to be built from BaseTools Source.
+  echo.
+
+:check_python_tools
 IF NOT EXIST "%EDK_TOOLS_BIN%\build.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\EfiLdrImage.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenBootSector.exe" goto check_build_environment
 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFds.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_build_environment
 IF NOT EXIST "%EDK_TOOLS_BIN%\TargetTool.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_build_environment
 IF NOT EXIST "%EDK_TOOLS_BIN%\Trim.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_build_environment
-IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_build_environment
 
 goto end
 
 :check_build_environment
-
-  if not defined FORCE_REBUILD (
-    echo.
-    echo Rebuilding of tools is not required.  Binaries of the latest,
-    echo tested versions of the tools have been tested and included in the
-    echo EDK II repository.
-    echo.
-    echo If you really want to build the tools, use the ForceRebuild option.
-    echo.
-    goto end
-  )
+  if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable
 
   if not defined BASE_TOOLS_PATH (
      if not exist "Source\C\Makefile" (
@@ -289,10 +288,6 @@ goto end
        set BASE_TOOLS_PATH=%CD%
      )
   )
-  set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%
-
-  set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
-  set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
 
   if not defined PYTHON_HOME (
     if defined PYTHONHOME (
@@ -307,36 +302,30 @@ goto end
 
   @REM We have Python, now test for FreezePython application
   if not defined PYTHON_FREEZER_PATH (
-    @REM see if we can find FreezePython.ex
-    if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (
-      set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3
-    ) 
-    if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (
-      set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze
-    ) 
-    if exist "C:\cx_Freeze\FreezePython.exe" (
-        set PYTHON_FREEZER_PATH=C:\cx_Freeze
-    )
-    if exist "C:\cx_Freeze-3.0.3" (
-        set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3
-    )
-    if not defined PYTHON_FREEZER_PATH (
-      echo.
-      echo !!! WARNING !!! Will not be able to compile Python programs to .exe
-      echo Will setup environment to run Python scripts directly.
-      echo.
-      set "PATH=%BASETOOLS_PYTHON_SOURCE%\Trim;%PATH%"
-      set "PATH=%BASETOOLS_PYTHON_SOURCE%\GenFds;%PATH%"
-      set "PATH=%BASETOOLS_PYTHON_SOURCE%\build;%PATH%"
-      set PATHEXT=%PATHEXT%;.py
-    )
+    echo.
+    echo !!! WARNING !!! PYTHON_FREEZER_PATH environment variable is not set.
+    echo Setup environment to run Python scripts directly.
+    echo.
+    set "PATH=%PATH%;%BASE_TOOLS_PATH%\BinWrappers\WindowsLike"
   )
+
+  set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
+  set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
   
-  echo BASE_TOOLS_PATH     = %BASE_TOOLS_PATH%
-  echo     PYTHON_PATH     = %PYTHON_PATH%
-  echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
+  echo                PATH = %PATH%
+  echo         PYTHON_HOME = %PYTHON_HOME%
+  echo          PYTHONPATH = %PYTHONPATH%
+  if defined PYTHON_FREEZER_PATH (
+    echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
+  )
   echo.
 
+:VisualStudioAvailable
+  if not defined FORCE_REBUILD (
+    if not defined REBUILD (
+      goto end
+    )
+  )
   call "%EDK_TOOLS_PATH%\get_vsvars.bat"
   if not defined VCINSTALLDIR (
     @echo.
@@ -344,8 +333,6 @@ goto end
     @echo.
     goto end
   )
-
-:VisualStudioAvailable
   if not defined FORCE_REBUILD goto IncrementalBuild
 
 :CleanAndBuild
-- 
2.8.0.windows.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source
  2016-09-12 16:03 ` [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source Liming Gao
@ 2016-09-12 23:59   ` Bjorge, Erik C
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorge, Erik C @ 2016-09-12 23:59 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Kinney, Michael D

Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

> -----Original Message-----
> From: Gao, Liming
> Sent: Monday, September 12, 2016 9:03 AM
> To: edk2-devel@lists.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
> Subject: [Patch 1/4] BaseTools: Add Windows batch files to run python
> tool from Source
> 
> Add 13 windows batch files for every python tool.
> 
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Cc: Erik Bjorge <erik.c.bjorge@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/BinWrappers/WindowsLike/BPDG.bat                      | 3 +++
>  BaseTools/BinWrappers/WindowsLike/Ecc.bat                       | 3 +++
>  BaseTools/BinWrappers/WindowsLike/GenDepex.bat                  | 3 +++
>  BaseTools/BinWrappers/WindowsLike/GenFds.bat                    | 3 +++
>  BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat          | 3 +++
>  BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat             | 3 +++
>  BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat                 | 3 +++
>  BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat | 1 +
>  BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat         | 3 +++
>  BaseTools/BinWrappers/WindowsLike/TargetTool.bat                | 3 +++
>  BaseTools/BinWrappers/WindowsLike/Trim.bat                      | 3 +++
>  BaseTools/BinWrappers/WindowsLike/UPT.bat                       | 3 +++
>  BaseTools/BinWrappers/WindowsLike/build.bat                     | 3 +++
>  13 files changed, 37 insertions(+)
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/BPDG.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/Ecc.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/GenDepex.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/GenFds.bat
>  create mode 100644
> BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
>  create mode 100644
> BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
>  create mode 100644
> BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/TargetTool.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/Trim.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/UPT.bat
>  create mode 100644 BaseTools/BinWrappers/WindowsLike/build.bat
> 
> diff --git a/BaseTools/BinWrappers/WindowsLike/BPDG.bat
> b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/GenDepex.bat
> b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/GenDepex.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat
> b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
> b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
> b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
> b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git
> a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
> b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
> new file mode 100644
> index 0000000..df93365
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
> @@ -0,0 +1 @@
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\Rsa2048Sha256Sign\Rsa2048Sha256GenerateK
> eys.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
> b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/TargetTool.bat
> b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/TargetTool.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/Trim.bat
> b/BaseTools/BinWrappers/WindowsLike/Trim.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/Trim.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/UPT.bat
> b/BaseTools/BinWrappers/WindowsLike/UPT.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/UPT.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> diff --git a/BaseTools/BinWrappers/WindowsLike/build.bat
> b/BaseTools/BinWrappers/WindowsLike/build.bat
> new file mode 100644
> index 0000000..9fbb704
> --- /dev/null
> +++ b/BaseTools/BinWrappers/WindowsLike/build.bat
> @@ -0,0 +1,3 @@
> +@setlocal
> +@set ToolName=%~n0%
> +@%PYTHON_HOME%\python.exe
> %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
> --
> 2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode
  2016-09-12 16:03 ` [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode Liming Gao
@ 2016-09-13  0:00   ` Bjorge, Erik C
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorge, Erik C @ 2016-09-13  0:00 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Kinney, Michael D

Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

> -----Original Message-----
> From: Gao, Liming
> Sent: Monday, September 12, 2016 9:03 AM
> To: edk2-devel@lists.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
> Subject: [Patch 2/4] BaseTools: Update python tool to call external
> tools with shell true mode
> 
> Python tool may run from source as the dos batch files. So, update
> python
> code to call external tools with shell true mode.
> 
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Cc: Erik Bjorge <erik.c.bjorge@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/Common/VpdInfoFile.py | 7 ++++---
>  BaseTools/Source/Python/build/build.py        | 5 ++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py
> b/BaseTools/Source/Python/Common/VpdInfoFile.py
> index cc79ee2..d45fb4c 100644
> --- a/BaseTools/Source/Python/Common/VpdInfoFile.py
> +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
> @@ -233,14 +233,15 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
>      OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
> 
>      try:
> -        PopenObject = subprocess.Popen([ToolPath,
> +        PopenObject = subprocess.Popen(' '.join([ToolPath,
>                                          '-o', OutputBinFileName,
>                                          '-m', OutputMapFileName,
>                                          '-q',
>                                          '-f',
> -                                        VpdFileName],
> +                                        VpdFileName]),
>                                          stdout=subprocess.PIPE,
> -                                        stderr= subprocess.PIPE)
> +                                        stderr= subprocess.PIPE,
> +                                        shell=True)
>      except Exception, X:
>          EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE,
> ExtraData="%s" % (str(X)))
>      (out, error) = PopenObject.communicate()
> diff --git a/BaseTools/Source/Python/build/build.py
> b/BaseTools/Source/Python/build/build.py
> index be02119..20f726f 100644
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -266,14 +266,13 @@ def LaunchCommand(Command, WorkingDir):
>      # ubuntu may fail with an error message that the command is not
> found.
>      # So here we may need convert command from string to list instance.
>      if not isinstance(Command, list):
> -        if platform.system() != 'Windows':
> -            Command = Command.split()
> +        Command = Command.split()
> 
>      Proc = None
>      EndOfProcedure = None
>      try:
>          # launch the command
> -        Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ,
> cwd=WorkingDir, bufsize=-1)
> +        Proc = Popen(' '.join(Command), stdout=PIPE, stderr=PIPE,
> env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
> 
>          # launch two threads to read the STDOUT and STDERR
>          EndOfProcedure = Event()
> --
> 2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH
  2016-09-12 16:03 ` [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH Liming Gao
@ 2016-09-13  0:00   ` Bjorge, Erik C
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorge, Erik C @ 2016-09-13  0:00 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Kinney, Michael D

Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

> -----Original Message-----
> From: Gao, Liming
> Sent: Monday, September 12, 2016 9:03 AM
> To: edk2-devel@lists.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
> Subject: [Patch 3/4] BaseTools: Update Python Makefile not to depend on
> PYTHON_FREEZER_PATH
> 
> If PYTHON_FREEZER_PATH is not set, Python tools will not be freeze.
> 
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Cc: Erik Bjorge <erik.c.bjorge@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/Makefile | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Makefile
> b/BaseTools/Source/Python/Makefile
> index 28be671..e7755cd 100644
> --- a/BaseTools/Source/Python/Makefile
> +++ b/BaseTools/Source/Python/Makefile
> @@ -11,16 +11,17 @@
>  # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
> IMPLIED.
>  #
> 
> -!IFNDEF PYTHON_FREEZER_PATH
> -!ERROR PYTHON_FREEZER_PATH must be defined!
> +!IFNDEF PYTHON_HOME
> +!ERROR PYTHON_HOME must be defined!
>  !ENDIF
> 
> +!IFDEF PYTHON_FREEZER_PATH
>  !IF EXIST ($(PYTHON_FREEZER_PATH)\cxfreeze)
>  # Using cx_Freeze 4.2.3 with Python 2.7.2
>  FREEZE=$(PYTHON_HOME)\python $(PYTHON_FREEZER_PATH)\cxfreeze
>  !ELSE
> -# Using cx_Freeze 3.0.3 with Python 2.5.4
> -FREEZE=$(PYTHON_FREEZER_PATH)\FreezePython.exe
> +!ERROR PYTHON_FREEZER_PATH does not exist!
> +!ENDIF
>  !ENDIF
> 
> 
> MODULES=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_8,e
> ncodings.utf_16_le,encodings.latin_1,encodings.ascii
> @@ -236,7 +237,14 @@
> CMD_UPT=$(BASE_TOOLS_PATH)\Source\Python\UPT\Core\DependencyRules.py \
>      $(BASE_TOOLS_PATH)\Source\Python\UPT\Xml\XmlParser.py \
>      $(BASE_TOOLS_PATH)\Source\Python\UPT\Xml\XmlParserMisc.py
> 
> +!IFDEF PYTHON_FREEZER_PATH
>  all: SetPythonPath $(APPLICATIONS)
> +!ELSE
> +all:
> +  @echo.
> +  @echo !!! WARNING !!! PYTHON_FREEZER_PATH is not set.
> +  @echo Cannot make executable from Python code, executing python
> scripts instead !!!
> +!ENDIF
> 
>  SetPythonPath:
>    set PYTHONPATH=$(BASE_TOOLS_PATH)\Source\Python
> @@ -310,5 +318,6 @@ $(BIN_DIR)\TestRoot.pub.pem:
> $(BASE_TOOLS_PATH)\Source\Python\Pkcs7Sign\TestRoot
>  clean:
>  cleanall:
>    @del /f /q $(BIN_DIR)\*.pyd $(BIN_DIR)\*.dll
> +  @del /f /q $(BASE_TOOLS_PATH)\Source\Python\*.pyc
>    @for %%i in ($(APPLICATIONS)) do @del /f /q %%i
> 
> --
> 2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source
  2016-09-12 16:03 ` [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source Liming Gao
@ 2016-09-13  0:13   ` Bjorge, Erik C
  0 siblings, 0 replies; 10+ messages in thread
From: Bjorge, Erik C @ 2016-09-13  0:13 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Kinney, Michael D

Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

> -----Original Message-----
> From: Gao, Liming
> Sent: Monday, September 12, 2016 9:04 AM
> To: edk2-devel@lists.01.org
> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>
> Subject: [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH
> env to run python source
> 
> When python tool exe doesn't exist, toolsetup.bat will set up
> PYTHONPATH,
> and set python tool dos script directory into system PATH.
> 
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Cc: Erik Bjorge <erik.c.bjorge@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/toolsetup.bat | 101 +++++++++++++++++++++--------------------
> -------
>  1 file changed, 44 insertions(+), 57 deletions(-)
> 
> diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
> index a64938d..6d416d4 100755
> --- a/BaseTools/toolsetup.bat
> +++ b/BaseTools/toolsetup.bat
> @@ -247,39 +247,38 @@ if defined FORCE_REBUILD goto
> check_build_environment
>  if defined REBUILD goto check_build_environment
>  if not exist "%EDK_TOOLS_PATH%" goto check_build_environment
> 
> -IF NOT EXIST "%EDK_TOOLS_BIN%\BootSectImage.exe" goto
> check_build_environment
> +IF NOT EXIST "%EDK_TOOLS_BIN%\BootSectImage.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\EfiLdrImage.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenBootSector.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools
> +IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools
> +
> +goto check_python_tools
> +
> +:check_c_tools
> +  echo.
> +  echo Binary C tools are missing. They are requried to be built from
> BaseTools Source.
> +  echo.
> +
> +:check_python_tools
>  IF NOT EXIST "%EDK_TOOLS_BIN%\build.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\EfiLdrImage.exe" goto
> check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenBootSector.exe" goto
> check_build_environment
>  IF NOT EXIST "%EDK_TOOLS_BIN%\GenFds.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_build_environment
>  IF NOT EXIST "%EDK_TOOLS_BIN%\TargetTool.exe" goto
> check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto
> check_build_environment
>  IF NOT EXIST "%EDK_TOOLS_BIN%\Trim.exe" goto check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto
> check_build_environment
> -IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_build_environment
> 
>  goto end
> 
>  :check_build_environment
> -
> -  if not defined FORCE_REBUILD (
> -    echo.
> -    echo Rebuilding of tools is not required.  Binaries of the latest,
> -    echo tested versions of the tools have been tested and included in
> the
> -    echo EDK II repository.
> -    echo.
> -    echo If you really want to build the tools, use the ForceRebuild
> option.
> -    echo.
> -    goto end
> -  )
> +  if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable
> 
>    if not defined BASE_TOOLS_PATH (
>       if not exist "Source\C\Makefile" (
> @@ -289,10 +288,6 @@ goto end
>         set BASE_TOOLS_PATH=%CD%
>       )
>    )
> -  set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%
> -
> -  set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
> -  set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
> 
>    if not defined PYTHON_HOME (
>      if defined PYTHONHOME (
> @@ -307,36 +302,30 @@ goto end
> 
>    @REM We have Python, now test for FreezePython application
>    if not defined PYTHON_FREEZER_PATH (
> -    @REM see if we can find FreezePython.ex
> -    if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (
> -      set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3
> -    )
> -    if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (
> -      set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze
> -    )
> -    if exist "C:\cx_Freeze\FreezePython.exe" (
> -        set PYTHON_FREEZER_PATH=C:\cx_Freeze
> -    )
> -    if exist "C:\cx_Freeze-3.0.3" (
> -        set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3
> -    )
> -    if not defined PYTHON_FREEZER_PATH (
> -      echo.
> -      echo !!! WARNING !!! Will not be able to compile Python programs
> to .exe
> -      echo Will setup environment to run Python scripts directly.
> -      echo.
> -      set "PATH=%BASETOOLS_PYTHON_SOURCE%\Trim;%PATH%"
> -      set "PATH=%BASETOOLS_PYTHON_SOURCE%\GenFds;%PATH%"
> -      set "PATH=%BASETOOLS_PYTHON_SOURCE%\build;%PATH%"
> -      set PATHEXT=%PATHEXT%;.py
> -    )
> +    echo.
> +    echo !!! WARNING !!! PYTHON_FREEZER_PATH environment variable is
> not set.
> +    echo Setup environment to run Python scripts directly.
> +    echo.
> +    set "PATH=%PATH%;%BASE_TOOLS_PATH%\BinWrappers\WindowsLike"
>    )
> +
> +  set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python
> +  set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%
> 
> -  echo BASE_TOOLS_PATH     = %BASE_TOOLS_PATH%
> -  echo     PYTHON_PATH     = %PYTHON_PATH%
> -  echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
> +  echo                PATH = %PATH%
> +  echo         PYTHON_HOME = %PYTHON_HOME%
> +  echo          PYTHONPATH = %PYTHONPATH%
> +  if defined PYTHON_FREEZER_PATH (
> +    echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%
> +  )
>    echo.
> 
> +:VisualStudioAvailable
> +  if not defined FORCE_REBUILD (
> +    if not defined REBUILD (
> +      goto end
> +    )
> +  )
>    call "%EDK_TOOLS_PATH%\get_vsvars.bat"
>    if not defined VCINSTALLDIR (
>      @echo.
> @@ -344,8 +333,6 @@ goto end
>      @echo.
>      goto end
>    )
> -
> -:VisualStudioAvailable
>    if not defined FORCE_REBUILD goto IncrementalBuild
> 
>  :CleanAndBuild
> --
> 2.8.0.windows.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch 0/4] Add support for running python tools from source on Windows
  2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
                   ` (3 preceding siblings ...)
  2016-09-12 16:03 ` [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source Liming Gao
@ 2016-09-21  2:50 ` Zhu, Yonghong
  4 siblings, 0 replies; 10+ messages in thread
From: Zhu, Yonghong @ 2016-09-21  2:50 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org

Reviewed the series of 4 patches.
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Liming Gao
Sent: Tuesday, September 13, 2016 12:03 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch 0/4] Add support for running python tools from source on Windows

When Python tool exe files don't exist, toolsetup.bat will configure PYTHONPATH to python source code, and set BaseTools\BinWrappers\WindowsLike into system PATH directory. Then, windows batch files will be used to run python tools from source files. 

Liming Gao (4):
  BaseTools: Add Windows batch files to run python tool from Source
  BaseTools: Update python tool to call external tools with shell true
    mode
  BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH
  BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python
    source

 BaseTools/BinWrappers/WindowsLike/BPDG.bat         |   3 +
 BaseTools/BinWrappers/WindowsLike/Ecc.bat          |   3 +
 BaseTools/BinWrappers/WindowsLike/GenDepex.bat     |   3 +
 BaseTools/BinWrappers/WindowsLike/GenFds.bat       |   3 +
 .../BinWrappers/WindowsLike/GenPatchPcdTable.bat   |   3 +
 .../BinWrappers/WindowsLike/PatchPcdValue.bat      |   3 +
 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat    |   3 +
 .../WindowsLike/Rsa2048Sha256GenerateKeys.bat      |   1 +
 .../BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat  |   3 +
 BaseTools/BinWrappers/WindowsLike/TargetTool.bat   |   3 +
 BaseTools/BinWrappers/WindowsLike/Trim.bat         |   3 +
 BaseTools/BinWrappers/WindowsLike/UPT.bat          |   3 +
 BaseTools/BinWrappers/WindowsLike/build.bat        |   3 +
 BaseTools/Source/Python/Common/VpdInfoFile.py      |   7 +-
 BaseTools/Source/Python/Makefile                   |  17 +++-
 BaseTools/Source/Python/build/build.py             |   5 +-
 BaseTools/toolsetup.bat                            | 101 +++++++++------------
 17 files changed, 100 insertions(+), 67 deletions(-)  create mode 100644 BaseTools/BinWrappers/WindowsLike/BPDG.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Ecc.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenDepex.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenFds.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/GenPatchPcdTable.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/PatchPcdValue.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Pkcs7Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256GenerateKeys.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Rsa2048Sha256Sign.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/TargetTool.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/Trim.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/UPT.bat
 create mode 100644 BaseTools/BinWrappers/WindowsLike/build.bat

--
2.8.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-21  2:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 16:03 [Patch 0/4] Add support for running python tools from source on Windows Liming Gao
2016-09-12 16:03 ` [Patch 1/4] BaseTools: Add Windows batch files to run python tool from Source Liming Gao
2016-09-12 23:59   ` Bjorge, Erik C
2016-09-12 16:03 ` [Patch 2/4] BaseTools: Update python tool to call external tools with shell true mode Liming Gao
2016-09-13  0:00   ` Bjorge, Erik C
2016-09-12 16:03 ` [Patch 3/4] BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATH Liming Gao
2016-09-13  0:00   ` Bjorge, Erik C
2016-09-12 16:03 ` [Patch 4/4] BaseTools: Update toolsetup.bat to set PYTHONPATH env to run python source Liming Gao
2016-09-13  0:13   ` Bjorge, Erik C
2016-09-21  2:50 ` [Patch 0/4] Add support for running python tools from source on Windows Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox