## @file\r
# This file is used to parse DEC file. It will consumed by DecParser\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials are licensed and made available \r
# under the terms and conditions of the BSD License which accompanies this \r
from Library.ParserValidate import IsValidUserId\r
from Library.ParserValidate import IsValidArch\r
from Library.ParserValidate import IsValidWord\r
+from Library.ParserValidate import IsValidDecVersionVal\r
from Parser.DecParserMisc import TOOL_NAME\r
from Parser.DecParserMisc import CleanString\r
from Parser.DecParserMisc import IsValidPcdDatum\r
from Object.Parser.DecObject import DecPcdItemObject\r
from Library.Misc import GuidStructureStringToGuidString\r
from Library.Misc import CheckGuidRegFormat\r
-from Library.String import ReplaceMacro\r
-from Library.String import GetSplitValueList\r
-from Library.String import gMACRO_PATTERN\r
-from Library.String import ConvertSpecialChar\r
+from Library.StringUtils import ReplaceMacro\r
+from Library.StringUtils import GetSplitValueList\r
+from Library.StringUtils import gMACRO_PATTERN\r
+from Library.StringUtils import ConvertSpecialChar\r
from Library.CommentParsing import ParsePcdErrorCode\r
\r
##\r
self._LoggerError(ST.ERR_DECPARSE_BACKSLASH_EMPTY)\r
CatLine += Line\r
\r
- self._RawData.CurrentLine = self._ReplaceMacro(CatLine)\r
+ #\r
+ # All MACRO values defined by the DEFINE statements in any section\r
+ # (except [Userextensions] sections for Intel) of the INF or DEC file\r
+ # must be expanded before processing of the file.\r
+ #\r
+ __IsReplaceMacro = True\r
+ Header = self._RawData.CurrentScope[0] if self._RawData.CurrentScope else None\r
+ if Header and len(Header) > 2:\r
+ if Header[0].upper() == 'USEREXTENSIONS' and not (Header[1] == 'TianoCore' and Header[2] == '"ExtraFiles"'):\r
+ __IsReplaceMacro = False\r
+ if __IsReplaceMacro:\r
+ self._RawData.CurrentLine = self._ReplaceMacro(CatLine)\r
+ else:\r
+ self._RawData.CurrentLine = CatLine\r
+\r
return CatLine, CommentList\r
\r
## Parse\r
if self.ItemObject.GetPackageSpecification():\r
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_DEC_SPECIFICATION)\r
if not IsValidToken('0[xX][0-9a-fA-F]{8}', Token):\r
- self._LoggerError(ST.ERR_DECPARSE_DEFINE_SPEC)\r
+ if not IsValidDecVersionVal(Token):\r
+ self._LoggerError(ST.ERR_DECPARSE_DEFINE_SPEC)\r
self.ItemObject.SetPackageSpecification(Token)\r
\r
def _SetPackageName(self, Token):\r
except BaseException:\r
Logger.Error(TOOL_NAME, FILE_OPEN_FAILURE, File=DecFile,\r
ExtraData=ST.ERR_DECPARSE_FILEOPEN % DecFile)\r
- RawData = FileContent(DecFile, Content)\r
+\r
+ #\r
+ # Pre-parser for Private section\r
+ #\r
+ self._Private = ''\r
+ __IsFoundPrivate = False\r
+ NewContent = []\r
+ for Line in Content:\r
+ Line = Line.strip()\r
+ if Line.startswith(DT.TAB_SECTION_START) and Line.endswith(DT.TAB_PRIVATE + DT.TAB_SECTION_END):\r
+ __IsFoundPrivate = True\r
+ if Line.startswith(DT.TAB_SECTION_START) and Line.endswith(DT.TAB_SECTION_END)\\r
+ and not Line.endswith(DT.TAB_PRIVATE + DT.TAB_SECTION_END):\r
+ __IsFoundPrivate = False\r
+ if __IsFoundPrivate:\r
+ self._Private += Line + '\r'\r
+ if not __IsFoundPrivate:\r
+ NewContent.append(Line + '\r')\r
+\r
+ RawData = FileContent(DecFile, NewContent)\r
\r
_DecComments.__init__(self)\r
_DecBase.__init__(self, RawData)\r
return self._Define.GetDataObject().GetPackageVersion()\r
def GetPackageUniFile(self):\r
return self._Define.GetDataObject().GetPackageUniFile()\r
+ def GetPrivateSections(self):\r
+ return self._Private\r