BaseTools: Enable structure pcd in FDF file
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / BuildClassObject.py
index c188b47..3b47715 100644 (file)
@@ -70,7 +70,8 @@ class PcdClassObject(object):
         if IsDsc:\r
             self.DscDefaultValue = Value\r
         self.PcdValueFromComm = ""\r
-        self.DefinitionPosition = ("", "")\r
+        self.PcdValueFromFdf = ""\r
+        self.DefinitionPosition = ("","")\r
 \r
     ## Get the maximum number of bytes\r
     def GetPcdMaxSize(self):\r
@@ -78,6 +79,16 @@ class PcdClassObject(object):
             return MAX_SIZE_TYPE[self.DatumType]\r
 \r
         MaxSize = int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0\r
+        if self.PcdValueFromFdf:\r
+            if self.PcdValueFromFdf.startswith("{") and self.PcdValueFromFdf.endswith("}"):\r
+                MaxSize =  max([len(self.PcdValueFromFdf.split(",")),MaxSize])\r
+            elif self.PcdValueFromFdf.startswith("\"") or self.PcdValueFromFdf.startswith("\'"):\r
+                MaxSize =  max([len(self.PcdValueFromFdf)-2+1,MaxSize])\r
+            elif self.PcdValueFromFdf.startswith("L\""):\r
+                MaxSize =  max([2*(len(self.PcdValueFromFdf)-3+1),MaxSize])\r
+            else:\r
+                MaxSize = max([len(self.PcdValueFromFdf),MaxSize])\r
+\r
         if self.PcdValueFromComm:\r
             if self.PcdValueFromComm.startswith("{") and self.PcdValueFromComm.endswith("}"):\r
                 return max([len(self.PcdValueFromComm.split(",")), MaxSize])\r
@@ -169,6 +180,7 @@ class StructurePcd(PcdClassObject):
         self.DefaultValueFromDec = ""\r
         self.ValueChain = set()\r
         self.PcdFieldValueFromComm = collections.OrderedDict()\r
+        self.PcdFieldValueFromFdf = collections.OrderedDict()\r
     def __repr__(self):\r
         return self.TypeName\r
 \r
@@ -216,6 +228,7 @@ class StructurePcd(PcdClassObject):
         self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions\r
         self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue\r
         self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm\r
+        self.PcdValueFromFdf = PcdObject.PcdValueFromFdf if PcdObject.PcdValueFromFdf else self.PcdValueFromFdf\r
         self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition\r
         if isinstance(PcdObject, StructurePcd):\r
             self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile\r
@@ -231,6 +244,7 @@ class StructurePcd(PcdClassObject):
             self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath\r
             self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain\r
             self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm\r
+            self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf\r
 \r
 ## LibraryClassObject\r
 #\r