From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB6552096966D for ; Mon, 14 May 2018 11:09:24 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2018 11:09:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,401,1520924400"; d="scan'208";a="55814249" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 14 May 2018 11:09:23 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Date: Mon, 14 May 2018 11:09:09 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 Subject: [PATCH v1 00/11] BaseTools refactoring X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 May 2018 18:09:25 -0000 This patch cleans up BaseTools. On classes that are not instantiated and are deisgned as purely base classes, they get marked using the abstract base class to prevent instantiation. This prevents future errors. Create a new shared base class to centralize some code that was identical in multiple classes. cleanup to pass tuples to startswith and endswith instead of calling multiple times in a single expression. when an statement used a fixed list or tuple change to a set to allow hashing to speed up the operation. if the order was important then make sure that is a list. creating on the fly tuples serves no purpose. use with statements for file opening and make sure we dont over request file privilidge. this also seems to have cleaned up the error about the file AutoGenTimeStamp which was causing errors previously. lots of work to elimiate concatenating strings as this is a poor performing operation since strings are immutable and must be completely reallocated and moved for each concatenation. Jaben Carsey (11): BaseTools: decorate base classes to prevent instantiation BaseTools: Workspace - create a base class BaseTools: remove unused code BaseTools: remove repeated calls to startswith/endswith BaseTools: use set presence instead of series of equality BaseTools: refactor section generation BaseTools: refactor file opening/writing BaseTools: refactor to change object types BaseTools: refactor to stop re-allocating strings BaseTools: change to set for membership testing BaseTools: remove extra assignment BaseTools/Source/Python/AutoGen/AutoGen.py | 248 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenC.py | 75 +++--- BaseTools/Source/Python/AutoGen/GenDepex.py | 42 ++-- BaseTools/Source/Python/AutoGen/GenMake.py | 43 ++-- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 52 ++-- BaseTools/Source/Python/AutoGen/GenVar.py | 6 +- BaseTools/Source/Python/AutoGen/IdfClassObject.py | 21 +- BaseTools/Source/Python/AutoGen/StrGather.py | 22 +- BaseTools/Source/Python/AutoGen/UniClassObject.py | 8 +- BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py | 32 ++- BaseTools/Source/Python/BPDG/BPDG.py | 2 +- BaseTools/Source/Python/BPDG/GenVpd.py | 38 ++- BaseTools/Source/Python/Common/DataType.py | 37 ++- BaseTools/Source/Python/Common/Expression.py | 68 +++--- BaseTools/Source/Python/Common/Misc.py | 77 +++--- BaseTools/Source/Python/Common/Parsing.py | 2 +- BaseTools/Source/Python/Common/RangeExpression.py | 10 +- BaseTools/Source/Python/Common/String.py | 2 +- BaseTools/Source/Python/Common/TargetTxtClassObject.py | 21 +- BaseTools/Source/Python/Common/ToolDefClassObject.py | 4 +- BaseTools/Source/Python/Common/VariableAttributes.py | 6 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 4 +- BaseTools/Source/Python/CommonDataClass/CommonClass.py | 29 +-- BaseTools/Source/Python/CommonDataClass/DataClass.py | 47 +--- BaseTools/Source/Python/Ecc/Check.py | 123 +--------- BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 4 +- BaseTools/Source/Python/Ecc/Configuration.py | 10 +- BaseTools/Source/Python/Ecc/Database.py | 76 +----- BaseTools/Source/Python/Ecc/Ecc.py | 4 +- BaseTools/Source/Python/Ecc/MetaDataParser.py | 4 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 54 +++-- BaseTools/Source/Python/Ecc/c.py | 42 ++-- BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 9 +- BaseTools/Source/Python/Eot/EotGlobalData.py | 14 +- BaseTools/Source/Python/Eot/FileProfile.py | 8 +- BaseTools/Source/Python/Eot/Parser.py | 4 +- BaseTools/Source/Python/Eot/Report.py | 19 +- BaseTools/Source/Python/Eot/c.py | 2 +- BaseTools/Source/Python/GenFds/Capsule.py | 26 +- BaseTools/Source/Python/GenFds/CapsuleData.py | 11 +- BaseTools/Source/Python/GenFds/CompressSection.py | 24 +- BaseTools/Source/Python/GenFds/DataSection.py | 32 +-- BaseTools/Source/Python/GenFds/DepexSection.py | 8 +- BaseTools/Source/Python/GenFds/EfiSection.py | 111 ++++----- BaseTools/Source/Python/GenFds/FdfParser.py | 195 ++++++++------- BaseTools/Source/Python/GenFds/Ffs.py | 88 +++---- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 9 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 28 +-- BaseTools/Source/Python/GenFds/Fv.py | 112 +++------ BaseTools/Source/Python/GenFds/FvImageSection.py | 38 ++- BaseTools/Source/Python/GenFds/GenFds.py | 8 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 65 ++--- BaseTools/Source/Python/GenFds/GuidSection.py | 71 +++--- BaseTools/Source/Python/GenFds/OptRomInfStatement.py | 15 +- BaseTools/Source/Python/GenFds/OptionRom.py | 2 - BaseTools/Source/Python/GenFds/Region.py | 17 +- BaseTools/Source/Python/GenFds/Section.py | 231 ++++++++---------- BaseTools/Source/Python/GenFds/UiSection.py | 22 +- BaseTools/Source/Python/GenFds/VerSection.py | 26 +- BaseTools/Source/Python/GenFds/Vtf.py | 108 +++------ BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 21 +- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 39 +-- BaseTools/Source/Python/Table/Table.py | 6 +- BaseTools/Source/Python/Table/TableDataModel.py | 11 +- BaseTools/Source/Python/Table/TableReport.py | 47 ++-- BaseTools/Source/Python/TargetTool/TargetTool.py | 97 ++++---- BaseTools/Source/Python/Trim/Trim.py | 76 +++--- BaseTools/Source/Python/Workspace/BuildClassObject.py | 149 +++++------- BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 119 +++++----- BaseTools/Source/Python/Workspace/InfBuildData.py | 32 +-- BaseTools/Source/Python/Workspace/MetaDataTable.py | 10 +- BaseTools/Source/Python/Workspace/MetaFileCommentParser.py | 4 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 74 +++--- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 20 +- BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 18 +- BaseTools/Source/Python/build/BuildReport.py | 115 +++++---- BaseTools/Source/Python/build/build.py | 140 ++++++----- 78 files changed, 1478 insertions(+), 2018 deletions(-) -- 2.16.2.windows.1