## @ GenCfgOpt.py\r
#\r
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials are licensed and made available under\r
# the terms and conditions of the BSD License that accompanies this distribution.\r
# The full text of the license may be found at\r
def __init__(self):\r
self.Debug = False\r
self.Error = ''\r
- self.ReleaseMode = True\r
\r
self._GlobalDataDef = """\r
GlobalDataDef\r
self._FvDir = ''\r
self._MapVer = 0\r
\r
- def ParseBuildMode (self, OutputStr):\r
- if "RELEASE_" in OutputStr:\r
- self.ReleaseMode = True\r
- if "DEBUG_" in OutputStr:\r
- self.ReleaseMode = False\r
- return\r
-\r
def ParseMacros (self, MacroDefStr):\r
# ['-DABC=1', '-D', 'CFG_DEBUG=1', '-D', 'CFG_OUTDIR=Build']\r
self._MacroDict = {}\r
if Match:\r
IncludeFilePath = Match.group(1)\r
IncludeFilePath = self.ExpandMacros(IncludeFilePath)\r
- try:\r
- IncludeDsc = open(IncludeFilePath, "r")\r
- except:\r
+ PackagesPath = os.getenv("PACKAGES_PATH")\r
+ if PackagesPath:\r
+ for PackagePath in PackagesPath.split(os.pathsep):\r
+ IncludeFilePathAbs = os.path.join(os.path.normpath(PackagePath), os.path.normpath(IncludeFilePath))\r
+ if os.path.exists(IncludeFilePathAbs):\r
+ IncludeDsc = open(IncludeFilePathAbs, "r")\r
+ break\r
+ else:\r
+ IncludeDsc = open(IncludeFilePath, "r")\r
+ if IncludeDsc == None:\r
print("ERROR: Cannot open file '%s'" % IncludeFilePath)\r
raise SystemExit\r
NewDscLines = IncludeDsc.readlines()\r
TxtFd.write("%s.UnusedUpdSpace%d|%s0x%04X|0x%04X|{0}\n" % (Item['space'], SpaceIdx, Default, NextOffset - StartAddr, Offset - NextOffset))\r
SpaceIdx = SpaceIdx + 1\r
NextOffset = Offset + Item['length']\r
- if Item['cname'] == 'PcdSerialIoUartDebugEnable':\r
- if self.ReleaseMode == False:\r
- Item['value'] = 0x01\r
TxtFd.write("%s.%s|%s0x%04X|%s|%s\n" % (Item['space'],Item['cname'],Default,Item['offset'] - StartAddr,Item['length'],Item['value']))\r
TxtFd.close()\r
return 0\r
IsArray = False\r
if Length in [1,2,4,8]:\r
Type = "UINT%d" % (Length * 8)\r
+ if Name.startswith("UnusedUpdSpace") and Length != 1:\r
+ IsArray = True\r
+ Type = "UINT8"\r
else:\r
IsArray = True\r
Type = "UINT8"\r
HeaderFd.write("#ifndef __%s__\n" % FileName)\r
HeaderFd.write("#define __%s__\n\n" % FileName)\r
HeaderFd.write("#include <%s>\n\n" % HeaderFileName)\r
- HeaderFd.write("#pragma pack(push, 1)\n\n")\r
+ HeaderFd.write("#pragma pack(1)\n\n")\r
\r
Export = False\r
for Line in IncLines:\r
for Item in range(len(StructStart)):\r
if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
HeaderFd.write (Line)\r
- HeaderFd.write("#pragma pack(pop)\n\n")\r
+ HeaderFd.write("#pragma pack()\n\n")\r
HeaderFd.write("#endif\n")\r
HeaderFd.close()\r
\r
HeaderFd.write("#ifndef __%s__\n" % FileName)\r
HeaderFd.write("#define __%s__\n\n" % FileName)\r
HeaderFd.write("#include <FspEas.h>\n\n")\r
- HeaderFd.write("#pragma pack(push, 1)\n\n")\r
+ HeaderFd.write("#pragma pack(1)\n\n")\r
\r
for item in range(len(UpdRegionCheck)):\r
Index = 0\r
for Item in range(len(StructStart)):\r
if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]:\r
HeaderFd.write (Line)\r
- HeaderFd.write("#pragma pack(pop)\n\n")\r
+ HeaderFd.write("#pragma pack()\n\n")\r
HeaderFd.write("#endif\n")\r
HeaderFd.close()\r
\r
return 0\r
\r
def WriteBsfStruct (self, BsfFd, Item):\r
+ LogExpr = CLogicalExpression()\r
if Item['type'] == "None":\r
Space = "gPlatformFspPkgTokenSpaceGuid"\r
else:\r
for Option in OptList:\r
Option = Option.strip()\r
(OpVal, OpStr) = Option.split(':')\r
+ test = LogExpr.getNumber (OpVal)\r
+ if test is None:\r
+ raise Exception("Selection Index '%s' is not a number" % OpVal)\r
TmpList.append((OpVal, OpStr))\r
return TmpList\r
\r
else:\r
OutFile = sys.argv[4]\r
Start = 5\r
- GenCfgOpt.ParseBuildMode(sys.argv[3])\r
- if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:\r
- print "ERROR: Macro parsing failed !"\r
- return 3\r
+ if argc > Start:\r
+ if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:\r
+ print "ERROR: Macro parsing failed !"\r
+ return 3\r
\r
FvDir = sys.argv[3]\r
if not os.path.exists(FvDir):\r