summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common/Misc.py
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2016-05-10 17:58:26 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2016-05-18 08:59:30 +0800
commitc28d2e1047816164ffec552e4a3375122cbcc6b6 (patch)
tree20c8ba16e7f4ed1a8ef4f135ef82e79f83ae3580 /BaseTools/Source/Python/Common/Misc.py
parentbba734ab4c7c9b4386d39420983bf61484f65dda (diff)
downloadedk2-c28d2e1047816164ffec552e4a3375122cbcc6b6.tar.gz
edk2-c28d2e1047816164ffec552e4a3375122cbcc6b6.tar.bz2
edk2-c28d2e1047816164ffec552e4a3375122cbcc6b6.zip
BaseTools: support private package definition
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>
Diffstat (limited to 'BaseTools/Source/Python/Common/Misc.py')
-rw-r--r--BaseTools/Source/Python/Common/Misc.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 777450d818..c99716da7d 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1,7 +1,7 @@
## @file
# Common routines used by all tools
#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -794,13 +794,18 @@ def GetRelPath(Path1, Path2):
#
# @param CName The CName of the GUID
# @param PackageList List of packages looking-up in
+# @param Inffile The driver file
#
# @retval GuidValue if the CName is found in any given package
# @retval None if the CName is not found in all given packages
#
-def GuidValue(CName, PackageList):
+def GuidValue(CName, PackageList, Inffile = None):
for P in PackageList:
- if CName in P.Guids:
+ GuidKeys = P.Guids.keys()
+ if Inffile and P._PrivateGuids:
+ if not Inffile.startswith(P.MetaFile.Dir):
+ GuidKeys = (dict.fromkeys(x for x in P.Guids if x not in P._PrivateGuids)).keys()
+ if CName in GuidKeys:
return P.Guids[CName]
return None
@@ -808,13 +813,18 @@ def GuidValue(CName, PackageList):
#
# @param CName The CName of the GUID
# @param PackageList List of packages looking-up in
+# @param Inffile The driver file
#
# @retval GuidValue if the CName is found in any given package
# @retval None if the CName is not found in all given packages
#
-def ProtocolValue(CName, PackageList):
+def ProtocolValue(CName, PackageList, Inffile = None):
for P in PackageList:
- if CName in P.Protocols:
+ ProtocolKeys = P.Protocols.keys()
+ if Inffile and P._PrivateProtocols:
+ if not Inffile.startswith(P.MetaFile.Dir):
+ ProtocolKeys = (dict.fromkeys(x for x in P.Protocols if x not in P._PrivateProtocols)).keys()
+ if CName in ProtocolKeys:
return P.Protocols[CName]
return None
@@ -822,13 +832,18 @@ def ProtocolValue(CName, PackageList):
#
# @param CName The CName of the GUID
# @param PackageList List of packages looking-up in
+# @param Inffile The driver file
#
# @retval GuidValue if the CName is found in any given package
# @retval None if the CName is not found in all given packages
#
-def PpiValue(CName, PackageList):
+def PpiValue(CName, PackageList, Inffile = None):
for P in PackageList:
- if CName in P.Ppis:
+ PpiKeys = P.Ppis.keys()
+ if Inffile and P._PrivatePpis:
+ if not Inffile.startswith(P.MetaFile.Dir):
+ PpiKeys = (dict.fromkeys(x for x in P.Ppis if x not in P._PrivatePpis)).keys()
+ if CName in PpiKeys:
return P.Ppis[CName]
return None