public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: remove PyUtility and open the file with unbuffered
@ 2018-09-17  6:43 Yonghong Zhu
  2018-09-17  7:22 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-09-17  6:43 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

the PyUtility is not used, so we remove it.
And update the open file with unbuffered to avoid the case that the
file is not wrote but directly used in later when the host's multiple
thread is very strong.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/PyUtility/Makefile        |  25 -------
 BaseTools/Source/C/PyUtility/PyUtility.c     | 106 ---------------------------
 BaseTools/Source/C/PyUtility/setup.py        |  42 -----------
 BaseTools/Source/Python/Common/Misc.py       |  16 +---
 BaseTools/Source/Python/Common/PyUtility.pyd | Bin 6144 -> 0 bytes
 5 files changed, 3 insertions(+), 186 deletions(-)
 delete mode 100644 BaseTools/Source/C/PyUtility/Makefile
 delete mode 100644 BaseTools/Source/C/PyUtility/PyUtility.c
 delete mode 100644 BaseTools/Source/C/PyUtility/setup.py
 delete mode 100644 BaseTools/Source/Python/Common/PyUtility.pyd

diff --git a/BaseTools/Source/C/PyUtility/Makefile b/BaseTools/Source/C/PyUtility/Makefile
deleted file mode 100644
index 5829070..0000000
--- a/BaseTools/Source/C/PyUtility/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-## @file
-# Makefile
-#
-# Copyright (c) 2007 - 2014, 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.
-#
-
-!INCLUDE ..\Makefiles\ms.common
-
-APPNAME = GenSec
-
-LIBS = $(LIB_PATH)\Common.lib
-
-OBJECTS = PyUtility.obj
-
-#CFLAGS = $(CFLAGS) /nodefaultlib:libc.lib
-
-!INCLUDE ..\Makefiles\ms.app
-
diff --git a/BaseTools/Source/C/PyUtility/PyUtility.c b/BaseTools/Source/C/PyUtility/PyUtility.c
deleted file mode 100644
index d14b872..0000000
--- a/BaseTools/Source/C/PyUtility/PyUtility.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/** @file
-Python Utility
-
-Copyright (c) 2009 - 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.
-
-**/
-
-#include <Python.h>
-#include <Windows.h>
-#include <Common/UefiBaseTypes.h>
-
-/*
- SaveFileToDisk(FilePath, Content)
-*/
-STATIC
-PyObject*
-SaveFileToDisk (
-  PyObject    *Self,
-  PyObject    *Args
-  )
-{
-  CHAR8         *File;
-  UINT8         *Data;
-  UINTN         DataLength;
-  UINTN         WriteBytes;
-  UINTN         Status;
-  HANDLE        FileHandle;
-  PyObject      *ReturnValue = Py_False;
-
-  Status = PyArg_ParseTuple(
-            Args,
-            "ss#",
-            &File,
-            &Data,
-            &DataLength
-            );
-  if (Status == 0) {
-    return NULL;
-  }
-
-  FileHandle = CreateFile(
-                File,
-                GENERIC_WRITE,
-                FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_SHARE_DELETE,
-                NULL,
-                CREATE_ALWAYS,
-                FILE_ATTRIBUTE_NORMAL,
-                NULL
-                );
-  if (FileHandle == INVALID_HANDLE_VALUE) {
-    PyErr_SetString(PyExc_Exception, "File creation failure");
-    return NULL;
-  }
-
-  while (WriteFile(FileHandle, Data, DataLength, &WriteBytes, NULL)) {
-    if (DataLength <= WriteBytes) {
-      DataLength = 0;
-      break;
-    }
-
-    Data += WriteBytes;
-    DataLength -= WriteBytes;
-  }
-
-  if (DataLength != 0) {
-    // file saved unsuccessfully
-    PyErr_SetString(PyExc_Exception, "File write failure");
-    goto Done;
-  }
-
-  //
-  // Flush buffer may slow down the whole build performance (average 10s slower)
-  //
-  //if (!FlushFileBuffers(FileHandle)) {
-  //  PyErr_SetString(PyExc_Exception, "File flush failure");
-  //  goto Done;
-  //}
-
-  // success!
-  ReturnValue = Py_True;
-
-Done:
-  CloseHandle(FileHandle);
-  return ReturnValue;
-}
-
-STATIC INT8 SaveFileToDiskDocs[] = "SaveFileToDisk(): Make sure the file is saved to disk\n";
-
-STATIC PyMethodDef PyUtility_Funcs[] = {
-  {"SaveFileToDisk", (PyCFunction)SaveFileToDisk, METH_VARARGS, SaveFileToDiskDocs},
-  {NULL, NULL, 0, NULL}
-};
-
-PyMODINIT_FUNC
-initPyUtility(VOID) {
-  Py_InitModule3("PyUtility", PyUtility_Funcs, "Utilties Module Implemented C Language");
-}
-
-
diff --git a/BaseTools/Source/C/PyUtility/setup.py b/BaseTools/Source/C/PyUtility/setup.py
deleted file mode 100644
index e4d407d..0000000
--- a/BaseTools/Source/C/PyUtility/setup.py
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file
-# package and install PyEfiCompressor extension
-#
-#  Copyright (c) 2008, 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.
-#
-
-##
-# Import Modules
-#
-from distutils.core import setup, Extension
-import os
-
-if 'BASE_TOOLS_PATH' not in os.environ:
-    raise "Please define BASE_TOOLS_PATH to the root of base tools tree"
-
-BaseToolsDir = os.environ['BASE_TOOLS_PATH']
-setup(
-    name="PyUtility",
-    version="0.01",
-    ext_modules=[
-        Extension(
-            'PyUtility',
-            sources=[
-                'PyUtility.c'
-                ],
-            include_dirs=[
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Include'),
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Include', 'Ia32'),
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Common')
-                ],
-            )
-        ],
-  )
-
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 430bf6b..3a8e7ca 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -470,23 +470,13 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
             DirName = os.getcwd()
         if not os.access(DirName, os.W_OK):
             EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write permission on directory %s" % DirName)
 
     try:
