Re: [edk2] [Patch] BaseTools: Support multiple .h file

2018-01-31 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Monday, January 29, 2018 2:10 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] BaseTools: Support multiple .h file
>
>for structure Pcd declaration in DEC file.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +-
> BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +-
> BaseTools/Source/Python/Workspace/DscBuildData.py | 8 
> BaseTools/Source/Python/Workspace/MetaFileParser.py   | 4 +++-
> 4 files changed, 9 insertions(+), 7 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>index 3afb27a9c0..0e1161c96f 100644
>--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>@@ -113,11 +113,11 @@ class StructurePcd(PcdClassObject):
> if SkuInfoList is None: SkuInfoList={}
> if validateranges is None: validateranges=[]
> if validlists is None: validlists=[]
> if expressions is None : expressions=[]
> super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value,
>Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges,
>validlists, expressions)
>-self.StructuredPcdIncludeFile = StructuredPcdIncludeFile
>+self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None
>else StructuredPcdIncludeFile
> self.PackageDecs = Packages
> self.DefaultStoreName = [default_store]
> self.DefaultValues = collections.OrderedDict({})
> self.PcdMode = None
> self.SkuOverrideValues = collections.OrderedDict({})
>diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py
>b/BaseTools/Source/Python/Workspace/DecBuildData.py
>index f6b908dee6..2fd3820dcc 100644
>--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
>@@ -374,11 +374,11 @@ class DecBuildData(PackageBuildClassObject):
> for pcdname in s_pcd_set:
> dep_pkgs = []
> struct_pcd = StructurePcd()
> for item,LineNo in s_pcd_set[pcdname]:
> if "" in item.TokenCName:
>-struct_pcd.StructuredPcdIncludeFile = item.DefaultValue
>+
>struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)
> elif "" in item.TokenCName:
> dep_pkgs.append(item.DefaultValue)
> elif item.DatumType == item.TokenCName:
> struct_pcd.copy(item)
> struct_pcd.TokenValue = 
> struct_pcd.TokenValue.strip("{").strip()
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 256fdd6875..0384b96997 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -1669,14 +1669,14 @@ class DscBuildData(PlatformBuildClassObject):
> CApp = PcdMainCHeader
>
> Includes = {}
> for PcdName in StructuredPcds:
> Pcd = StructuredPcds[PcdName]
>-IncludeFile = Pcd.StructuredPcdIncludeFile
>-if IncludeFile not in Includes:
>-Includes[IncludeFile] = True
>-CApp = CApp + '#include <%s>\n' % (IncludeFile)
>+for IncludeFile in Pcd.StructuredPcdIncludeFile:
>+if IncludeFile not in Includes:
>+Includes[IncludeFile] = True
>+CApp = CApp + '#include <%s>\n' % (IncludeFile)
> CApp = CApp + '\n'
>
> for PcdName in StructuredPcds:
> Pcd = StructuredPcds[PcdName]
> if not Pcd.SkuOverrideValues:
>diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py
>b/BaseTools/Source/Python/Workspace/MetaFileParser.py
>index 8f4b5e5cc1..4359ba4b33 100644
>--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
>+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
>@@ -1889,26 +1889,28 @@ class DecParser(MetaFileParser):
> self._ValueList[0] = self._CurrentStructurePcdName
>
> if "|" not in self._CurrentLine:
> if "" == self._CurrentLine:
> self._include_flag = True
>+self._package_flag = False
> self._ValueList = None
> return
> if "" == self._CurrentLine:
> self._package_flag = True
> self._ValueList = None
>+self._include_flag = False
> return
>
> if self._include_flag:
> 

[edk2] [Patch] BaseTools: Support multiple .h file

2018-01-28 Thread BobCF
for structure Pcd declaration in DEC file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py | 2 +-
 BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py | 8 
 BaseTools/Source/Python/Workspace/MetaFileParser.py   | 4 +++-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py 
b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 3afb27a9c0..0e1161c96f 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -113,11 +113,11 @@ class StructurePcd(PcdClassObject):
 if SkuInfoList is None: SkuInfoList={}
 if validateranges is None: validateranges=[]
 if validlists is None: validlists=[]
 if expressions is None : expressions=[]
 super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, 
Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, 
validlists, expressions)
-self.StructuredPcdIncludeFile = StructuredPcdIncludeFile
+self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None 
else StructuredPcdIncludeFile
 self.PackageDecs = Packages
 self.DefaultStoreName = [default_store]
 self.DefaultValues = collections.OrderedDict({})
 self.PcdMode = None
 self.SkuOverrideValues = collections.OrderedDict({})
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py 
b/BaseTools/Source/Python/Workspace/DecBuildData.py
index f6b908dee6..2fd3820dcc 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -374,11 +374,11 @@ class DecBuildData(PackageBuildClassObject):
 for pcdname in s_pcd_set:
 dep_pkgs = []
 struct_pcd = StructurePcd()
 for item,LineNo in s_pcd_set[pcdname]:
 if "" in item.TokenCName:
-struct_pcd.StructuredPcdIncludeFile = item.DefaultValue
+
struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)
 elif "" in item.TokenCName:
 dep_pkgs.append(item.DefaultValue)
 elif item.DatumType == item.TokenCName:
 struct_pcd.copy(item)
 struct_pcd.TokenValue = 
