From 27f38c6d6e3df494c0cf856ce87732cefe1dafdc Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Thu, 13 Sep 2018 14:12:00 +0800 Subject: [PATCH] BaseTools: remove the not used PyUtility file the PyUtility is not used, so we remove it. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- 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 | 23 +--- BaseTools/Source/Python/Common/PyUtility.pyd | Bin 6144 -> 0 bytes 5 files changed, 5 insertions(+), 191 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 58290703ba..0000000000 --- a/BaseTools/Source/C/PyUtility/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -## @file -# Makefile -# -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -!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 d14b87228d..0000000000 --- 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.
-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 -#include -#include - -/* - 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 e4d407d84f..0000000000 --- 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.
-# -# 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 69d306b939..2ac592d26b 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -477,25 +477,12 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True): 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: - if isinstance(Content, bytes): - with open(File, "wb") as Fd: - Fd.write(Content) - else: - with open(File, "w") as Fd: - Fd.write(Content) + if isinstance(Content, bytes): + with open(File, "wb") as Fd: + Fd.write(Content) else: - if isinstance(Content, bytes): - with open(File, "wb") as Fd: - Fd.write(Content) - else: - with open(File, "w") as Fd: - Fd.write(Content) + with open(File, "w") as Fd: + Fd.write(Content) except IOError as X: EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X) 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*LWve_ASI=x2o0fm+ayhs`sRIE ztFXg`&gEXKZh9Oy-AS*z!|n7=Jsll53AD4Ib%zWqo1NFW>VoaG3PRm#-+i7pDYS^* z?XPWjKDqDnyPsC2^UQ_s)&|ek&^PzraJecO|R>n<%20xWK?Sacd zNTo_cPUOE^HH{l4>VkQyY(nNzM^f0=^DycGMrEy6=4wJRmF3luxPYKRLjxHNo9MnP zV`}+aAt4)peX@WkTPVkMTNxo+RM(}g6dmayyk_22kf|%x1JQLK4e)E);1XVMHWY(X8jnrM;v&iLBweWenv{@( ziV$r*lSs*^HffZql!0qy^>s`gh4j!1x6Z&oPC(o)peVSiN4#2uH%xJ$t23^ zdt@j!D!*+-7O4s)|Xl4xKok%^ZfZAFh;h=os6h zQ%N~KswUfAQyb68gYevrvv9&E<>b>~wQD3>5g6hQo$KfVkVo^G#Q9S=gQfk#&Hf~O zkqx(lAxLW7@*slt_tC6=h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