X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFsp2Pkg%2FTools%2FGenCfgOpt.py;h=c9b7bc5373fb77c3ac46cba54489f2a31f90dfbc;hp=e8cec95aa7352086a4bb5c44b34cb932464ca242;hb=37431eb1fedbfbfd3b471d5f599aa90c77d97099;hpb=62997d5ede78c0d719548e4ecd9b9c717ce593cf diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py b/IntelFsp2Pkg/Tools/GenCfgOpt.py index e8cec95aa7..c9b7bc5373 100644 --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py @@ -1,6 +1,6 @@ ## @ GenCfgOpt.py # -# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at @@ -289,7 +289,6 @@ class CGenCfgOpt: def __init__(self): self.Debug = False self.Error = '' - self.ReleaseMode = True self._GlobalDataDef = """ GlobalDataDef @@ -318,13 +317,6 @@ EndList self._FvDir = '' self._MapVer = 0 - def ParseBuildMode (self, OutputStr): - if "RELEASE_" in OutputStr: - self.ReleaseMode = True - if "DEBUG_" in OutputStr: - self.ReleaseMode = False - return - def ParseMacros (self, MacroDefStr): # ['-DABC=1', '-D', 'CFG_DEBUG=1', '-D', 'CFG_OUTDIR=Build'] self._MacroDict = {} @@ -523,9 +515,16 @@ EndList if Match: IncludeFilePath = Match.group(1) IncludeFilePath = self.ExpandMacros(IncludeFilePath) - try: - IncludeDsc = open(IncludeFilePath, "r") - except: + PackagesPath = os.getenv("PACKAGES_PATH") + if PackagesPath: + for PackagePath in PackagesPath.split(os.pathsep): + IncludeFilePathAbs = os.path.join(os.path.normpath(PackagePath), os.path.normpath(IncludeFilePath)) + if os.path.exists(IncludeFilePathAbs): + IncludeDsc = open(IncludeFilePathAbs, "r") + break + else: + IncludeDsc = open(IncludeFilePath, "r") + if IncludeDsc == None: print("ERROR: Cannot open file '%s'" % IncludeFilePath) raise SystemExit NewDscLines = IncludeDsc.readlines() @@ -808,9 +807,6 @@ EndList TxtFd.write("%s.UnusedUpdSpace%d|%s0x%04X|0x%04X|{0}\n" % (Item['space'], SpaceIdx, Default, NextOffset - StartAddr, Offset - NextOffset)) SpaceIdx = SpaceIdx + 1 NextOffset = Offset + Item['length'] - if Item['cname'] == 'PcdSerialIoUartDebugEnable': - if self.ReleaseMode == False: - Item['value'] = 0x01 TxtFd.write("%s.%s|%s0x%04X|%s|%s\n" % (Item['space'],Item['cname'],Default,Item['offset'] - StartAddr,Item['length'],Item['value'])) TxtFd.close() return 0 @@ -875,6 +871,9 @@ EndList IsArray = False if Length in [1,2,4,8]: Type = "UINT%d" % (Length * 8) + if Name.startswith("UnusedUpdSpace") and Length != 1: + IsArray = True + Type = "UINT8" else: IsArray = True Type = "UINT8" @@ -1129,7 +1128,7 @@ EndList HeaderFd.write("#ifndef __%s__\n" % FileName) HeaderFd.write("#define __%s__\n\n" % FileName) HeaderFd.write("#include <%s>\n\n" % HeaderFileName) - HeaderFd.write("#pragma pack(push, 1)\n\n") + HeaderFd.write("#pragma pack(1)\n\n") Export = False for Line in IncLines: @@ -1177,7 +1176,7 @@ EndList for Item in range(len(StructStart)): if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]: HeaderFd.write (Line) - HeaderFd.write("#pragma pack(pop)\n\n") + HeaderFd.write("#pragma pack()\n\n") HeaderFd.write("#endif\n") HeaderFd.close() @@ -1188,7 +1187,7 @@ EndList HeaderFd.write("#ifndef __%s__\n" % FileName) HeaderFd.write("#define __%s__\n\n" % FileName) HeaderFd.write("#include \n\n") - HeaderFd.write("#pragma pack(push, 1)\n\n") + HeaderFd.write("#pragma pack(1)\n\n") for item in range(len(UpdRegionCheck)): Index = 0 @@ -1222,13 +1221,14 @@ EndList for Item in range(len(StructStart)): if Index >= StructStartWithComment[Item] and Index <= StructEnd[Item]: HeaderFd.write (Line) - HeaderFd.write("#pragma pack(pop)\n\n") + HeaderFd.write("#pragma pack()\n\n") HeaderFd.write("#endif\n") HeaderFd.close() return 0 def WriteBsfStruct (self, BsfFd, Item): + LogExpr = CLogicalExpression() if Item['type'] == "None": Space = "gPlatformFspPkgTokenSpaceGuid" else: @@ -1250,6 +1250,9 @@ EndList for Option in OptList: Option = Option.strip() (OpVal, OpStr) = Option.split(':') + test = LogExpr.getNumber (OpVal) + if test is None: + raise Exception("Selection Index '%s' is not a number" % OpVal) TmpList.append((OpVal, OpStr)) return TmpList @@ -1418,10 +1421,10 @@ def Main(): else: OutFile = sys.argv[4] Start = 5 - GenCfgOpt.ParseBuildMode(sys.argv[3]) - if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0: - print "ERROR: Macro parsing failed !" - return 3 + if argc > Start: + if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0: + print "ERROR: Macro parsing failed !" + return 3 FvDir = sys.argv[3] if not os.path.exists(FvDir):