-        if GlobalData.gIsWindows:
-            try:
-                from .PyUtility import SaveFileToDisk
-                if not SaveFileToDisk(File, Content):
-                    EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
-            except:
-                Fd = open(File, "wb")
-                Fd.write(Content)
-                Fd.close()
-        else:
-            Fd = open(File, "wb")
-            Fd.write(Content)
-            Fd.close()
+        Fd = open(File, "wb", 0)
+        Fd.write(Content)
+        Fd.close()
     except IOError as X:
         EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)
 
     return True
 
diff --git a/BaseTools/Source/Python/Common/PyUtility.pyd b/BaseTools/Source/Python/Common/PyUtility.pyd
deleted file mode 100644
index 856b508e4ea39a806fbe52264ac5e4db0956a2de..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 6144
zcmeHLe{hrK9e<LhG=-E#uhDwKNFnvQAuP$;(7Y>*LWve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O_nA+cbr!wFW!YlcW@)oLZaH8<V9i7+;x_YcMDKcm
I{@=v?8;(I;UjP6A

-- 
2.6.1.windows.1



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

* Re: [Patch] BaseTools: remove PyUtility and open the file with unbuffered
  2018-09-17  6:43 [Patch] BaseTools: remove PyUtility and open the file with unbuffered Yonghong Zhu
@ 2018-09-17  7:22 ` Zhu, Yonghong
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-09-17  7:22 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Please ignore this one, I will separate it into two patches.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
Sent: Monday, September 17, 2018 2:43 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>
Subject: [edk2] [Patch] BaseTools: remove PyUtility and open the file with unbuffered

the PyUtility is not used, so we remove it.
And update the open file with unbuffered to avoid the case that the file is not wrote but directly used in later when the host's multiple thread is very strong.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/C/PyUtility/Makefile        |  25 -------
 BaseTools/Source/C/PyUtility/PyUtility.c     | 106 ---------------------------
 BaseTools/Source/C/PyUtility/setup.py        |  42 -----------
 BaseTools/Source/Python/Common/Misc.py       |  16 +---
 BaseTools/Source/Python/Common/PyUtility.pyd | Bin 6144 -> 0 bytes
 5 files changed, 3 insertions(+), 186 deletions(-)  delete mode 100644 BaseTools/Source/C/PyUtility/Makefile
 delete mode 100644 BaseTools/Source/C/PyUtility/PyUtility.c
 delete mode 100644 BaseTools/Source/C/PyUtility/setup.py
 delete mode 100644 BaseTools/Source/Python/Common/PyUtility.pyd

diff --git a/BaseTools/Source/C/PyUtility/Makefile b/BaseTools/Source/C/PyUtility/Makefile
deleted file mode 100644
index 5829070..0000000
--- a/BaseTools/Source/C/PyUtility/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-## @file
-# Makefile
-#
-# Copyright (c) 2007 - 2014, 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.
-#
-
-!INCLUDE ..\Makefiles\ms.common
-
-APPNAME = GenSec
-
-LIBS = $(LIB_PATH)\Common.lib
-
-OBJECTS = PyUtility.obj
-
-#CFLAGS = $(CFLAGS) /nodefaultlib:libc.lib
-
-!INCLUDE ..\Makefiles\ms.app
-
diff --git a/BaseTools/Source/C/PyUtility/PyUtility.c b/BaseTools/Source/C/PyUtility/PyUtility.c
deleted file mode 100644
index d14b872..0000000
--- a/BaseTools/Source/C/PyUtility/PyUtility.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/** @file
-Python Utility
-
-Copyright (c) 2009 - 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.
-
-**/
-
-#include <Python.h>
-#include <Windows.h>
-#include <Common/UefiBaseTypes.h>
-
-/*
- SaveFileToDisk(FilePath, Content)
-*/
-STATIC
-PyObject*
-SaveFileToDisk (
-  PyObject    *Self,
-  PyObject    *Args
-  )
-{
-  CHAR8         *File;
-  UINT8         *Data;
-  UINTN         DataLength;
-  UINTN         WriteBytes;
-  UINTN         Status;
-  HANDLE        FileHandle;
-  PyObject      *ReturnValue = Py_False;
-
-  Status = PyArg_ParseTuple(
-            Args,
-            "ss#",
-            &File,
-            &Data,
-            &DataLength
-            );
-  if (Status == 0) {
-    return NULL;
-  }
-
-  FileHandle = CreateFile(
-                File,
-                GENERIC_WRITE,
-                FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_SHARE_DELETE,
-                NULL,
-                CREATE_ALWAYS,
-                FILE_ATTRIBUTE_NORMAL,
-                NULL
-                );
-  if (FileHandle == INVALID_HANDLE_VALUE) {
-    PyErr_SetString(PyExc_Exception, "File creation failure");
-    return NULL;
-  }
-
-  while (WriteFile(FileHandle, Data, DataLength, &WriteBytes, NULL)) {
-    if (DataLength <= WriteBytes) {
-      DataLength = 0;
-      break;
-    }
-
-    Data += WriteBytes;
-    DataLength -= WriteBytes;
-  }
-
-  if (DataLength != 0) {
-    // file saved unsuccessfully
-    PyErr_SetString(PyExc_Exception, "File write failure");
-    goto Done;
-  }
-
-  //
-  // Flush buffer may slow down the whole build performance (average 10s slower)
-  //
-  //if (!FlushFileBuffers(FileHandle)) {
-  //  PyErr_SetString(PyExc_Exception, "File flush failure");
-  //  goto Done;
-  //}
-
-  // success!
-  ReturnValue = Py_True;
-
-Done:
-  CloseHandle(FileHandle);
-  return ReturnValue;
-}
-
-STATIC INT8 SaveFileToDiskDocs[] = "SaveFileToDisk(): Make sure the file is saved to disk\n";
-
-STATIC PyMethodDef PyUtility_Funcs[] = {
-  {"SaveFileToDisk", (PyCFunction)SaveFileToDisk, METH_VARARGS, SaveFileToDiskDocs},
-  {NULL, NULL, 0, NULL}
-};
-
-PyMODINIT_FUNC
-initPyUtility(VOID) {
-  Py_InitModule3("PyUtility", PyUtility_Funcs, "Utilties Module Implemented C Language"); -}
-
-
diff --git a/BaseTools/Source/C/PyUtility/setup.py b/BaseTools/Source/C/PyUtility/setup.py
deleted file mode 100644
index e4d407d..0000000
--- a/BaseTools/Source/C/PyUtility/setup.py
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file
-# package and install PyEfiCompressor extension -# -#  Copyright (c) 2008, 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.
-#
-
-##
-# Import Modules
-#
-from distutils.core import setup, Extension -import os
-
-if 'BASE_TOOLS_PATH' not in os.environ:
-    raise "Please define BASE_TOOLS_PATH to the root of base tools tree"
-
-BaseToolsDir = os.environ['BASE_TOOLS_PATH'] -setup(
-    name="PyUtility",
-    version="0.01",
-    ext_modules=[
-        Extension(
-            'PyUtility',
-            sources=[
-                'PyUtility.c'
-                ],
-            include_dirs=[
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Include'),
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Include', 'Ia32'),
-                os.path.join(BaseToolsDir, 'Source', 'C', 'Common')
-                ],
-            )
-        ],
-  )
-
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 430bf6b..3a8e7ca 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -470,23 +470,13 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
             DirName = os.getcwd()
         if not os.access(DirName, os.W_OK):
             EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write permission on directory %s" % DirName)
 
     try:
-        if GlobalData.gIsWindows:
-            try:
-                from .PyUtility import SaveFileToDisk
-                if not SaveFileToDisk(File, Content):
-                    EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
-            except:
-                Fd = open(File, "wb")
-                Fd.write(Content)
-                Fd.close()
-        else:
-            Fd = open(File, "wb")
-            Fd.write(Content)
-            Fd.close()
+        Fd = open(File, "wb", 0)
+        Fd.write(Content)
+        Fd.close()
     except IOError as X:
         EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)
 
     return True
 
diff --git a/BaseTools/Source/Python/Common/PyUtility.pyd b/BaseTools/Source/Python/Common/PyUtility.pyd
deleted file mode 100644
index 856b508e4ea39a806fbe52264ac5e4db0956a2de..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 6144
zcmeHLe{hrK9e<LhG=-E#uhDwKNFnvQAuP$;(7Y>*LWve_ASI=x2o0fm+ayhs`sRIE
ztFXg`&gEXKZh9Oy-AS*z!|n7=Jsll53AD4Ib%zWqo1NFW>VoaG3PRm#-+i7pDYS^*
z?XPWjKDqDn<NN(S-`~&kzImNnA0-)t5Dh?<3F*N|Tba^-eU}7z{-PuE$&1-<6!fSn
z-zcc|2cpJSKGMW{TZ|3fa5y3ucXCEv3>yPs<GPJ*V@t%xEzilBYf6jmY~Hr|)Ld(5
z8a^6WA9@|@x3_eq$3vl$%KA6TI>C2^UQ_s)&|ek&^PzraJecO|R>n<%20xWK?Sacd
zNTo_cPUOE^HH{l4>VkQyY(nNzM^f0=^DycGMrEy6=4wJRmF3luxPYKRLjxHNo9MnP
zV`}+aAt4)peX@WkTPVkMTNxo+RM(}<LY_8WlN+p`nZ+@Cv0UKV1fV{In~HtZ*R<W!
zoJK-+Ea!b*!Ar;#brc9P2at{lW=boA>g6dmayyk_22kf|%x1JQLK4e)E);1X<YDR)
z5DMQ-7-zIHLe|b$elz_qL?AY%cS{Q&Hxhm4I+MmFtuq-rD^0qp&T3QsCO<N)cgcnW
zAjkUhIuc^$J+VH0uT*K$*93`wFANT<gCv;c$E>VMHWY(X8jnrM;v&iLBweWenv{@(
ziV$r*lSs*^Hff<vS1YZugAycAn_sobRU^OMkr0YU=X5?n!$Db~F0b_Xt_@PPNuTlN
z(&K4f*QT0ywaFBR$#jo+Hn!WOBf@vDC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Ib?a>^0MWO<sHif
z%RH;mT4-Hry~BF9wbt5XZLtbg$@)|43)aKdlh$GDgmub#Bf~K3n2k&=^CKqCJj^`C
z{G2(&^e}HR?=k;moW=JQpD6yg_={q#ZN6=>t;Dw0w$;{Z+haRoJ7ycUy>EMZ#j`7p
zt@z7|PgY!Bv7@B1Bvite#7Z71`9;Z*k}SK<zQlfq-EH^So9q$${r0EqhwLxdd+e{+
z`|PjT|7`!zK5oBcpR}u4Et|{U#4cn_>{8asvg{gmJzK?YXB*jO_FndWb|3o)`viNC
zeU5#JJ<1+u-)7%sKVXS5^;qpO_nA+cbr!wFW!YlcW@)oLZaH8<V9i7+;x_YcMDKcm
I{@=v?8;(I;UjP6A

--
2.6.1.windows.1

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


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

end of thread, other threads:[~2018-09-17  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-17  6:43 [Patch] BaseTools: remove PyUtility and open the file with unbuffered Yonghong Zhu
2018-09-17  7:22 ` Zhu, Yonghong

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