git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@128 7335b...
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 12 Jun 2007 09:31:31 +0000 (09:31 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 12 Jun 2007 09:31:31 +0000 (09:31 +0000)
12 files changed:
Source/Python/DataType.py [new file with mode: 0644]
Source/Python/DecClassObject.py [new file with mode: 0644]
Source/Python/Dictionary.py [new file with mode: 0644]
Source/Python/DscClassObject.py [new file with mode: 0644]
Source/Python/EdkIIWorkspace.py [new file with mode: 0644]
Source/Python/EdkIIWorkspaceBuild.py [new file with mode: 0644]
Source/Python/EdkLogger.py [new file with mode: 0644]
Source/Python/Identification.py [new file with mode: 0644]
Source/Python/InfClassObject.py [new file with mode: 0644]
Source/Python/String.py [new file with mode: 0644]
Source/Python/TargetTxtClassObject.py [new file with mode: 0644]
Source/Python/ToolDefClassObject.py [new file with mode: 0644]

diff --git a/Source/Python/DataType.py b/Source/Python/DataType.py
new file mode 100644 (file)
index 0000000..84213e8
--- /dev/null
@@ -0,0 +1,237 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each tab used by INF/DEC/DSC files\r
+#\r
+\r
+#\r
+#Common Definitions\r
+#\r
+TAB_SPLIT = '.'\r
+TAB_COMMENT_SPLIT = '#'\r
+TAB_EQUAL_SPLIT = '='\r
+TAB_VALUE_SPLIT = '|'\r
+TAB_SPACE_SPLIT = ' '\r
+TAB_SECTION_START = '['\r
+TAB_SECTION_END = ']'\r
+TAB_OPTION_START = '<'\r
+TAB_OPTION_END  = '>'\r
+\r
+TAB_WORKSPACE1 = '${WORKSPACE}/'\r
+TAB_WORKSPACE2 = '$(WORKSPACE)/'\r
+\r
+TAB_ARCH_NULL = ''\r
+TAB_ARCH_COMMON = 'Common'\r
+TAB_ARCH_IA32 = 'IA32'\r
+TAB_ARCH_X64 = 'X64'\r
+TAB_ARCH_IPF = 'IPF'\r
+TAB_ARCH_EBC = 'EBC'\r
+\r
+ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_EBC]\r
+ARCH_LIST_FULL = [TAB_ARCH_COMMON] + ARCH_LIST \r
+\r
+SUP_MODULE_BASE = 'BASE'\r
+SUP_MODULE_SEC = 'SEC'\r
+SUP_MODULE_PEI_CORE = 'PEI_CORE'\r
+SUP_MODULE_PEIM = 'PEIM'\r
+SUP_MODULE_DXE_CORE = 'DXE_CORE'\r
+SUP_MODULE_DXE_DRIVER = 'DXE_DRIVER'\r
+SUP_MODULE_DXE_RUNTIME_DRIVER = 'DXE_RUNTIME_DRIVER'\r
+SUP_MODULE_DXE_SAL_DRIVER = 'DXE_SAL_DRIVER'\r
+SUP_MODULE_DXE_SMM_DRIVER = 'DXE_SMM_DRIVER'\r
+SUP_MODULE_UEFI_DRIVER = 'UEFI_DRIVER'\r
+SUP_MODULE_UEFI_APPLICATION = 'UEFI_APPLICATION'\r
+SUP_MODULE_USER_DEFINED = 'USER_DEFINED'\r
+\r
+SUP_MODULE_LIST = [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, \\r
+                   SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \\r
+                   SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED]\r
+SUP_MODULE_LIST_STRING = TAB_SPACE_SPLIT.join(l for l in SUP_MODULE_LIST)\r
+\r
+TAB_SOURCES = 'Sources'\r
+TAB_SOURCES_COMMON = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_SOURCES_IA32 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_SOURCES_X64 = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_SOURCES_IPF = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_SOURCES_EBC = TAB_SOURCES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_BINARIES = 'Binaries'\r
+TAB_BINARIES_COMMON = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_BINARIES_IA32 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_BINARIES_X64 = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_BINARIES_IPF = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_BINARIES_EBC = TAB_BINARIES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_INCLUDES = 'Includes'\r
+TAB_INCLUDES_COMMON = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_INCLUDES_IA32 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_INCLUDES_X64 = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_INCLUDES_IPF = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_INCLUDES_EBC = TAB_INCLUDES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_GUIDS = 'Guids'\r
+TAB_GUIDS_COMMON = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_GUIDS_IA32 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_GUIDS_X64 = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_GUIDS_IPF = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_GUIDS_EBC = TAB_GUIDS + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PROTOCOLS = 'Protocols'\r
+TAB_PROTOCOLS_COMMON = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PROTOCOLS_IA32 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PROTOCOLS_X64 = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PROTOCOLS_IPF = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PROTOCOLS_EBC = TAB_PROTOCOLS + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PPIS = 'Ppis'\r
+TAB_PPIS_COMMON = TAB_PPIS + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PPIS_IA32 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PPIS_X64 = TAB_PPIS + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PPIS_IPF = TAB_PPIS + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PPIS_EBC = TAB_PPIS + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_LIBRARY_CLASSES = 'LibraryClasses'\r
+TAB_LIBRARY_CLASSES_COMMON = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_LIBRARY_CLASSES_IA32 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_LIBRARY_CLASSES_X64 = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_LIBRARY_CLASSES_IPF = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_LIBRARY_CLASSES_EBC = TAB_LIBRARY_CLASSES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PACKAGES = 'Packages'\r
+TAB_PACKAGES_COMMON = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PACKAGES_IA32 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PACKAGES_X64 = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PACKAGES_IPF = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PACKAGES_EBC = TAB_PACKAGES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PCDS = 'Pcds'\r
+TAB_PCDS_FIXED_AT_BUILD = 'FixedAtBuild'\r
+TAB_PCDS_PATCHABLE_IN_MODULE = 'PatchableInModule'\r
+TAB_PCDS_FEATURE_FLAG = 'FeatureFlag'\r
+TAB_PCDS_DYNAMIC_EX = 'DynamicEx'\r
+TAB_PCDS_DYNAMIC = 'Dynamic'\r
+\r
+TAB_PCDS_FIXED_AT_BUILD_NULL = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD\r
+TAB_PCDS_FIXED_AT_BUILD_COMMON = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PCDS_FIXED_AT_BUILD_IA32 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PCDS_FIXED_AT_BUILD_X64 = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PCDS_FIXED_AT_BUILD_IPF = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PCDS_FIXED_AT_BUILD_EBC = TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PCDS_PATCHABLE_IN_MODULE_NULL = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE\r
+TAB_PCDS_PATCHABLE_IN_MODULE_COMMON = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PCDS_PATCHABLE_IN_MODULE_IA32 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PCDS_PATCHABLE_IN_MODULE_X64 = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PCDS_PATCHABLE_IN_MODULE_IPF = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PCDS_PATCHABLE_IN_MODULE_EBC = TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PCDS_FEATURE_FLAG_NULL = TAB_PCDS + TAB_PCDS_FEATURE_FLAG\r
+TAB_PCDS_FEATURE_FLAG_COMMON = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PCDS_FEATURE_FLAG_IA32 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PCDS_FEATURE_FLAG_X64 = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PCDS_FEATURE_FLAG_IPF = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PCDS_FEATURE_FLAG_EBC = TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PCDS_DYNAMIC_EX_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC_EX\r
+TAB_PCDS_DYNAMIC_EX_COMMON = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PCDS_DYNAMIC_EX_IA32 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PCDS_DYNAMIC_EX_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PCDS_DYNAMIC_EX_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PCDS_DYNAMIC_EX_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_PCDS_DYNAMIC_NULL = TAB_PCDS + TAB_PCDS_DYNAMIC\r
+TAB_PCDS_DYNAMIC_COMMON = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_PCDS_DYNAMIC_IA32 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_PCDS_DYNAMIC_X64 = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_PCDS_DYNAMIC_IPF = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_DEPEX = 'Depex'\r
+TAB_DEPEX_COMMON = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_DEPEX_IA32 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_DEPEX_X64 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_DEPEX_IPF = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_DEPEX_EBC = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_LIBRARIES = 'Libraries'\r
+TAB_LIBRARIES_COMMON = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_LIBRARIES_IA32 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_LIBRARIES_X64 = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_LIBRARIES_IPF = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_LIBRARIES_EBC = TAB_LIBRARIES + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_COMPONENTS = 'Components'\r
+TAB_COMPONENTS_COMMON = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_COMMON\r
+TAB_COMPONENTS_IA32 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IA32\r
+TAB_COMPONENTS_X64 = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_X64\r
+TAB_COMPONENTS_IPF = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_IPF\r
+TAB_COMPONENTS_EBC = TAB_COMPONENTS + TAB_SPLIT + TAB_ARCH_EBC\r
+\r
+TAB_BUILD_OPTIONS = 'BuildOptions'\r
+\r
+#Common Define\r
+TAB_COMMON_DEFINES = 'Defines'\r
+\r
+#Inf Definitions\r
+TAB_INF_DEFINES = TAB_COMMON_DEFINES\r
+TAB_INF_DEFINES_INF_VERSION = 'INF_VERSION'\r
+TAB_INF_DEFINES_BASE_NAME = 'BASE_NAME'\r
+TAB_INF_DEFINES_EDK_RELEASE_VERSION = 'EDK_RELEASE_VERSION'\r
+TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION = 'EFI_SPECIFICATION_VERSION'\r
+TAB_INF_DEFINES_FILE_GUID = 'FILE_GUID'\r
+TAB_INF_DEFINES_MODULE_TYPE = 'MODULE_TYPE'\r
+TAB_INF_DEFINES_BINARY_MODULE = 'BINARY_MODULE'\r
+TAB_INF_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME'\r
+TAB_INF_DEFINES_VERSION_STRING = 'VERSION_STRING'\r
+TAB_INF_DEFINES_VERSION = 'VERSION'\r
+TAB_INF_DEFINES_LIBRARY_CLASS = 'LIBRARY_CLASS'\r
+TAB_INF_DEFINES_PCD_DRIVER = 'PCD_DRIVER'\r
+TAB_INF_DEFINES_ENTRY_POINT = 'ENTRY_POINT'\r
+TAB_INF_DEFINES_UNLOAD_IMAGE = 'UNLOAD_IMAGE'\r
+TAB_INF_DEFINES_CONSTRUCTOR = 'CONSTRUCTOR'\r
+TAB_INF_DEFINES_DESTRUCTOR = 'DESTRUCTOR'\r
+TAB_INF_DEFINES_DEFINE = 'DEFINE'\r
+TAB_INF_DEFINES_CUSTOM_MAKEFILE = 'CUSTOM_MAKEFILE'\r
+TAB_INF_DEFINES_TOOLS_FLAGS = 'ToolFlags'      #TBD\r
+TAB_INF_DEFINES_MACRO_NAME = 'MacroName'       #TBD\r
+\r
+#Dec Definitions\r
+TAB_DEC_DEFINES = TAB_COMMON_DEFINES\r
+TAB_DEC_DEFINES_DEC_SPECIFICATION = 'DEC_SPECIFICATION'\r
+TAB_DEC_DEFINES_PACKAGE_NAME = 'PACKAGE_NAME'\r
+TAB_DEC_DEFINES_PACKAGE_GUID = 'PACKAGE_GUID'\r
+TAB_DEC_DEFINES_PACKAGE_VERSION = 'PACKAGE_VERSION'\r
+\r
+#Dsc Definitions\r
+TAB_DSC_DEFINES = TAB_COMMON_DEFINES\r
+TAB_DSC_DEFINES_PLATFORM_NAME = 'PLATFORM_NAME'\r
+TAB_DSC_DEFINES_PLATFORM_GUID = 'PLATFORM_GUID'\r
+TAB_DSC_DEFINES_PLATFORM_VERSION = 'PLATFORM_VERSION'\r
+TAB_DSC_DEFINES_DSC_SPECIFICATION = 'DSC_SPECIFICATION'\r
+TAB_DSC_DEFINES_OUTPUT_DIRECTORY = 'OUTPUT_DIRECTORY'\r
+TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES = 'SUPPORTED_ARCHITECTURES'\r
+TAB_DSC_DEFINES_BUILD_TARGETS = 'BUILD_TARGETS'\r
+TAB_DSC_DEFINES_SKUID_IDENTIFIER = 'SKUID_IDENTIFIER'\r
+\r
+#TargetTxt Definitions\r
+TAB_TAT_DEFINES_ACTIVE_PLATFORM = 'ACTIVE_PLATFORM'\r
+TAB_TAT_DEFINES_ACTIVE_MODULE = 'ACTIVE_MODULE'\r
+TAB_TAT_DEFINES_TOOL_CHAIN_CONF = 'TOOL_CHAIN_CONF'\r
+TAB_TAT_DEFINES_MULTIPLE_THREAD = 'MULTIPLE_THREAD'\r
+TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER = 'MAX_CONCURRENT_THREAD_NUMBER'\r
+TAB_TAT_DEFINES_TARGET = 'TARGET'\r
+TAB_TAT_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'\r
+TAB_TAT_DEFINES_TARGET_ARCH = 'TARGET_ARCH'\r
+\r
+#ToolDef Definitions\r
+TAB_TOD_DEFINES_TARGET = 'TARGET'\r
+TAB_TOD_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'\r
+TAB_TOD_DEFINES_TARGET_ARCH = 'TARGET_ARCH'\r
+TAB_TOD_DEFINES_COMMAND_TYPE = 'COMMAND_TYPE'\r
diff --git a/Source/Python/DecClassObject.py b/Source/Python/DecClassObject.py
new file mode 100644 (file)
index 0000000..b4c1398
--- /dev/null
@@ -0,0 +1,124 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each component of DEC file\r
+#\r
+\r
+import os\r
+from String import *\r
+from DataType import *\r
+from Identification import *\r
+from Dictionary import *\r
+\r
+class DecObject(object):\r
+  def __init__(self):\r
+    object.__init__()\r
+\r
+class DecDefines(DecObject):\r
+  def __init__(self):\r
+    self.DefinesDictionary = {\r
+      #Req\r
+      TAB_DEC_DEFINES_DEC_SPECIFICATION   : '',\r
+      TAB_DEC_DEFINES_PACKAGE_NAME        : '',\r
+      TAB_DEC_DEFINES_PACKAGE_GUID        : '',\r
+      TAB_DEC_DEFINES_PACKAGE_VERSION     : ''\r
+    }\r
+    \r
+class DecContents(DecObject):\r
+  def __init__(self):\r
+    self.Includes = []\r
+    self.Guids = []\r
+    self.Protocols = []\r
+    self.Ppis = []\r
+    self.LibraryClasses = []\r
+    self.PcdsFixedAtBuild = []\r
+    self.PcdsPatchableInModule = []\r
+    self.PcdsFeatureFlag = []\r
+    self.PcdsDynamic = []\r
+    self.PcdsDynamicEx = []\r
+\r
+class Dec(DecObject):\r
+  def __init__(self, filename = None, isMergeAllArches = False):\r
+    self.identification = Identification()\r
+    self.Defines = DecDefines()\r
+    \r
+    self.Contents = {}\r
+    for key in DataType.ARCH_LIST_FULL:\r
+      self.Contents[key] = DecContents()\r
+    \r
+    self.KeyList = [\r
+      TAB_INCLUDES, TAB_GUIDS, TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, \\r
+      TAB_PCDS_FIXED_AT_BUILD_NULL, TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \\r
+      TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL\r
+    ]\r
+  \r
+    if filename != None:\r
+      self.LoadDecFile(filename)\r
+      \r
+    if isMergeAllArches:\r
+      self.MergeAllArches()      \r
+  \r
+  def ParseDec(self, Lines, Key, KeyField):\r
+    GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
+      \r
+  def MergeAllArches(self):\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST:\r
+        Command = "self.Contents[arch]." + key + ".extend(" + "self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ")"\r
+        eval(Command)\r
+\r
+  def LoadDecFile(self, filename):\r
+    f = open(filename, 'r').read()\r
+    sects = f.split('[')\r
+    for sect in sects:\r
+      tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
+      if tab == TAB_INF_DEFINES.upper():\r
+        GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
+        continue\r
+      for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+        for key in self.KeyList:\r
+          if arch != DataType.TAB_ARCH_NULL:\r
+            target = (key + DataType.TAB_SPLIT + arch).upper()\r
+          else:\r
+            target = key.upper()\r
+          if tab == target:\r
+            if arch != DataType.TAB_ARCH_NULL:\r
+              Command = 'self.ParseDec(sect, tab, self.Contents[arch].' + key + ')'\r
+              eval(Command)\r
+              continue\r
+            else:\r
+              Command = "self.ParseDec(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
+              eval(Command)\r
+              continue\r
+    #EndFor\r
+\r
+  def showDec(self):\r
+    print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END\r
+    printDict(self.Defines.DefinesDictionary)\r
+\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST_FULL:\r
+        Command = "printList(TAB_SECTION_START + '" + \\r
+                  key + DataType.TAB_SPLIT + arch + \\r
+                  "' + TAB_SECTION_END, self.Contents[arch]." + key + ')'\r
+        eval(Command)\r
+\r
+if __name__ == '__main__':\r
+  p = Dec()\r
+  directory = 'C:\Documents and Settings\\hchen30\\Desktop\\prototype\\dec'\r
+  fileList = []\r
+  for f in os.listdir(directory):\r
+    if os.path.splitext(os.path.normcase(f))[1] == '.dec':\r
+      fileList.append(os.path.join(directory, os.path.normcase(f)))\r
+      \r
+      \r
+  for f in fileList:\r
+    p.LoadDecFile(f)\r
+    p.showDec()\r
diff --git a/Source/Python/Dictionary.py b/Source/Python/Dictionary.py
new file mode 100644 (file)
index 0000000..2113e94
--- /dev/null
@@ -0,0 +1,45 @@
+import EdkLogger\r
+from DataType import *\r
+\r
+#\r
+# Convert a text file to a dictionary\r
+#\r
+def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+  """Convert a text file to a dictionary of (name:value) pairs."""\r
+  try:\r
+    f = open(FileName,'r')\r
+  except:\r
+    EdkLogger.error('Open file failed')\r
+    return False\r
+  Keys = []\r
+  for Line in f:\r
+    if Line.startswith(CommentCharacter):\r
+      continue\r
+    LineList = Line.split(KeySplitCharacter,1)\r
+    if len(LineList) >= 2:\r
+      Key = LineList[0].split()\r
+      if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:\r
+        if ValueSplitFlag:\r
+          Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
+        else:\r
+          Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')\r
+        Keys += [Key[0]]\r
+  f.close()\r
+  return True\r
+\r
+def printDict(dict):\r
+  if dict != None:\r
+    KeyList = dict.keys()\r
+    for Key in KeyList:\r
+      if dict[Key] != '':\r
+        print Key + ' = ' + str(dict[Key])\r
+\r
+def printList(key, list):\r
+  if type(list) == type([]):\r
+      if len(list) > 0:\r
+        if key.find(TAB_SPLIT) != -1:\r
+          print "\n" + key\r
+          for i in list:\r
+            print i\r
+    \r
+      \r
diff --git a/Source/Python/DscClassObject.py b/Source/Python/DscClassObject.py
new file mode 100644 (file)
index 0000000..ab4f7ae
--- /dev/null
@@ -0,0 +1,137 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each component of DSC file\r
+#\r
+\r
+import os\r
+from String import *\r
+from DataType import *\r
+from Identification import *\r
+from Dictionary import *\r
+\r
+class DscObject(object):\r
+  def __init__(self):\r
+    object.__init__()\r
+\r
+class DscDefines(DscObject):\r
+  def __init__(self):\r
+    self.DefinesDictionary = {\r
+      #Req\r
+      TAB_DSC_DEFINES_PLATFORM_NAME             : '',\r
+      TAB_DSC_DEFINES_PLATFORM_GUID             : '',\r
+      TAB_DSC_DEFINES_PLATFORM_VERSION          : '',\r
+      TAB_DSC_DEFINES_DSC_SPECIFICATION         : '',\r
+      TAB_DSC_DEFINES_OUTPUT_DIRECTORY          : '',\r
+      TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES   : [],\r
+      TAB_DSC_DEFINES_BUILD_TARGETS             : [],\r
+      TAB_DSC_DEFINES_SKUID_IDENTIFIER          : []\r
+    }\r
+\r
+class DscSkuId(DscObject):\r
+  def __init__(self):\r
+    self.SkuId = {}     #{ [skuid : skuname], [skuid : skuname], ...}\r
+\r
+class DscContents(DscObject):\r
+  def __init__(self):\r
+    self.Libraries = []\r
+    self.Components = []        #[['component name', [lib1, lib2, lib3], [bo1, bo2, bo3]], ...]\r
+    self.LibraryClasses = []\r
+    self.PcdsFixedAtBuild = []\r
+    self.PcdsPatchableInModule = []\r
+    self.PcdsFeatureFlag = []\r
+    self.PcdsDynamic = []\r
+    self.PcdsDynamicEx = []\r
+    self.BuildOptions = []\r
+\r
+class Dsc(DscObject):\r
+  def __init__(self, filename = None, isMergeAllArches = False):\r
+    self.identification = Identification()\r
+    self.Defines = DscDefines()\r
+    self.Contents = {}\r
+\r
+    for key in DataType.ARCH_LIST_FULL:\r
+      self.Contents[key] = DscContents()\r
+    \r
+    self.KeyList = [\r
+      TAB_LIBRARIES, TAB_LIBRARY_CLASSES, TAB_BUILD_OPTIONS, TAB_PCDS_FIXED_AT_BUILD_NULL, \\r
+      TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \\r
+      TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL, TAB_COMPONENTS, TAB_BUILD_OPTIONS\r
+    ]\r
+    \r
+    if filename != None:\r
+      self.LoadDscFile(filename)\r
+      \r
+    if isMergeAllArches:\r
+      self.MergeAllArches()\r
+    \r
+  def ParseDsc(self, Lines, Key, KeyField):\r
+    newKey = SplitModuleType(Key)   \r
+    if newKey[0].find(TAB_LIBRARY_CLASSES.upper()) != -1:\r
+      GetLibraryClassesWithModuleType(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
+    elif newKey[0].find(TAB_COMPONENTS.upper()) != -1:\r
+      GetComponents(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
+    else:\r
+      GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
+  \r
+  def MergeAllArches(self):\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST:\r
+        Command = "self.Contents[arch]." + key + ".extend(" + "self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ")"\r
+        eval(Command)\r
+      \r
+  def LoadDscFile(self, filename):\r
+    EdkLogger.info('Open Dsc File:' + filename)\r
+    f = open(filename, 'r').read()\r
+    sects = f.split('[')\r
+    for sect in sects:\r
+      tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
+      if tab == TAB_INF_DEFINES.upper():\r
+        GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
+        continue\r
+      for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+        for key in self.KeyList:\r
+          if arch != DataType.TAB_ARCH_NULL:\r
+            target = (key + DataType.TAB_SPLIT + arch).upper()\r
+          else:\r
+            target = key.upper()\r
+          if SplitModuleType(tab)[0] == target:\r
+            if arch != DataType.TAB_ARCH_NULL:\r
+              Command = 'self.ParseDsc(sect, tab, self.Contents[arch].' + key + ')'\r
+              eval(Command)\r
+              continue\r
+            else:\r
+              Command = "self.ParseDsc(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
+              eval(Command)\r
+              continue\r
+\r
+  def showDsc(self):\r
+    print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END\r
+    printDict(self.Defines.DefinesDictionary)\r
+\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST_FULL:\r
+        Command = "printList(TAB_SECTION_START + '" + \\r
+                  key + DataType.TAB_SPLIT + arch + \\r
+                  "' + TAB_SECTION_END, self.Contents[arch]." + key + ')'\r
+        eval(Command)\r
+    \r
+if __name__ == '__main__':\r
+  p = Dsc()\r
+  directory = 'C:\MyWorkspace\\EdkModulePkg'\r
+  fileList = []\r
+  for f in os.listdir(directory):\r
+    if os.path.splitext(os.path.normcase(f))[1] == '.dsc':\r
+      fileList.append(os.path.join(directory, os.path.normcase(f)))\r
+      \r
+  for f in fileList:\r
+    p.LoadDscFile(f)\r
+    p.MergeAllArches()\r
+    p.showDsc()\r
diff --git a/Source/Python/EdkIIWorkspace.py b/Source/Python/EdkIIWorkspace.py
new file mode 100644 (file)
index 0000000..b833cce
--- /dev/null
@@ -0,0 +1,196 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+# This is the base class for applications that operate on an EDK II Workspace \r
+#\r
+\r
+import os, sys, time\r
+from XmlRoutines import *\r
+from DataType import *\r
+\r
+class EdkIIWorkspace:\r
+  def __init__(self):\r
+    """Collect WorkspaceDir from the environment, the Verbose command line flag, and detect an icon bitmap file."""\r
+\r
+    self.StartTime = time.time()\r
+    self.PrintRunTime   = False\r
+    self.PrintRunStatus = False\r
+    self.RunStatus      = ''\r
+    \r
+    if os.environ.get('WORKSPACE') == None:\r
+      print 'ERROR: WORKSPACE not defined.  Please run EdkSetup from the EDK II install directory.'\r
+      return False\r
+\r
+    self.CurrentWorkingDir = os.getcwd()\r
+    \r
+    self.WorkspaceDir = os.path.realpath(os.environ.get('WORKSPACE'))\r
+    (Drive, Path) = os.path.splitdrive(self.WorkspaceDir)\r
+    if Drive == '':\r
+      (Drive, CwdPath) = os.path.splitdrive(self.CurrentWorkingDir)\r
+      if Drive != '':\r
+        self.WorkspaceDir = Drive + Path\r
+    else:\r
+      self.WorkspaceDir = Drive.upper() + Path\r
+\r
+    self.WorkspaceRelativeWorkingDir = self.WorkspaceRelativePath (self.CurrentWorkingDir)\r
+      \r
+    try:\r
+      self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'),wx.BITMAP_TYPE_GIF)\r
+    except:\r
+      self.Icon = None\r
+      \r
+    self.Verbose = False\r
+    for arg in sys.argv:\r
+      if arg.lower() == '-v':\r
+        self.Verbose = True      \r
+\r
+    #return True\r
+\r
+  def Close(self):\r
+    if self.PrintRunTime:\r
+      Seconds = int(time.time() - self.StartTime)\r
+      if Seconds < 60:\r
+        print 'Run Time: %d seconds' % (Seconds)\r
+      else:\r
+        Minutes = Seconds / 60\r
+        Seconds = Seconds % 60\r
+        if Minutes < 60:\r
+          print 'Run Time: %d minutes %d seconds' % (Minutes, Seconds)\r
+        else:\r
+          Hours = Minutes / 60\r
+          Minutes = Minutes % 60\r
+          print 'Run Time: %d hours %d minutes %d seconds' % (Hours, Minutes, Seconds)\r
+    if self.RunStatus != '':\r
+      print self.RunStatus\r
+    \r
+  def WorkspaceRelativePath(self, FileName):\r
+    """Convert a full path filename to a workspace relative filename."""\r
+    FileName = os.path.realpath(FileName)\r
+    if FileName.find(self.WorkspaceDir) != 0:\r
+      return None\r
+    return FileName.replace (self.WorkspaceDir, '').strip('\\').strip('/')\r
+\r
+  def WorkspaceFile(self, FileName):\r
+    """Convert a workspace relative filename to a full path filename."""\r
+    return os.path.realpath(os.path.join(self.WorkspaceDir,FileName))\r
+\r
+  def WorkspacePathConvert(self, FileName):\r
+    """Convert ${WORKSPACE} to real path"""\r
+    return os.path.realpath(FileName.replace(TAB_WORKSPACE, self.WorkspaceDir))\r
+    \r
+  def XmlParseFile (self, FileName):\r
+    """Parse an XML file into a DOM and return the DOM."""\r
+    if self.Verbose:\r
+      print FileName\r
+    return XmlParseFile (self.WorkspaceFile(FileName))\r
+    \r
+  def XmlParseFileSection (self, FileName, SectionTag):\r
+    """Parse a section of an XML file into a DOM(Document Object Model) and return the DOM."""\r
+    if self.Verbose:\r
+      print FileName\r
+    return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)    \r
+\r
+  def XmlSaveFile (self, Dom, FileName):\r
+    """Save a DOM(Document Object Model) into an XML file."""\r
+    if self.Verbose:\r
+      print FileName\r
+    return XmlSaveFile (Dom, self.WorkspaceFile(FileName))\r
+\r
+  def ConvertTextFileToDictionary(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+    """Convert a workspace relative text file to a dictionary of (name:value) pairs."""\r
+    if self.Verbose:\r
+      print FileName\r
+    return ConvertTextFileToDictionary(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter)\r
+  \r
+  def ConvertDictionaryToTextFile(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+    """Convert a dictionary of (name:value) pairs to a workspace relative text file."""\r
+    if self.Verbose:\r
+      print FileName\r
+    return ConvertDictionaryToTextFile(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter)\r
+\r
+#\r
+# Convert a text file to a dictionary\r
+#\r
+def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+  """Convert a text file to a dictionary of (name:value) pairs."""\r
+  try:\r
+    f = open(FileName,'r')\r
+  except:\r
+    return False\r
+  Keys = []\r
+  for Line in f:\r
+    LineList = Line.split(KeySplitCharacter,1)\r
+    if len(LineList) >= 2:\r
+      Key = LineList[0].split()\r
+      if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys: \r
+        if ValueSplitFlag:\r
+          Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
+        else:\r
+          Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')\r
+        Keys += [Key[0]]\r
+  f.close()\r
+  return True\r
+\r
+def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+  """Convert a dictionary of (name:value) pairs to a text file."""\r
+  try:\r
+    f = open(FileName,'r')\r
+    Lines = []\r
+    Lines = f.readlines()\r
+    f.close()\r
+  except:\r
+    Lines = []\r
+  Keys = Dictionary.keys()\r
+  MaxLength = 0\r
+  for Key in Keys:\r
+    if len(Key) > MaxLength:\r
+      MaxLength = len(Key)\r
+  Index = 0\r
+  for Line in Lines:\r
+    LineList = Line.split(KeySplitCharacter,1)\r
+    if len(LineList) >= 2:\r
+      Key = LineList[0].split()\r
+      if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] in Dictionary:\r
+        if ValueSplitFlag:\r
+          Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, ' '.join(Dictionary[Key[0]]))\r
+        else:\r
+          Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, Dictionary[Key[0]])\r
+        Lines.pop(Index)\r
+        if Key[0] in Keys:\r
+          Lines.insert(Index,Line)\r
+          Keys.remove(Key[0])\r
+    Index += 1\r
+  for RemainingKey in Keys:\r
+    if ValueSplitFlag:\r
+      Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter,' '.join(Dictionary[RemainingKey])) \r
+    else:\r
+      Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, Dictionary[RemainingKey])\r
+    Lines.append(Line)\r
+  try:\r
+    f = open(FileName,'w')\r
+  except:\r
+    return False\r
+  f.writelines(Lines)\r
+  f.close()\r
+  return True\r
+\r
+def CreateDirectory(Directory):\r
+  if not os.access(Directory, os.F_OK):\r
+    os.makedirs (Directory)\r
+  \r
+def CreateFile(Directory, FileName, mode='w'):\r
+  CreateDirectory (Directory)\r
+  return open(os.path.join(Directory, FileName), mode)\r
+\r
+# This acts like the main() function for the script, unless it is 'import'ed into another\r
+# script.\r
+if __name__ == '__main__':\r
+  # Nothing to do here. Could do some unit tests\r
+  pass
\ No newline at end of file
diff --git a/Source/Python/EdkIIWorkspaceBuild.py b/Source/Python/EdkIIWorkspaceBuild.py
new file mode 100644 (file)
index 0000000..36929f9
--- /dev/null
@@ -0,0 +1,535 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+# This file is used to define each component of the build database\r
+#\r
+\r
+#\r
+# Import Modules\r
+#\r
+import os, string, copy, pdb\r
+import EdkLogger\r
+import DataType\r
+from EdkIIWorkspace import *\r
+from TargetTxtClassObject import *\r
+from ToolDefClassObject import *\r
+from InfClassObject import *\r
+from DecClassObject import *\r
+from DscClassObject import *\r
+from String import *\r
+\r
+class ModuleSourceFilesClassObject(object):\r
+  def __init__(self, Item):\r
+    self.SourceFile            = Item\r
+    self.TagName               = ''\r
+    self.ToolCode              = ''\r
+    self.ToolChainFamily       = ''\r
+    \r
+class PcdClassObject(object):\r
+  def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None):\r
+    self.TokenCName = Name\r
+    self.TokenSpaceGuidCName = Guid\r
+    self.Type = Type\r
+    self.DatumType = DatumType\r
+    self.DefaultValue = Value\r
+    self.TokenValue = Token\r
+    self.MaxDatumSize = MaxDatumSize\r
+\r
+class LibraryClassObject(object):\r
+  def __init__(self, Name = None, Type = None):\r
+    self.LibraryClass = Name\r
+    self.SupModList = []\r
+    if Type != None:\r
+      self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)\r
+    \r
+class ModuleBuildClassObject(object):\r
+  def __init__(self):\r
+    self.DescFilePath          = ''\r
+    self.BaseName              = ''\r
+    self.ModuleType            = ''\r
+    self.Guid                  = ''\r
+    self.Version               = ''\r
+    self.Specification         = ''\r
+    self.LibraryClass          = None      # LibraryClassObject\r
+    self.ModuleEntryPointList  = []\r
+    self.ModuleUnloadImageList = []\r
+    self.ConstructorList       = []\r
+    self.DestructorList        = []\r
+    \r
+    self.Sources               = []        #[ SourcesClassObject, ... ]\r
+    self.LibraryClasses        = {}        #{ [LibraryClassName, ModuleType] : LibraryClassInfFile }\r
+    self.Protocols             = []        #[ ProtocolName, ... ]\r
+    self.Ppis                  = []        #[ PpiName, ... ]\r
+    self.Guids                 = []        #[ GuidName, ... ]\r
+    self.Includes              = []        #[ IncludePath, ... ]\r
+    self.Packages              = []        #[ DecFileName, ... ]\r
+    self.Pcds                  = {}        #{ [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
+    self.BuildOptions          = {}        #{ [BuildOptionKey] : BuildOptionValue}\r
+    \r
+class PackageBuildClassObject(object):\r
+  def __init__(self):\r
+    self.DescFilePath          = ''\r
+    self.PackageName           = ''\r
+    self.Guid                  = ''\r
+    self.Version               = ''\r
+    \r
+    self.Protocols             = {}        #{ [ProtocolName] : Protocol Guid, ... }\r
+    self.Ppis                  = {}        #{ [PpiName] : Ppi Guid, ... }\r
+    self.Guids                 = {}        #{ [GuidName] : Guid, ... }\r
+    self.Includes              = []        #[ IncludePath, ... ]    \r
+    self.LibraryClasses        = {}        #{ [LibraryClassName] : LibraryClassInfFile }\r
+    self.Pcds                  = {}        #{ [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
+    \r
+class PlatformBuildClassObject(object):\r
+  def __init__(self):\r
+    self.DescFilePath          = ''\r
+    self.PlatformName          = ''\r
+    self.Guid                  = ''\r
+    self.Version               = ''\r
+    self.OutputDirectory       = ''\r
+    \r
+    self.Modules               = []        #[ InfFileName, ... ]\r
+    self.LibraryClasses        = {}        #{ (LibraryClassName, ModuleType) : LibraryClassInfFile }\r
+    self.Pcds                  = {}        #{ [(PcdCName, PcdGuidCName)] : PcdClassObject }\r
+    self.BuildOptions          = {}        #{ [BuildOptionKey] : BuildOptionValue }  \r
+\r
+class ItemBuild(object):\r
+  def __init__(self, arch, platform = None, package = None, module = None):\r
+    self.Arch                  = arch\r
+    self.PlatformDatabase      = {}        #{ [DscFileName] : PlatformBuildClassObject, ...}\r
+    self.PackageDatabase       = {}        #{ [DecFileName] : PacakgeBuildClassObject, ...}\r
+    self.ModuleDatabase        = {}        #{ [InfFileName] : ModuleBuildClassObject, ...}\r
+    \r
+class WorkspaceBuild(object):\r
+  def __init__(self):\r
+    self.Workspace              = EdkIIWorkspace()\r
+    self.PrintRunTime           = True\r
+    self.PlatformBuild          = True\r
+    self.TargetTxt              = TargetTxtClassObject()\r
+    self.ToolDef                = ToolDefClassObject()\r
+    self.InfDatabase            = {}       #{ [InfFileName] : InfClassObject}    \r
+    self.DecDatabase            = {}       #{ [DecFileName] : DecClassObject}\r
+    self.DscDatabase            = {}       #{ [DscFileName] : DscClassObject}\r
+    \r
+    self.Build                  = {}\r
+    for key in DataType.ARCH_LIST:\r
+      self.Build[key] = ItemBuild(key)\r
+    \r
+    self.TargetTxt.LoadTargetTxtFile(self.Workspace.WorkspaceFile('Tools/Conf/target.txt'))\r
+    self.ToolDef.LoadToolDefFile(self.Workspace.WorkspaceFile('Tools/Conf/tools_def.txt'))\r
+    \r
+    #get active platform\r
+    dscFileName = NormPath(self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM][0])\r
+    file = self.Workspace.WorkspaceFile(dscFileName)\r
+    if os.path.exists(file) and os.path.isfile(file):\r
+      self.DscDatabase[dscFileName] = Dsc(file, True)\r
+    else:\r
+      EdkLogger.error('No Active Platform')\r
+      return\r
+    \r
+    #parse platform to get module\r
+    for dsc in self.DscDatabase.keys():\r
+      dscObj = self.DscDatabase[dsc]\r
+      #Get all inf\r
+      for key in DataType.ARCH_LIST:\r
+        for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
+          self.AddToInfDatabase(dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)[1])\r
+        for index in range(len(dscObj.Contents[key].Components)):\r
+          self.AddToInfDatabase(dscObj.Contents[key].Components[index][0])\r
+        \r
+    #End For of Dsc\r
+    \r
+    #parse module to get package\r
+    for inf in self.InfDatabase.keys():\r
+      infObj = self.InfDatabase[inf]\r
+      #Get all dec\r
+      for key in DataType.ARCH_LIST:\r
+        for index in range(len(infObj.Contents[key].Packages)):\r
+          self.AddToDecDatabase(infObj.Contents[key].Packages[index])\r
+    \r
+    #Build databases\r
+    #Build PlatformDatabase\r
+    for dsc in self.DscDatabase.keys():\r
+      dscObj = self.DscDatabase[dsc]\r
+      \r
+      for key in DataType.ARCH_LIST:\r
+        pb = PlatformBuildClassObject()\r
+        pb.DescFilePath = dsc\r
+        pb.PlatformName = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_NAME]\r
+        pb.Guid = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_GUID]\r
+        pb.Version = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_VERSION]\r
+        pb.OutputDirectory = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_OUTPUT_DIRECTORY])\r
+      \r
+        #Module\r
+        for index in range(len(dscObj.Contents[key].Components)):\r
+          pb.Modules.append(NormPath(dscObj.Contents[key].Components[index][0]))\r
+        \r
+        #BuildOptions\r
+        for index in range(len(dscObj.Contents[key].BuildOptions)):\r
+          b = desObj.Contents[key].BuildOptions[index]\r
+          pb.BuildOptions[CleanString(b.split(DataType.TAB_EQUAL_SPLIT)[0])] = CleanString(b.split(DataType.TAB_EQUAL_SPLIT)[1])\r
+          \r
+        #LibraryClass\r
+        for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
+          #['DebugLib|MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf', 'DXE_CORE']\r
+          list = dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)\r
+          type = dscObj.Contents[key].LibraryClasses[index][1]\r
+          pb.LibraryClasses[(list[0], type)] = NormPath(list[1])\r
+\r
+        #Pcds\r
+        for index in range(len(dscObj.Contents[key].PcdsFixedAtBuild)):\r
+          pcd = dscObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD, None, None, pcd[2], None)\r
+        for index in range(len(dscObj.Contents[key].PcdsPatchableInModule)):\r
+          pcd = dscObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, None, pcd[2], None)\r
+        for index in range(len(dscObj.Contents[key].PcdsFeatureFlag)):\r
+          pcd = dscObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, None, pcd[2], None)\r
+        for index in range(len(dscObj.Contents[key].PcdsDynamic)):\r
+          pcd = dscObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC, None, None, pcd[2], None)\r
+        for index in range(len(dscObj.Contents[key].PcdsDynamicEx)):\r
+          pcd = dscObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX, None, None, pcd[2], None)\r
+        \r
+        self.Build[key].PlatformDatabase[dsc] = pb\r
+        pb = None  \r
+      #End of Arch List Go Through  \r
+        \r
+    #End of Dsc Go Through\r
+    \r
+    #End of build PlatformDatabase\r
+    \r
+    #Build PackageDatabase\r
+    for dec in self.DecDatabase.keys():\r
+      decObj = self.DecDatabase[dec]\r
+\r
+      for key in DataType.ARCH_LIST:\r
+        pb = PackageBuildClassObject()\r
+        #Defines\r
+        pb.DescFilePath = dec\r
+        pb.PackageName = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_NAME]\r
+        pb.Guid = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_GUID]\r
+        pb.Version = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_VERSION]\r
+        \r
+        #Protocols\r
+        for index in range(len(decObj.Contents[key].Protocols)):\r
+          list = decObj.Contents[key].Protocols[index].split(DataType.TAB_EQUAL_SPLIT)\r
+          pb.Protocols[CleanString(list[0])] = CleanString(list[1])\r
+\r
+        #Ppis\r
+        for index in range(len(decObj.Contents[key].Ppis)):\r
+          list = decObj.Contents[key].Ppis[index].split(DataType.TAB_EQUAL_SPLIT)\r
+          pb.Ppis[CleanString(list[0])] = CleanString(list[1])      \r
+\r
+        #Guids\r
+        for index in range(len(decObj.Contents[key].Guids)):\r
+          list = decObj.Contents[key].Guids[index].split(DataType.TAB_EQUAL_SPLIT)\r
+          pb.Guids[CleanString(list[0])] = CleanString(list[1])    \r
+        \r
+        #Includes\r
+        for index in range(len(decObj.Contents[key].Includes)):\r
+          pb.Includes.append(NormPath(decObj.Contents[key].Includes[index]))\r
+      \r
+        #LibraryClasses\r
+        for index in range(len(decObj.Contents[key].LibraryClasses)):\r
+          list = decObj.Contents[key].LibraryClasses[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.LibraryClasses[CleanString(list[0])] = NormPath(CleanString(list[1]))\r
+                        \r
+        #Pcds\r
+        for index in range(len(decObj.Contents[key].PcdsFixedAtBuild)):\r
+          pcd = decObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_FIXED_AT_BUILD, pcd[3], pcd[4], pcd[1], None)\r
+        for index in range(len(decObj.Contents[key].PcdsPatchableInModule)):\r
+          pcd = decObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, pcd[3], pcd[4], pcd[1], None)\r
+        for index in range(len(decObj.Contents[key].PcdsFeatureFlag)):\r
+          pcd = decObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_FEATURE_FLAG, pcd[3], pcd[4], pcd[1], None)\r
+        for index in range(len(decObj.Contents[key].PcdsDynamic)):\r
+          pcd = decObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC, pcd[3], pcd[4], pcd[1], None)\r
+        for index in range(len(decObj.Contents[key].PcdsDynamicEx)):\r
+          pcd = decObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC_EX, pcd[3], pcd[4], pcd[1], None)\r
+      \r
+        #Add to database\r
+        self.Build[key].PackageDatabase[dec] = pb\r
+        pb = None  \r
+      #End of Arch List Go Through\r
+    \r
+    #End of Dec Go Through  \r
+    \r
+    #End of build PackageDatabase\r
+  \r
+    #Build ModuleDatabase\r
+    for inf in self.InfDatabase.keys():\r
+      infObj = self.InfDatabase[inf]\r
+      \r
+      for key in DataType.ARCH_LIST:\r
+        #Defines\r
+        pb = ModuleBuildClassObject()\r
+        pb.DescFilePath = inf\r
+        pb.BaseName = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_BASE_NAME]\r
+        pb.Guid = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_FILE_GUID]\r
+        pb.Version = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING]\r
+        pb.ModuleType = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_MODULE_TYPE]\r
+        pb.Specification = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION]\r
+        \r
+        LibraryClass = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_LIBRARY_CLASS]\r
+        if LibraryClass != '':\r
+          l = LibraryClass.split(DataType.TAB_VALUE_SPLIT)\r
+          if len(l) == 2:\r
+            pb.LibraryClass = LibraryClassObject(l[0], l[1])\r
+          elif len(l) == 1:\r
+            pb.LibraryClass = LibraryClassObject(l[0], DataType.SUP_MODULE_LIST_STRING)\r
+\r
+        pb.ModuleEntryPointList = (infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT])\r
+        pb.ModuleUnloadImageList = (infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE])\r
+        pb.ConstructorList = (infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR])\r
+        pb.DestructorList = (infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR])\r
+\r
+        #Sources\r
+        for index in range(len(infObj.Contents[key].Sources)):\r
+          pb.Sources.append(ModuleSourceFilesClassObject(NormPath(infObj.Contents[key].Sources[index])))\r
+\r
+        #Protocols\r
+        for index in range(len(infObj.Contents[key].Protocols)):\r
+          pb.Protocols.append(infObj.Contents[key].Protocols[index])\r
+      \r
+        #Ppis\r
+        for index in range(len(infObj.Contents[key].Ppis)):\r
+          pb.Ppis.append(infObj.Contents[key].Ppis[index])\r
+                \r
+        #Guids\r
+        for index in range(len(infObj.Contents[key].Guids)):\r
+          pb.Guids.append(infObj.Contents[key].Guids[index])\r
+      \r
+        #Includes\r
+        for index in range(len(infObj.Contents[key].Includes)):\r
+          pb.Includes.append(NormPath(infObj.Contents[key].Includes[index]))\r
+      \r
+        #Packages\r
+        for index in range(len(infObj.Contents[key].Packages)):\r
+          pb.Packages.append(NormPath(infObj.Contents[key].Packages[index]))\r
+          \r
+        #BuildOptions\r
+        for index in range(len(infObj.Contents[key].BuildOptions)):\r
+          b = infObj.Contents[key].BuildOptions[index]\r
+          pb.BuildOptions[CleanString(b.split(DataType.TAB_EQUAL_SPLIT)[0])] = CleanString(b.split(DataType.TAB_EQUAL_SPLIT)[1])\r
+        self.FindBuildOptions(key, inf, pb.BuildOptions)\r
+        \r
+        #LibraryClasses\r
+        for index in range(len(infObj.Contents[key].LibraryClasses)):\r
+          #Get LibraryClass name and default instance if existing\r
+          list = infObj.Contents[key].LibraryClasses[index].split(DataType.TAB_VALUE_SPLIT)\r
+          if len(list) < 2:\r
+            v = ''\r
+          else:\r
+            v = list[1]\r
+          \r
+          if pb.LibraryClass != None:\r
+            #For Library\r
+            for type in pb.LibraryClass.SupModList:\r
+              instance = self.FindLibraryClassInstanceOfLibrary(CleanString(list[0]), key, type)\r
+              if instance != None:\r
+                v = instance\r
+                pb.LibraryClasses[(CleanString(list[0]), type)] = NormPath(CleanString(v))\r
+          else:\r
+            #For Module            \r
+            instance = self.FindLibraryClassInstanceOfModule(CleanString(list[0]), key, pb.ModuleType, inf) \r
+            if instance != None:\r
+              v = instance\r
+              pb.LibraryClasses[(CleanString(list[0]), pb.ModuleType)] = NormPath(CleanString(v))\r
+\r
+        #Pcds\r
+        for index in range(len(infObj.Contents[key].PcdsFixedAtBuild)):\r
+          pcd = infObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD)\r
+        for index in range(len(infObj.Contents[key].PcdsPatchableInModule)):\r
+          pcd = infObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE)\r
+          #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, None, None, None)          \r
+        for index in range(len(infObj.Contents[key].PcdsFeatureFlag)):\r
+          pcd = infObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG)\r
+          #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, None, None, None)          \r
+        for index in range(len(infObj.Contents[key].PcdsDynamic)):\r
+          pcd = infObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC)\r
+          #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC, None, None, None, None)\r
+        for index in range(len(infObj.Contents[key].PcdsDynamicEx)):\r
+          pcd = infObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
+          pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX)\r
+          #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX, None, None, None, None)\r
+                    \r
+        #Add to database\r
+        self.Build[key].ModuleDatabase[inf] = pb\r
+        pb = None  \r
+      #End of Arch List Go Through\r
+    \r
+    #End of Inf Go Through\r
+    \r
+    #End of build ModuleDatabase  \r
+  \r
+  #End of self.Init\r
+  \r
+  def AddToInfDatabase(self, infFileName):\r
+    infFileName = NormPath(infFileName)\r
+    file = self.Workspace.WorkspaceFile(infFileName)\r
+    if os.path.exists(file) and os.path.isfile(file):\r
+      if infFileName not in self.InfDatabase:\r
+        self.InfDatabase[infFileName] = Inf(file, True)\r
+        \r
+  def AddToDecDatabase(self, decFileName):\r
+    decFileName = NormPath(decFileName)\r
+    file = self.Workspace.WorkspaceFile(decFileName)\r
+    if os.path.exists(file) and os.path.isfile(file):\r
+      if decFileName not in self.DecDatabase:\r
+        self.DecDatabase[decFileName] = Dec(file, True)\r
+        \r
+  def FindLibraryClassInstanceOfModule(self, lib, arch, moduleType, moduleName):\r
+    for dsc in self.DscDatabase.keys():\r
+      #First find if exist in <LibraryClass> of <Components> from dsc file      \r
+      dscObj = self.DscDatabase[dsc]\r
+      for index in range(len(dscObj.Contents[arch].Components)):\r
+        if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][1]) > 0:\r
+          #Search each library class\r
+          LibList = dscObj.Contents[arch].Components[index][1]\r
+          for indexOfLib in range(len(LibList)):\r
+            if LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[0] == lib:\r
+              return LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[1]\r
+      \r
+      #Second find if exist in <LibraryClass> of <LibraryClasses> from dsc file      \r
+      if (lib, moduleType) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
+        return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, moduleType)]\r
+      elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
+        return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
+      \r
+  def FindLibraryClassInstanceOfLibrary(self, lib, arch, type):\r
+    for dsc in self.DscDatabase.keys():\r
+      dscObj = self.DscDatabase[dsc]\r
+      if (lib, type) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
+        return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, type)]\r
+      elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
+        return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
+      \r
+  def FindBuildOptions(self, arch, moduleName, BuildOptions):\r
+    for dsc in self.DscDatabase.keys():\r
+      #First find if exist in <BuildOptions> of <Components> from dsc file\r
+      dscObj = self.DscDatabase[dsc]\r
+      for index in range(len(dscObj.Contents[arch].Components)):\r
+        if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][2]) > 0:\r
+          list = dscObj.Contents[arch].Components[index][2]\r
+          for l in list:\r
+            BuildOptions[CleanString(l.split(DataType.TAB_EQUAL_SPLIT)[0])] = CleanString(l.split(DataType.TAB_EQUAL_SPLIT)[1])\r
+            \r
+  def FindPcd(self, arch, CName, GuidCName, Type):\r
+    DatumType = ''\r
+    DefaultValue = ''\r
+    TokenValue = ''\r
+    MaxDatumSize = ''\r
+    for dsc in self.Build[arch].PlatformDatabase.keys():\r
+      platform = self.Build[arch].PlatformDatabase[dsc]\r
+      pcds = platform.Pcds\r
+      if (CName, GuidCName) in pcds:\r
+        DatumType = pcds[(CName, GuidCName)].DatumType\r
+        DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
+        TokenValue = pcds[(CName, GuidCName)].TokenValue\r
+        MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
+        break\r
+\r
+    for dec in self.Build[arch].PackageDatabase.keys():\r
+      package = self.Build[arch].PackageDatabase[dec]\r
+      pcds = package.Pcds\r
+      if (CName, GuidCName) in pcds:\r
+        DatumType = pcds[(CName, GuidCName)].DatumType\r
+        #DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
+        TokenValue = pcds[(CName, GuidCName)].TokenValue\r
+        #MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
+        break\r
+    \r
+    return PcdClassObject(CName, GuidCName, Type, DatumType, DefaultValue, TokenValue, MaxDatumSize)\r
+        \r
+        \r
+# This acts like the main() function for the script, unless it is 'import'ed into another\r
+# script.\r
+if __name__ == '__main__':\r
+\r
+  # Nothing to do here. Could do some unit tests.\r
+  ewb = WorkspaceBuild()\r
+  #printDict(ewb.TargetTxt.TargetTxtDictionary)\r
+  #printDict(ewb.ToolDef.ToolsDefTxtDictionary)\r
+#  print ewb.DscDatabase\r
+#  print ewb.InfDatabase\r
+#  print ewb.DecDatabase\r
+  \r
+  #\r
+  for key in DataType.ARCH_LIST:\r
+    print key\r
+    print 'Platform'\r
+    for platform in ewb.Build[key].PlatformDatabase.keys():\r
+      p = ewb.Build[key].PlatformDatabase[platform]\r
+      print p.DescFilePath   \r
+      print p.PlatformName   \r
+      print p.Guid           \r
+      print p.Version\r
+      print p.OutputDirectory        \r
+      print p.Modules        \r
+      print p.LibraryClasses \r
+      print p.Pcds           \r
+      print p.BuildOptions   \r
+    #End of Platform\r
+  \r
+    print 'package'\r
+    for package in ewb.Build[key].PackageDatabase.keys():\r
+      p = ewb.Build[key].PackageDatabase[package]\r
+      print p.DescFilePath  \r
+      print p.PackageName   \r
+      print p.Guid          \r
+      print p.Version       \r
+      print p.Protocols     \r
+      print p.Ppis          \r
+      print p.Guids         \r
+      print p.Includes      \r
+      print p.LibraryClasses\r
+      print p.Pcds          \r
+    #End of Package\r
+    \r
+    print 'module'\r
+    for module in ewb.Build[key].ModuleDatabase.keys():\r
+      p = ewb.Build[key].ModuleDatabase[module]\r
+      print p.DescFilePath          \r
+      print p.BaseName             \r
+      print p.ModuleType           \r
+      print p.Guid                 \r
+      print p.Version\r
+      print p.Specification\r
+      if p.LibraryClass != None:\r
+        print p.LibraryClass.LibraryClass\r
+        print p.LibraryClass.SupModList\r
+      print p.ModuleEntryPointList \r
+      print p.ModuleUnloadImageList\r
+      print p.ConstructorList      \r
+      print p.DestructorList       \r
+                                   \r
+      print p.Sources              \r
+      print p.LibraryClasses       \r
+      print p.Protocols            \r
+      print p.Ppis                 \r
+      print p.Guids                \r
+      print p.Includes             \r
+      print p.Packages             \r
+      print p.Pcds                 \r
+      print p.BuildOptions\r
+    #End of Module  \r
+      \r
+  #End of Arch List\r
diff --git a/Source/Python/EdkLogger.py b/Source/Python/EdkLogger.py
new file mode 100644 (file)
index 0000000..c838459
--- /dev/null
@@ -0,0 +1,90 @@
+import sys, os, logging, traceback, inspect
+
+DEBUG   = logging.DEBUG
+VERBOSE = logging.INFO
+INFO    = logging.WARN
+WARNING = logging.ERROR
+ERROR   = logging.CRITICAL
+
+_log_levels = [DEBUG, VERBOSE, INFO, WARNING, ERROR]
+
+_debug_logger = logging.getLogger("edk2_debug")
+_debug_logger.setLevel(INFO)
+_debug_ch = logging.StreamHandler()
+# _ch.setLevel(logging.INFO)
+_debug_formatter = logging.Formatter("%(pathname)s:%(lineno)d: [%(asctime)s] %(funcName)s() : %(message)s")
+_debug_ch.setFormatter(_debug_formatter)
+_debug_logger.addHandler(_debug_ch)
+
+_verbose_logger = logging.getLogger("edk2_verbose")
+_verbose_logger.setLevel(INFO)
+_verbose_ch = logging.StreamHandler()
+# _ch.setLevel(logging.CRITICAL)
+_verbose_formatter = logging.Formatter("%(message)s")
+_verbose_ch.setFormatter(_verbose_formatter)
+_verbose_logger.addHandler(_verbose_ch)
+
+_info_logger = logging.getLogger("edk2_info")
+_info_logger.setLevel(INFO)
+_info_ch = logging.StreamHandler()
+#_ch.setLevel(logging.INFO)
+_info_formatter = logging.Formatter("%(message)s")
+_info_ch.setFormatter(_info_formatter)
+_info_logger.addHandler(_info_ch)
+
+_warn_logger = logging.getLogger("edk2_warn")
+_warn_logger.setLevel(INFO)
+_warn_ch = logging.StreamHandler()
+# _ch.setLevel(logging.INFO)
+_warn_formatter = logging.Formatter("\t%(pathname)s:%(lineno)d: [WARNING] %(funcName)s() : %(message)s")
+_warn_ch.setFormatter(_warn_formatter)
+_warn_logger.addHandler(_warn_ch)
+
+
+_error_logger = logging.getLogger("edk2_error")
+_error_logger.setLevel(INFO)
+_error_ch = logging.StreamHandler()
+# _ch.setLevel(logging.ERROR)
+_error_formatter = logging.Formatter("\t%(pathname)s:%(lineno)d: [ERROR] %(funcName)s() : %(message)s")
+_error_ch.setFormatter(_error_formatter)
+_error_logger.addHandler(_error_ch)
+
+debug   = _debug_logger.debug
+verbose = _verbose_logger.info
+info    = _info_logger.warn
+warn    = _warn_logger.error
+error   = _error_logger.critical
+
+def setLevel(level):
+    if level not in _log_levels:
+        warn("Not supported log level (%d)" % level)
+        level = INFO
+    _debug_logger.setLevel(level)
+    _verbose_logger.setLevel(level)
+    _info_logger.setLevel(level)
+    _warn_logger.setLevel(level)
+    _error_logger.setLevel(level)
+    
+def setLogFile(log):
+    if os.path.exists(log):
+        os.remove(log)
+        
+    _ch = logging.FileHandler(log)
+    _ch.setFormatter(_debug_formatter)
+    _debug_logger.addHandler(_ch)
+    
+    _ch = logging.FileHandler(log)
+    _ch.setFormatter(_verbose_formatter)
+    _verbose_logger.addHandler(_ch)
+
+    _ch = logging.FileHandler(log)
+    _ch.setFormatter(_info_formatter)
+    _info_logger.addHandler(_ch)
+
+    _ch = logging.FileHandler(log)
+    _ch.setFormatter(_warn_formatter)
+    _warn_logger.addHandler(_ch)
+
+    _ch = logging.FileHandler(log)
+    _ch.setFormatter(_error_formatter)
+    _error_logger.addHandler(_ch)
diff --git a/Source/Python/Identification.py b/Source/Python/Identification.py
new file mode 100644 (file)
index 0000000..e79ba83
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+"""\r
+This file is used to define the identification of INF/DEC/DSC files\r
+"""\r
+\r
+class Identification(object):\r
+  def __init__(self):\r
+    self.FileName = ''\r
+    self.FileFullPath = ''\r
+    self.FileRelativePath = ''\r
+\r
+  def GetFileName(self, FileFullPath, FileRelativePath):\r
+    pass\r
+\r
+  def GetFileFullPath(self, FileName, FileRelativePath):\r
+    pass\r
+\r
+  def GetFileRelativePath(self, FileName, FileFullPath):\r
+    pass\r
+\r
+if __name__ == '__main__':\r
+  id = Identification()\r
diff --git a/Source/Python/InfClassObject.py b/Source/Python/InfClassObject.py
new file mode 100644 (file)
index 0000000..a53dc49
--- /dev/null
@@ -0,0 +1,153 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each component of INF file\r
+#\r
+\r
+import os\r
+import EdkLogger\r
+from String import *\r
+from DataType import *\r
+from Identification import *\r
+from Dictionary import *\r
+\r
+class InfObject(object):\r
+  def __init__(self):\r
+    object.__init__()\r
+\r
+class InfDefines(InfObject):\r
+  def __init__(self):\r
+    self.DefinesDictionary = {\r
+      #Required\r
+      TAB_INF_DEFINES_BASE_NAME                    : '',\r
+      TAB_INF_DEFINES_EDK_RELEASE_VERSION          : '',\r
+      TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION    : '',\r
+      #Optional\r
+      TAB_INF_DEFINES_FILE_GUID                    : '',\r
+      TAB_INF_DEFINES_MODULE_TYPE                  : '',\r
+      TAB_INF_DEFINES_BINARY_MODULE                : '',\r
+      TAB_INF_DEFINES_MAKEFILE_NAME                : '',\r
+      TAB_INF_DEFINES_VERSION_STRING               : '',\r
+      TAB_INF_DEFINES_VERSION                      : '',\r
+      TAB_INF_DEFINES_LIBRARY_CLASS                : '',\r
+      TAB_INF_DEFINES_PCD_DRIVER                   : '',\r
+      TAB_INF_DEFINES_ENTRY_POINT                  : [],\r
+      TAB_INF_DEFINES_UNLOAD_IMAGE                 : [],\r
+      TAB_INF_DEFINES_CONSTRUCTOR                  : [],\r
+      TAB_INF_DEFINES_DESTRUCTOR                   : [],\r
+      TAB_INF_DEFINES_DEFINE                       : '',\r
+      TAB_INF_DEFINES_CUSTOM_MAKEFILE              : '',\r
+      TAB_INF_DEFINES_INF_VERSION                  : ''\r
+    }\r
+    self.ToolFlags = []   #'${FAMILY}:${TARGET}_${TAGNAME}_${ARCH}_${TOOLCODE}_FLAGS'\r
+    self.MacroName = '$(MACRO_NAME)'\r
+\r
+class InfContents(InfObject):\r
+  def __init__(self):\r
+    self.Sources = []\r
+    self.BuildOptions = []\r
+    self.Binaries = []\r
+    self.Includes = []\r
+    self.Guids = []\r
+    self.Protocols = []\r
+    self.Ppis = []\r
+    self.LibraryClasses = []\r
+    self.Packages = []\r
+    self.PcdsFixedAtBuild = []\r
+    self.PcdsPatchableInModule = []\r
+    self.PcdsFeatureFlag = []\r
+    self.PcdsDynamic = []\r
+    self.PcdsDynamicEx = []\r
+    self.Depex = []\r
+    \r
+class Inf(InfObject):\r
+  def __init__(self, filename = None, isMergeAllArches = False):\r
+    self.identification = Identification()\r
+    self.Defines = InfDefines()\r
+    self.Contents = {}\r
+    \r
+    for key in DataType.ARCH_LIST_FULL:\r
+      self.Contents[key] = InfContents()\r
+\r
+    self.KeyList = [\r
+      TAB_BINARIES, TAB_SOURCES, TAB_INCLUDES, TAB_GUIDS, TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, TAB_BUILD_OPTIONS, \\r
+      TAB_PCDS_FIXED_AT_BUILD_NULL, TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \\r
+      TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL\r
+    ]\r
+        \r
+    if filename != None:\r
+      self.LoadInfFile(filename)\r
+    \r
+    if isMergeAllArches:\r
+      self.MergeAllArches()\r
+  \r
+  def MergeAllArches(self):\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST:\r
+        Command = "self.Contents[arch]." + key + ".extend(" + "self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ")"\r
+        eval(Command)   \r
+      \r
+  def ParseInf(self, Lines, Key, KeyField):\r
+      GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
+\r
+  def LoadInfFile(self, filename):   \r
+    (filepath, name) = os.path.split(filename)\r
+    self.identification.FileName = name\r
+    self.identification.FileFullPath = filename\r
+    self.identification.FileRelativePath = filepath\r
+    \r
+    f = open(filename, 'r').read()\r
+    sects = f.split('[')\r
+    for sect in sects:\r
+      tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
+      if tab == TAB_INF_DEFINES.upper():\r
+        GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, False, None)\r
+        continue\r
+      for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+        for key in self.KeyList:\r
+          if arch != DataType.TAB_ARCH_NULL:\r
+            target = (key + DataType.TAB_SPLIT + arch).upper()\r
+          else:\r
+            target = key.upper()\r
+          if tab == target:\r
+            if arch != DataType.TAB_ARCH_NULL:\r
+              Command = 'self.ParseInf(sect, tab, self.Contents[arch].' + key + ')'\r
+              eval(Command)\r
+              continue\r
+            else:\r
+              Command = "self.ParseInf(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
+              eval(Command)\r
+              continue\r
+    #EndFor\r
+\r
+  def showInf(self):\r
+    print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END\r
+    printDict(self.Defines.DefinesDictionary)\r
+\r
+    for key in self.KeyList:\r
+      for arch in DataType.ARCH_LIST_FULL:\r
+        Command = "printList(TAB_SECTION_START + '" + \\r
+                  key + DataType.TAB_SPLIT + arch + \\r
+                  "' + TAB_SECTION_END, self.Contents[arch]." + key + ')'\r
+        eval(Command)\r
+    print ""\r
+    \r
+if __name__ == '__main__':\r
+  m = Inf()\r
+  directory = 'C:\Documents and Settings\\hchen30\\Desktop\\prototype\\inf'\r
+  fileList = []\r
+  \r
+  for f in os.listdir(directory):\r
+    if os.path.splitext(os.path.normcase(f))[1] == '.inf':\r
+      fileList.append(os.path.join(directory, os.path.normcase(f)))\r
+      \r
+  for f in fileList:\r
+    m = Inf(f)\r
+    m.showInf()\r
diff --git a/Source/Python/String.py b/Source/Python/String.py
new file mode 100644 (file)
index 0000000..20109c3
--- /dev/null
@@ -0,0 +1,227 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define some common useful string functions\r
+#\r
+\r
+import DataType\r
+import os.path\r
+\r
+def MergeModulePcds(pcds, pcdsFixedAtBuild, pcdsPatchableInModule, pcdsFeatureFlag, pcdsDynamic):\r
+  #[ ['PcdName|PcdGuid|PcdType', 'IA32|X64|IPF|EBC'], ...]\r
+  \r
+  Item = pcdsFixedAtBuild\r
+  for index in range(len(Item)):\r
+    pcds.append([(Item[index][0].split(DataType.TAB_VALUE_SPLIT))[1] + DataType.TAB_VALUE_SPLIT + DataType.TAB_PCDS_FIXED_AT_BUILD, Item[index][1]])\r
+\r
+  Item = pcdsPatchableInModule\r
+  for index in range(len(Item)):\r
+    pcds.append([(Item[index][0].split(DataType.TAB_VALUE_SPLIT))[1] + DataType.TAB_VALUE_SPLIT + DataType.TAB_PCDS_PATCHABLE_IN_MODULE, Item[index][1]])\r
+                 \r
+  Item = pcdsFeatureFlag\r
+  for index in range(len(Item)):\r
+    pcds.append([(Item[index][0].split(DataType.TAB_VALUE_SPLIT))[1] + DataType.TAB_VALUE_SPLIT + DataType.TAB_PCDS_FEATURE_FLAG, Item[index][1]])\r
+                 \r
+  Item = pcdsDynamic\r
+  for index in range(len(Item)):\r
+    pcds.append([(Item[index][0].split(DataType.TAB_VALUE_SPLIT))[1] + DataType.TAB_VALUE_SPLIT + DataType.TAB_PCDS_DYNAMIC, Item[index][1]])\r
+\r
+def MergeAllArch(list1, listCommon, listIa32, listX64, listIpf, listEbc):\r
+  isFound = False\r
+  for j in range(len(list1)):\r
+    list1[j] = [list1[j], '']\r
+  \r
+  for i in listCommon:\r
+    if i not in list1:\r
+      list1.append([i, ''])\r
+  for i in listIa32:\r
+    for j in range(len(list1)):\r
+      if i == list1[j][0]:\r
+        isFound = True\r
+        list1[j] = [list1[j][0], 'IA32|']\r
+        break\r
+    if not isFound:\r
+      list1.append([i, 'IA32|'])\r
+    isFound = False\r
+  \r
+  for i in listX64:\r
+    for j in range(len(list1)):\r
+      if i == list1[j][0]:\r
+        isFound = True\r
+        list1[j] = [list1[j][0], list1[j][1] + 'X64|']\r
+        break\r
+    if not isFound:\r
+      list1.append([i, 'X64|'])\r
+    isFound = False\r
+  \r
+  for i in listIpf:\r
+    for j in range(len(list1)):\r
+      if i == list1[j][0]:\r
+        isFound = True\r
+        list1[j] = [list1[j][0], list1[j][1] + 'Ipf|']\r
+        break\r
+    if not isFound:\r
+      list1.append([i, 'Ipf|'])\r
+    isFound = False\r
+    \r
+  for i in listEbc:\r
+    for j in range(len(list1)):\r
+      if i == list1[j][0]:\r
+        isFound = True\r
+        list1[j] = [list1[j][0], list1[j][1] + 'Ebc|']\r
+        break\r
+    if not isFound:\r
+      list1.append([i, 'Ebc|'])\r
+    isFound = False\r
+    \r
+  #Remove DataType.TAB_VALUE_SPLIT\r
+  for i in range(len(list1)):\r
+    if list1[i][1].endswith(DataType.TAB_VALUE_SPLIT):\r
+      list1[i][1] = list1[i][1].rsplit(DataType.TAB_VALUE_SPLIT, 1)[0]\r
+\r
+  #print list1\r
+\r
+def GetComponents(Lines, Key, KeyValues, CommentCharacter):\r
+  #KeyValues [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3]], ...]\r
+  Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1]\r
+  findBlock = False\r
+  findLibraryClass = False\r
+  findBuildOption = False\r
+  ListItem = None\r
+  LibraryClassItem = []\r
+  BuildOption = []\r
+  \r
+  LineList = Lines.split('\n')\r
+  for Line in LineList:\r
+    Line = CleanString(Line, CommentCharacter)\r
+    if Line == None or Line == '':\r
+      continue\r
+    \r
+    if findBlock == False:\r
+      ListItem = Line\r
+      #find '{' at line tail\r
+      if Line.endswith('{'):\r
+        findBlock = True\r
+        ListItem = CleanString(Line.rsplit('{', 1)[0], CommentCharacter)\r
+\r
+    if findBlock:  \r
+      if Line.find('<LibraryClass>') != -1:\r
+        findLibraryClass = True\r
+        continue\r
+      if Line.find('<BuildOptions>') != -1:\r
+        findBuildOption = True\r
+        continue\r
+      if Line.endswith('}'):\r
+        #find '}' at line tail\r
+        KeyValues.append([ListItem, LibraryClassItem, BuildOption])\r
+        findBlock = False\r
+        findLibraryClass = False\r
+        findBuildOption = False\r
+        LibraryClassItem = []\r
+        BuildOption = []\r
+        continue\r
+\r
+    if findBlock:\r
+      if findLibraryClass:\r
+        LibraryClassItem.append(Line)\r
+      elif findBuildOption:\r
+        BuildOption.append(Line)\r
+    else:\r
+      KeyValues.append([ListItem, [], []])\r
+    \r
+  return True\r
+\r
+def GetLibraryClassesWithModuleType(Lines, Key, KeyValues, CommentCharacter):\r
+  newKey = SplitModuleType(Key)\r
+  Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1]\r
+  LineList = Lines.splitlines()\r
+  for Line in LineList:\r
+    if Line != '' and Line[0] != CommentCharacter:\r
+      KeyValues.append([CleanString(Line, CommentCharacter), newKey[1]])\r
+\r
+  return True\r
+\r
+def SplitModuleType(Key):\r
+  #from DataType import *\r
+  KeyList = Key.split(DataType.TAB_SPLIT)\r
+  rtv = []\r
+  if len(KeyList) == 3:\r
+    rtv.append(KeyList[0] + DataType.TAB_SPLIT + KeyList[1])\r
+    rtv.append(KeyList[2])\r
+    return rtv\r
+  else:\r
+    rtv.append(Key)\r
+    rtv.append(None)\r
+    return rtv\r
+  \r
+def NormPath(path):\r
+  if path != '':\r
+    return os.path.normpath(path)\r
+  else:\r
+    return path\r
+\r
+def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT):\r
+  #remove comments\r
+  Line = Line.split(CommentCharacter, 1)[0];\r
+  #remove whitespace\r
+  Line = Line.strip();\r
+  #replace '\\', '\' with '/'\r
+  Line = Line.replace('\\', '/')\r
+  Line = Line.replace('//', '/')\r
+  #remove ${WORKSPACE}\r
+  Line = Line.replace(DataType.TAB_WORKSPACE1, '')\r
+  Line = Line.replace(DataType.TAB_WORKSPACE2, '')\r
+  #remove '/' at the beginning\r
+  if Line.startswith('/'):\r
+    Line = Line.replace('/', '')\r
+  #Change path\r
+  #Line = os.path.normpath(Line)\r
+  \r
+  return Line\r
+\r
+def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValues, CommentCharacter):\r
+  Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1]\r
+  LineList = Lines.split('\n')\r
+  for Line in LineList:\r
+    Line = CleanString(Line, CommentCharacter)\r
+    if Line != '' and Line[0] != CommentCharacter:\r
+      KeyValues += [Line]\r
+\r
+  return True\r
+\r
+def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
+  Lines = Lines.split('\n')\r
+  Keys = []\r
+  Value = ''\r
+  for Line in Lines:\r
+    LineList = Line.split(KeySplitCharacter, 1)\r
+    if len(LineList) >= 2:\r
+      Key = LineList[0].split()\r
+      if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:\r
+        #Remove comments and white spaces\r
+        LineList[1] = CleanString(LineList[1], CommentCharacter)\r
+\r
+        if ValueSplitFlag:\r
+          ValueList = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
+          if len(ValueList) == 1:\r
+            Value = ValueList[0]\r
+        else:\r
+          Value = CleanString(LineList[1], CommentCharacter)\r
+\r
+        Dictionary[Key[0]] = Value\r
+        Keys += [Key[0]]\r
+        \r
+  return True\r
+\r
+\r
+if __name__ == '__main__':\r
+  print SplitModuleType('LibraryClasses.common.DXE_RUNTIME_DRIVER')\r
+  print SplitModuleType('Library.common')\r
+  print SplitModuleType('Librarsdsfwe')
\ No newline at end of file
diff --git a/Source/Python/TargetTxtClassObject.py b/Source/Python/TargetTxtClassObject.py
new file mode 100644 (file)
index 0000000..d4caa5a
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each component of Target.txt file\r
+#\r
+import EdkLogger\r
+import DataType\r
+from Dictionary import *\r
+\r
+\r
+class TargetTxtClassObject(object):\r
+  def __init__(self, filename = None):\r
+    self.TargetTxtDictionary = {\r
+      DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM              : [''],\r
+      DataType.TAB_TAT_DEFINES_ACTIVE_MODULE                : [''],\r
+      DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF              : [''],\r
+      DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD              : ['Disable'],\r
+      DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : ['2'],\r
+      DataType.TAB_TAT_DEFINES_TARGET                       : [''],\r
+      DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG               : [''],\r
+      DataType.TAB_TAT_DEFINES_TARGET_ARCH                  : ['']\r
+    }\r
+    if filename != None:\r
+      self.LoadTargetTxtFile(filename)\r
+\r
+  def LoadTargetTxtFile(self, filename):\r
+    EdkLogger.info('LoadTargetTxtFile() Start')\r
+    if filename != None:\r
+      ConvertTextFileToDictionary(filename, self.TargetTxtDictionary, '#', '=', True, None)\r
+      if self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM] == []:\r
+        self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]            = ['']\r
+      else:\r
+        self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]            = [self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM][0]]\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]              = [self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF][0]]\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD]              = [self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD][0]]\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER] = [self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER][0]]\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]                       = list(set(self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]))\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]               = list(set(self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]))\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH]                  = list(set(self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH]))\r
+      if self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET] == []:\r
+        self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET] = ['']\r
+      if self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG] == []:\r
+        self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG] = ['']\r
+      if self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH] == []:\r
+        self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH] = ['']\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET].sort()\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG].sort()\r
+      self.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH].sort()\r
+      \r
+      EdkLogger.info('LoadTargetTxtFile() End')\r
+    else:\r
+      EdkLogger.error('LoadTargetTxtFile() : No Target.txt file exist')\r
+\r
+if __name__ == '__main__':\r
+  pass
\ No newline at end of file
diff --git a/Source/Python/ToolDefClassObject.py b/Source/Python/ToolDefClassObject.py
new file mode 100644 (file)
index 0000000..03131a1
--- /dev/null
@@ -0,0 +1,85 @@
+# Copyright (c) 2007, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+#\r
+#This file is used to define each component of tools_def.txt file\r
+#\r
+\r
+import EdkLogger\r
+from Dictionary import *\r
+\r
+class ToolDefClassObject(object):\r
+  def __init__(self, filename = None):\r
+    self.ToolsDefTxtDictionary = {}\r
+    \r
+    self.ToolsDefTxtDatabase = {\r
+      TAB_TOD_DEFINES_TARGET                       : [],\r
+      TAB_TOD_DEFINES_TOOL_CHAIN_TAG               : [],\r
+      TAB_TOD_DEFINES_TARGET_ARCH                  : [],\r
+      TAB_TOD_DEFINES_COMMAND_TYPE                 : []\r
+    }\r
+    if filename != None:\r
+      self.LoadToolDefFile(filename)\r
+\r
+  def LoadToolDefFile(self, filename):\r
+    EdkLogger.info('LoadToolDefFile() Start')\r
+    if filename != None:\r
+      ConvertTextFileToDictionary(filename, self.ToolsDefTxtDictionary, '#', '=', False, None)\r
+\r
+    self.ToolsDefTxtDatabase = {\r
+      TAB_TOD_DEFINES_TARGET                       : [],\r
+      TAB_TOD_DEFINES_TOOL_CHAIN_TAG               : [],\r
+      TAB_TOD_DEFINES_TARGET_ARCH                  : [],\r
+      TAB_TOD_DEFINES_COMMAND_TYPE                 : []\r
+    }\r
+\r
+    for Key in dict(self.ToolsDefTxtDictionary):\r
+      List = Key.split('_')\r
+      if len(List) != 5:\r
+        del self.ToolsDefTxtDictionary[Key]\r
+      elif List[4] == '*':\r
+        del self.ToolsDefTxtDictionary[Key]\r
+      else:\r
+        if List[0] != '*':\r
+          self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET] += [List[0]]\r
+        if List[1] != '*':\r
+          self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] += [List[1]]\r
+        if List[2] != '*':\r
+          self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH] += [List[2]]\r
+        if List[3] != '*':\r
+          self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE] += [List[3]]\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET]         = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET]))\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG]))\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH]    = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH]))\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE]   = list(set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE]))\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET].sort()\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG].sort()\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH].sort()\r
+    self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE].sort()\r
+\r
+    KeyList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE]\r
+    for Index in range(3,-1,-1):\r
+      for Key in dict(self.ToolsDefTxtDictionary):\r
+        List = Key.split('_')\r
+        if List[Index] == '*':\r
+          for String in self.ToolsDefTxtDatabase[KeyList[Index]]:\r
+            List[Index] = String\r
+            NewKey = '%s_%s_%s_%s_%s' % tuple(List)\r
+            if NewKey not in self.ToolsDefTxtDictionary:\r
+              self.ToolsDefTxtDictionary[NewKey] = self.ToolsDefTxtDictionary[Key]\r
+            continue\r
+          del self.ToolsDefTxtDictionary[Key]\r
+        elif List[Index] not in self.ToolsDefTxtDatabase[KeyList[Index]]:\r
+          del self.ToolsDefTxtDictionary[Key]\r
+    \r
+    EdkLogger.info('LoadToolDefFile() End')\r
+    \r
+if __name__ == '__main__':\r
+  td = ToolDefClassObject('tool_def.txt')\r
+  print td.ToolsDefTxtDatabase
\ No newline at end of file