EDKII build spec and DEC spec updated to support private package
definition.
If GUID, Protocol or PPI is listed in a DEC file, where the Private
modifier is used in the section tag ([Guids.common.Private] for example),
only modules within the package are permitted to use the GUID, Protocol
or PPI. If a module or library instance outside of the package attempts
to use the item, the build must fail with an appropriate error message.
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
for SkuId in PcdInModule.SkuInfoList:\r
Sku = PcdInModule.SkuInfoList[SkuId]\r
if Sku.VariableGuid == '': continue\r
for SkuId in PcdInModule.SkuInfoList:\r
Sku = PcdInModule.SkuInfoList[SkuId]\r
if Sku.VariableGuid == '': continue\r
- Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList)\r
+ Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)\r
if Sku.VariableGuidValue == None:\r
PackageList = "\n\t".join([str(P) for P in self.PackageList])\r
EdkLogger.error(\r
if Sku.VariableGuidValue == None:\r
PackageList = "\n\t".join([str(P) for P in self.PackageList])\r
EdkLogger.error(\r
PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
if PackageDir not in self._IncludePathList:\r
self._IncludePathList.append(PackageDir)\r
PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
if PackageDir not in self._IncludePathList:\r
self._IncludePathList.append(PackageDir)\r
- for Inc in Package.Includes:\r
+ IncludesList = Package.Includes\r
+ if Package._PrivateIncludes:\r
+ if not self.MetaFile.Path.startswith(PackageDir):\r
+ IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))\r
+ for Inc in IncludesList:\r
if Inc not in self._IncludePathList:\r
self._IncludePathList.append(str(Inc))\r
return self._IncludePathList\r
if Inc not in self._IncludePathList:\r
self._IncludePathList.append(str(Inc))\r
return self._IncludePathList\r
for SkuName in Pcd.SkuInfoList:\r
SkuInfo = Pcd.SkuInfoList[SkuName]\r
Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
for SkuName in Pcd.SkuInfoList:\r
SkuInfo = Pcd.SkuInfoList[SkuName]\r
Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
- Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList)\r
+ Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)\r
if not Value:\r
continue\r
Guid = GuidStructureStringToGuidString(Value)\r
if not Value:\r
continue\r
Guid = GuidStructureStringToGuidString(Value)\r
## @file\r
# Common routines used by all tools\r
#\r
## @file\r
# Common routines used by all tools\r
#\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
# 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
# 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
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def GuidValue(CName, PackageList):\r
+def GuidValue(CName, PackageList, Inffile = None):\r
+ GuidKeys = P.Guids.keys()\r
+ if Inffile and P._PrivateGuids:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ GuidKeys = (dict.fromkeys(x for x in P.Guids if x not in P._PrivateGuids)).keys()\r
+ if CName in GuidKeys:\r
return P.Guids[CName]\r
return None\r
\r
return P.Guids[CName]\r
return None\r
\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def ProtocolValue(CName, PackageList):\r
+def ProtocolValue(CName, PackageList, Inffile = None):\r
- if CName in P.Protocols:\r
+ ProtocolKeys = P.Protocols.keys()\r
+ if Inffile and P._PrivateProtocols:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ ProtocolKeys = (dict.fromkeys(x for x in P.Protocols if x not in P._PrivateProtocols)).keys()\r
+ if CName in ProtocolKeys:\r
return P.Protocols[CName]\r
return None\r
\r
return P.Protocols[CName]\r
return None\r
\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def PpiValue(CName, PackageList):\r
+def PpiValue(CName, PackageList, Inffile = None):\r
+ PpiKeys = P.Ppis.keys()\r
+ if Inffile and P._PrivatePpis:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ PpiKeys = (dict.fromkeys(x for x in P.Ppis if x not in P._PrivatePpis)).keys()\r
+ if CName in PpiKeys:\r
return P.Ppis[CName]\r
return None\r
\r
return P.Ppis[CName]\r
return None\r
\r
self._SectionName = ''\r
self._SectionType = []\r
ArchList = set()\r
self._SectionName = ''\r
self._SectionType = []\r
ArchList = set()\r
Line = self._CurrentLine.replace("%s%s" % (TAB_COMMA_SPLIT, TAB_SPACE_SPLIT), TAB_COMMA_SPLIT)\r
for Item in Line[1:-1].split(TAB_COMMA_SPLIT):\r
if Item == '':\r
Line = self._CurrentLine.replace("%s%s" % (TAB_COMMA_SPLIT, TAB_SPACE_SPLIT), TAB_COMMA_SPLIT)\r
for Item in Line[1:-1].split(TAB_COMMA_SPLIT):\r
if Item == '':\r
# S2 may be Platform or ModuleType\r
if len(ItemList) > 2:\r
S2 = ItemList[2].upper()\r
# S2 may be Platform or ModuleType\r
if len(ItemList) > 2:\r
S2 = ItemList[2].upper()\r
+ # only Includes, GUIDs, PPIs, Protocols section have Private tag\r
+ if self._SectionName in [TAB_INCLUDES.upper(), TAB_GUIDS.upper(), TAB_PROTOCOLS.upper(), TAB_PPIS.upper()]:\r
+ if S2 != 'PRIVATE':\r
+ EdkLogger.error("Parser", FORMAT_INVALID, 'Please use keyword "Private" as section tag modifier.',\r
+ File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
if [S1, S2, self.DataType[self._SectionName]] not in self._Scope:\r
self._Scope.append([S1, S2, self.DataType[self._SectionName]])\r
\r
if [S1, S2, self.DataType[self._SectionName]] not in self._Scope:\r
self._Scope.append([S1, S2, self.DataType[self._SectionName]])\r
\r
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",\r
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
\r
EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",\r
File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
\r
+ # It is not permissible to mix section tags without the Private attribute with section tags with the Private attribute\r
+ if 'COMMON' in PrivateList and len(PrivateList) > 1:\r
+ EdkLogger.error('Parser', FORMAT_INVALID, "Can't mix section tags without the Private attribute with section tags with the Private attribute",\r
+ File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
+\r
## [guids], [ppis] and [protocols] section parser\r
@ParseMacro\r
def _GuidParser(self):\r
## [guids], [ppis] and [protocols] section parser\r
@ParseMacro\r
def _GuidParser(self):\r
## @file\r
# This file is used to create/update/query/erase a meta file table\r
#\r
## @file\r
# This file is used to create/update/query/erase a meta file table\r
#\r
-# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
# 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
# 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
#\r
def Query(self, Model, Arch=None):\r
ConditionString = "Model=%s AND Enabled>=0" % Model\r
#\r
def Query(self, Model, Arch=None):\r
ConditionString = "Model=%s AND Enabled>=0" % Model\r
- ValueString = "Value1,Value2,Value3,Scope1,ID,StartLine"\r
+ ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"\r
\r
if Arch != None and Arch != 'COMMON':\r
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
\r
if Arch != None and Arch != 'COMMON':\r
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
self._LibraryClasses = None\r
self._Pcds = None\r
self.__Macros = None\r
self._LibraryClasses = None\r
self._Pcds = None\r
self.__Macros = None\r
+ self._PrivateProtocols = None\r
+ self._PrivatePpis = None\r
+ self._PrivateGuids = None\r
+ self._PrivateIncludes = None\r
\r
## Get current effective macros\r
def _GetMacros(self):\r
\r
## Get current effective macros\r
def _GetMacros(self):\r
# protocol defition for given ARCH\r
#\r
ProtocolDict = tdict(True)\r
# protocol defition for given ARCH\r
#\r
ProtocolDict = tdict(True)\r
+ PrivateProtocolDict = tdict(True)\r
# find out all protocol definitions for specific and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch]\r
# find out all protocol definitions for specific and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch]\r
- for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+ for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+ if PrivateFlag == 'PRIVATE':\r
+ if Name not in PrivateNameList:\r
+ PrivateNameList.append(Name)\r
+ PrivateProtocolDict[Arch, Name] = Guid\r
if Name not in NameList:\r
NameList.append(Name)\r
ProtocolDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Protocols = sdict()\r
if Name not in NameList:\r
NameList.append(Name)\r
ProtocolDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Protocols = sdict()\r
+ self._PrivateProtocols = sdict()\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Protocols[Name] = ProtocolDict[self._Arch, Name]\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Protocols[Name] = ProtocolDict[self._Arch, Name]\r
+ for Name in PrivateNameList:\r
+ self._PrivateProtocols[Name] = PrivateProtocolDict[self._Arch, Name]\r
return self._Protocols\r
\r
## Retrieve PPI definitions (name/value pairs)\r
return self._Protocols\r
\r
## Retrieve PPI definitions (name/value pairs)\r
# PPI defition for given ARCH\r
#\r
PpiDict = tdict(True)\r
# PPI defition for given ARCH\r
#\r
PpiDict = tdict(True)\r
+ PrivatePpiDict = tdict(True)\r
# find out all PPI definitions for specific arch and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch]\r
# find out all PPI definitions for specific arch and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch]\r
- for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+ for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+ if PrivateFlag == 'PRIVATE':\r
+ if Name not in PrivateNameList:\r
+ PrivateNameList.append(Name)\r
+ PrivatePpiDict[Arch, Name] = Guid\r
if Name not in NameList:\r
NameList.append(Name)\r
PpiDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Ppis = sdict()\r
if Name not in NameList:\r
NameList.append(Name)\r
PpiDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Ppis = sdict()\r
+ self._PrivatePpis = sdict()\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Ppis[Name] = PpiDict[self._Arch, Name]\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Ppis[Name] = PpiDict[self._Arch, Name]\r
+ for Name in PrivateNameList:\r
+ self._PrivatePpis[Name] = PrivatePpiDict[self._Arch, Name]\r
return self._Ppis\r
\r
## Retrieve GUID definitions (name/value pairs)\r
return self._Ppis\r
\r
## Retrieve GUID definitions (name/value pairs)\r
# GUID defition for given ARCH\r
#\r
GuidDict = tdict(True)\r
# GUID defition for given ARCH\r
#\r
GuidDict = tdict(True)\r
+ PrivateGuidDict = tdict(True)\r
# find out all protocol definitions for specific and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]\r
# find out all protocol definitions for specific and 'common' arch\r
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]\r
- for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+ for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+ if PrivateFlag == 'PRIVATE':\r
+ if Name not in PrivateNameList:\r
+ PrivateNameList.append(Name)\r
+ PrivateGuidDict[Arch, Name] = Guid\r
if Name not in NameList:\r
NameList.append(Name)\r
GuidDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Guids = sdict()\r
if Name not in NameList:\r
NameList.append(Name)\r
GuidDict[Arch, Name] = Guid\r
# use sdict to keep the order\r
self._Guids = sdict()\r
+ self._PrivateGuids = sdict()\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Guids[Name] = GuidDict[self._Arch, Name]\r
for Name in NameList:\r
#\r
# limit the ARCH to self._Arch, if no self._Arch found, tdict\r
# will automatically turn to 'common' ARCH for trying\r
#\r
self._Guids[Name] = GuidDict[self._Arch, Name]\r
+ for Name in PrivateNameList:\r
+ self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name]\r
return self._Guids\r
\r
## Retrieve public include paths declared in this package\r
def _GetInclude(self):\r
if self._Includes == None:\r
self._Includes = []\r
return self._Guids\r
\r
## Retrieve public include paths declared in this package\r
def _GetInclude(self):\r
if self._Includes == None:\r
self._Includes = []\r
+ self._PrivateIncludes = []\r
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
Macros = self._Macros\r
Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
Macros = self._Macros\r
Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
# avoid duplicate include path\r
if File not in self._Includes:\r
self._Includes.append(File)\r
# avoid duplicate include path\r
if File not in self._Includes:\r
self._Includes.append(File)\r
+ if Record[4] == 'PRIVATE':\r
+ if File not in self._PrivateIncludes:\r
+ self._PrivateIncludes.append(File)\r
return self._Includes\r
\r
## Retrieve library class declarations (not used in build at present)\r
return self._Includes\r
\r
## Retrieve library class declarations (not used in build at present)\r
LibraryClassSet = set()\r
RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch]\r
Macros = self._Macros\r
LibraryClassSet = set()\r
RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch]\r
Macros = self._Macros\r
- for LibraryClass, File, Dummy, Arch, ID, LineNo in RecordList:\r
+ for LibraryClass, File, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
File = PathClass(NormPath(File, Macros), self._PackageDir, Arch=self._Arch)\r
# check the file validation\r
ErrorCode, ErrorInfo = File.Validate()\r
File = PathClass(NormPath(File, Macros), self._PackageDir, Arch=self._Arch)\r
# check the file validation\r
ErrorCode, ErrorInfo = File.Validate()\r
PcdSet = set()\r
# find out all PCDs of the 'type'\r
RecordList = self._RawData[Type, self._Arch]\r
PcdSet = set()\r
# find out all PCDs of the 'type'\r
RecordList = self._RawData[Type, self._Arch]\r
- for TokenSpaceGuid, PcdCName, Setting, Arch, Dummy1, Dummy2 in RecordList:\r
+ for TokenSpaceGuid, PcdCName, Setting, Arch, PrivateFlag, Dummy1, Dummy2 in RecordList:\r
PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting\r
PcdSet.add((PcdCName, TokenSpaceGuid))\r
\r
PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting\r
PcdSet.add((PcdCName, TokenSpaceGuid))\r
\r
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
- Value = ProtocolValue(CName, self.Packages)\r
+ Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
- Value = PpiValue(CName, self.Packages)\r
+ Value = PpiValue(CName, self.Packages, self.MetaFile.Path)\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]\r
for Record in RecordList:\r
CName = Record[0]\r
- Value = GuidValue(CName, self.Packages)\r
+ Value = GuidValue(CName, self.Packages, self.MetaFile.Path)\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
DepexList.append(Module.Guid)\r
else:\r
# get the GUID value now\r
DepexList.append(Module.Guid)\r
else:\r
# get the GUID value now\r
- Value = ProtocolValue(Token, self.Packages)\r
+ Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)\r
- Value = PpiValue(Token, self.Packages)\r
+ Value = PpiValue(Token, self.Packages, self.MetaFile.Path)\r
- Value = GuidValue(Token, self.Packages)\r
+ Value = GuidValue(Token, self.Packages, self.MetaFile.Path)\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
PcdList.append((PcdCName, TokenSpaceGuid))\r
# get the guid value\r
if TokenSpaceGuid not in self.Guids:\r
PcdList.append((PcdCName, TokenSpaceGuid))\r
# get the guid value\r
if TokenSpaceGuid not in self.Guids:\r
- Value = GuidValue(TokenSpaceGuid, self.Packages)\r
+ Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path)\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
if Value == None:\r
PackageList = "\n\t".join([str(P) for P in self.Packages])\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r