## @file\r
# This file is used to create a database used by build tool\r
#\r
-# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
from Common.DataType import *\r
from Common.Misc import *\r
from types import *\r
+from collections import OrderedDict\r
\r
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject\r
\r
self._Ppis = None\r
self._Guids = None\r
self._Includes = None\r
+ self._CommonIncludes = None\r
self._LibraryClasses = None\r
self._Pcds = None\r
self.__Macros = None\r
\r
## Get current effective macros\r
def _GetMacros(self):\r
- if self.__Macros == None:\r
+ if self.__Macros is None:\r
self.__Macros = {}\r
self.__Macros.update(GlobalData.gGlobalDefines)\r
return self.__Macros\r
\r
## Retrieve package name\r
def _GetPackageName(self):\r
- if self._PackageName == None:\r
- if self._Header == None:\r
+ if self._PackageName is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._PackageName == None:\r
+ if self._PackageName is None:\r
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", File=self.MetaFile)\r
return self._PackageName\r
\r
## Retrieve file guid\r
def _GetFileGuid(self):\r
- if self._Guid == None:\r
- if self._Header == None:\r
+ if self._Guid is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Guid == None:\r
+ if self._Guid is None:\r
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", File=self.MetaFile)\r
return self._Guid\r
\r
## Retrieve package version\r
def _GetVersion(self):\r
- if self._Version == None:\r
- if self._Header == None:\r
+ if self._Version is None:\r
+ if self._Header is None:\r
self._GetHeaderInfo()\r
- if self._Version == None:\r
+ if self._Version is None:\r
self._Version = ''\r
return self._Version\r
\r
## Retrieve protocol definitions (name/value pairs)\r
def _GetProtocol(self):\r
- if self._Protocols == None:\r
+ if self._Protocols is None:\r
#\r
# tdict is a special kind of dict, used for selecting correct\r
# protocol defition for given ARCH\r
\r
## Retrieve PPI definitions (name/value pairs)\r
def _GetPpi(self):\r
- if self._Ppis == None:\r
+ if self._Ppis is None:\r
#\r
# tdict is a special kind of dict, used for selecting correct\r
# PPI defition for given ARCH\r
\r
## Retrieve GUID definitions (name/value pairs)\r
def _GetGuid(self):\r
- if self._Guids == None:\r
+ if self._Guids is None:\r
#\r
# tdict is a special kind of dict, used for selecting correct\r
# GUID defition for given ARCH\r
\r
## Retrieve public include paths declared in this package\r
def _GetInclude(self):\r
- if self._Includes == None:\r
+ if self._Includes is None or self._CommonIncludes is None:\r
+ self._CommonIncludes = []\r
self._Includes = []\r
self._PrivateIncludes = []\r
PublicInclues = []\r
PublicInclues.append(File)\r
if File in self._PrivateIncludes:\r
EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)\r
-\r
+ if Record[3] == "COMMON":\r
+ self._CommonIncludes.append(File)\r
return self._Includes\r
\r
## Retrieve library class declarations (not used in build at present)\r
def _GetLibraryClass(self):\r
- if self._LibraryClasses == None:\r
+ if self._LibraryClasses is None:\r
#\r
# tdict is a special kind of dict, used for selecting correct\r
# library class declaration for given ARCH\r
\r
## Retrieve PCD declarations\r
def _GetPcds(self):\r
- if self._Pcds == None:\r
+ if self._Pcds is None:\r
self._Pcds = sdict()\r
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r
\r
\r
def ProcessStructurePcd(self, StructurePcdRawDataSet):\r
- s_pcd_set = dict()\r
+ s_pcd_set = OrderedDict()\r
for s_pcd,LineNo in StructurePcdRawDataSet:\r
if s_pcd.TokenSpaceGuidCName not in s_pcd_set:\r
s_pcd_set[s_pcd.TokenSpaceGuidCName] = []\r
struct_pcd = StructurePcd()\r
for item,LineNo in s_pcd_set[pcdname]:\r
if "<HeaderFiles>" in item.TokenCName:\r
- struct_pcd.StructuredPcdIncludeFile = item.DefaultValue\r
+ struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)\r
elif "<Packages>" in item.TokenCName:\r
dep_pkgs.append(item.DefaultValue)\r
elif item.DatumType == item.TokenCName:\r
struct_pcd.copy(item)\r
struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip()\r
struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")\r
+ struct_pcd.PcdDefineLineNo = LineNo\r
+ struct_pcd.PkgPath = self.MetaFile.File\r
+ struct_pcd.SetDecDefaultValue(item.DefaultValue)\r
else:\r
struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)\r
\r
struct_pcd.PackageDecs = dep_pkgs\r
-\r
str_pcd_set.append(struct_pcd)\r
-\r
return str_pcd_set\r
\r
## Retrieve PCD declarations for given type\r
# will automatically turn to 'common' ARCH and try again\r
#\r
Setting,LineNo = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]\r
- if Setting == None:\r
+ if Setting is None:\r
continue\r
\r
DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)\r
list(validlists),\r
list(expressions)\r
)\r
+ PcdObj.DefinitionPosition = (self.MetaFile.File,LineNo)\r
if "." in TokenSpaceGuid:\r
StrPcdSet.append((PcdObj,LineNo))\r
else:\r
StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r
for pcd in StructurePcds:\r
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r
+ StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
+ for pcd in Pcds.values():\r
+ if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+ if StructPattern.match(pcd.DatumType) is None:\r
+ EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", pcd.DefinitionPosition[0],pcd.DefinitionPosition[1])\r
+ for struct_pcd in Pcds.values():\r
+ if isinstance(struct_pcd,StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:\r
+ EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName,struct_pcd.DefinitionPosition[0],struct_pcd.DefinitionPosition[1] ))\r
\r
return Pcds\r
+ @property\r
+ def CommonIncludes(self):\r
+ if self._CommonIncludes is None:\r
+ self.Includes\r
+ return self._CommonIncludes\r
\r
\r
_Macros = property(_GetMacros)\r