struct_pcd.TokenValue.strip("{").strip()
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 256fdd6875..0384b96997 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1669,14 +1669,14 @@ class DscBuildData(PlatformBuildClassObject):
 CApp = PcdMainCHeader
 
 Includes = {}
 for PcdName in StructuredPcds:
 Pcd = StructuredPcds[PcdName]
-IncludeFile = Pcd.StructuredPcdIncludeFile
-if IncludeFile not in Includes:
-Includes[IncludeFile] = True
-CApp = CApp + '#include <%s>\n' % (IncludeFile)
+for IncludeFile in Pcd.StructuredPcdIncludeFile:
+if IncludeFile not in Includes:
+Includes[IncludeFile] = True
+CApp = CApp + '#include <%s>\n' % (IncludeFile)
 CApp = CApp + '\n'
 
 for PcdName in StructuredPcds:
 Pcd = StructuredPcds[PcdName]
 if not Pcd.SkuOverrideValues:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 8f4b5e5cc1..4359ba4b33 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -1889,26 +1889,28 @@ class DecParser(MetaFileParser):
 self._ValueList[0] = self._CurrentStructurePcdName
 
 if "|" not in self._CurrentLine:
 if "" == self._CurrentLine:
 self._include_flag = True
+self._package_flag = False
 self._ValueList = None
 return
 if "" == self._CurrentLine:
 self._package_flag = True
 self._ValueList = None
+self._include_flag = False
 return
 
 if self._include_flag:
 self._ValueList[1] = "_" + 
md5.new(self._CurrentLine).hexdigest()
 self._ValueList[2] = self._CurrentLine
-self._include_flag = False
 if self._package_flag and "}" != self._CurrentLine:
 self._ValueList[1] = "_" + 
md5.new(self._CurrentLine).hexdigest()
 self._ValueList[2] = self._CurrentLine
  

[edk2] [Patch] BaseTools: Support multiple .h file for structure Pcd declaration in DEC file.

2018-01-22 Thread BobCF
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py | 4 ++--
 BaseTools/Source/Python/Workspace/DecBuildData.py | 2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py | 8 
 BaseTools/Source/Python/Workspace/MetaFileParser.py   | 4 +++-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py 
b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index e5f1f01556..0e3081cfc5 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -107,13 +107,13 @@ class PcdClassObject(object):
 #
 def __hash__(self):
 return hash((self.TokenCName, self.TokenSpaceGuidCName))
 
 class StructurePcd(PcdClassObject):
-def __init__(self, StructuredPcdIncludeFile="", Packages=None, Name=None, 
Guid=None, Type=None, DatumType=None, Value=None, Token=None, 
MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, 
validateranges=[], validlists=[], expressions=[],default_store = 
TAB_DEFAULT_STORES_DEFAULT):
+def __init__(self, StructuredPcdIncludeFile=None, Packages=None, 
Name=None, Guid=None, Type=None, DatumType=None, Value=None, Token=None, 
MaxDatumSize=None, SkuInfoList={}, IsOverrided=False, GuidValue=None, 
validateranges=[], validlists=[], expressions=[],default_store = 
TAB_DEFAULT_STORES_DEFAULT):
 super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value, 
Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges, 
validlists, expressions)
-self.StructuredPcdIncludeFile = StructuredPcdIncludeFile
+self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None 
else StructuredPcdIncludeFile
 self.PackageDecs = Packages
 self.DefaultStoreName = [default_store]
 self.DefaultValues = collections.OrderedDict({})
 self.PcdMode = None
 self.SkuOverrideValues = collections.OrderedDict({})
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py 
b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 01f716bfab..13fb8686b6 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -374,11 +374,11 @@ class DecBuildData(PackageBuildClassObject):
 for pcdname in s_pcd_set:
 dep_pkgs = []
 struct_pcd = StructurePcd()
 for item,LineNo in s_pcd_set[pcdname]:
 if "" in item.TokenCName:
-struct_pcd.StructuredPcdIncludeFile = item.DefaultValue
+
struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)
 elif "" in item.TokenCName:
 dep_pkgs.append(item.DefaultValue)
 elif item.DatumType == item.TokenCName:
 struct_pcd.copy(item)
 struct_pcd.TokenValue = 
struct_pcd.TokenValue.strip("{").strip()
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 4a87fd1762..b042c4306a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1455,14 +1455,14 @@ class DscBuildData(PlatformBuildClassObject):
 CApp = PcdMainCHeader
 
 Includes = {}
 for PcdName in StructuredPcds:
 Pcd = StructuredPcds[PcdName]
-IncludeFile = Pcd.StructuredPcdIncludeFile
-if IncludeFile not in Includes:
-Includes[IncludeFile] = True
-CApp = CApp + '#include <%s>\n' % (IncludeFile)
+for IncludeFile in Pcd.StructuredPcdIncludeFile:
+if IncludeFile not in Includes:
+Includes[IncludeFile] = True
+CApp = CApp + '#include <%s>\n' % (IncludeFile)
 CApp = CApp + '\n'
 
 for PcdName in StructuredPcds:
 Pcd = StructuredPcds[PcdName]
 if not Pcd.SkuOverrideValues:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index b2b0e282eb..7469cd7ab7 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -1889,26 +1889,28 @@ class DecParser(MetaFileParser):
 self._ValueList[0] = self._CurrentStructurePcdName
 
 if "|" not in self._CurrentLine:
 if "" == self._CurrentLine:
 self._include_flag = True
+self._package_flag = False
 self._ValueList = None
 return
 if "" == self._CurrentLine:
 self._package_flag = True
 self._ValueList = None
+