From 2bcc713e74b944bb5aefb433ef33fb4002a62d76 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Fri, 25 Nov 2011 06:21:03 +0000 Subject: Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes: 1. Fix !include issues 2. Fix Trim to skip the postfix 'U' for hexadecimal and decimal numbers 3. Fix building error C2733 when building C++ code. 4. Add GCC46 tool chain definition 5. Add new RVCT and RVCTLINUX tool chains Signed-off-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12782 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/UPT/BuildVersion.py | 3 ++ BaseTools/Source/Python/UPT/Library/Misc.py | 53 +++++++++++++++++++++++ BaseTools/Source/Python/UPT/Logger/StringTable.py | 1 + BaseTools/Source/Python/UPT/Makefile | 4 +- BaseTools/Source/Python/UPT/Parser/InfParser.py | 18 ++++++++ BaseTools/Source/Python/UPT/UPT.py | 2 +- 6 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 BaseTools/Source/Python/UPT/BuildVersion.py (limited to 'BaseTools/Source/Python/UPT') diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py new file mode 100644 index 0000000000..4bb9a8b521 --- /dev/null +++ b/BaseTools/Source/Python/UPT/BuildVersion.py @@ -0,0 +1,3 @@ +#This file is for build version number auto generation +# +gBUILD_VERSION = "Build 2423" diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py index 658c4e0cfb..b67cd102d1 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -834,6 +834,59 @@ def ProcessLineExtender(LineList): return NewList +## ProcessEdkComment +# +# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment +# +# +# @param LineList The LineList need to be processed. +# +# @return LineList The LineList been processed. +# @return FirstPos Where Edk comment is first found, -1 if not found +# +def ProcessEdkComment(LineList): + FindEdkBlockComment = False + Count = 0 + StartPos = -1 + EndPos = -1 + FirstPos = -1 + + while(Count < len(LineList)): + Line = LineList[Count].strip() + if Line.startswith("/*"): + # + # handling c style comment + # + StartPos = Count + while Count < len(LineList): + Line = LineList[Count].strip() + if Line.endswith("*/"): + if (Count == StartPos) and Line.strip() == '/*/': + Count = Count + 1 + continue + EndPos = Count + FindEdkBlockComment = True + break + Count = Count + 1 + + if FindEdkBlockComment: + if FirstPos == -1: + FirstPos = StartPos + for Index in xrange(StartPos, EndPos+1): + LineList[Index] = '' + FindEdkBlockComment = False + elif Line.find("//") != -1: + # + # handling cpp style comment + # + LineList[Count] = Line.replace("//", '#') + if FirstPos == -1: + FirstPos = Count + + Count = Count + 1 + + return LineList, FirstPos + ## GetLibInstanceInfo # # Get the information from Library Instance INF file. diff --git a/BaseTools/Source/Python/UPT/Logger/StringTable.py b/BaseTools/Source/Python/UPT/Logger/StringTable.py index 230c659189..063ca52d2b 100644 --- a/BaseTools/Source/Python/UPT/Logger/StringTable.py +++ b/BaseTools/Source/Python/UPT/Logger/StringTable.py @@ -196,6 +196,7 @@ ERR_INF_PARSER_VER_EXIST_BOTH_NUM_STR = \ _("The INF file %s defines both VERSION_NUMBER and VERSION_STRING, " "using VERSION_STRING") ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF = _("EDKI INF is not supported") +ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII = _("The EDKI style comment is not supported in EDKII modules") ERR_INF_PARSER_FEATUREPCD_USAGE_INVALID = _("The usage for FeaturePcd can only" " be type of \"CONSUMES\".") diff --git a/BaseTools/Source/Python/UPT/Makefile b/BaseTools/Source/Python/UPT/Makefile index a6e3a6dd41..d4eef45196 100644 --- a/BaseTools/Source/Python/UPT/Makefile +++ b/BaseTools/Source/Python/UPT/Makefile @@ -24,14 +24,14 @@ SOURCES_PATH = . APPLICATIONS=$(BIN_DIR)\UPT.exe -COMMON_PYTHON=$(SOURCES_PATH)\UPT.py +UPT_BUILDVERSION_PYTHON=$(SOURCES_PATH)\BuildVersion.py all: SetPythonPath $(APPLICATIONS) SetPythonPath: set PYTHONPATH= $(SOURCES_PATH) -$(BIN_DIR)\UPT.exe: $(SOURCES_PATH)\UPT.py $(COMMON_PYTHON) +$(BIN_DIR)\UPT.exe: $(SOURCES_PATH)\UPT.py $(UPT_BUILDVERSION_PYTHON) @pushd . & @cd build & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) UPT.py & @popd @pushd . & @copy .\Dll\sqlite3.dll .\Bin\Sqlite3.dll & @popd clean: diff --git a/BaseTools/Source/Python/UPT/Parser/InfParser.py b/BaseTools/Source/Python/UPT/Parser/InfParser.py index aa44e8038d..79f71448ee 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfParser.py @@ -26,6 +26,7 @@ from copy import deepcopy from Library.String import GetSplitValueList from Library.String import ConvertSpecialChar from Library.Misc import ProcessLineExtender +from Library.Misc import ProcessEdkComment from Library.Parsing import NormPath from Library.ParserValidate import IsValidInfMoudleTypeList from Library.ParserValidate import IsValidArch @@ -164,6 +165,12 @@ class InfParser(InfSectionParser): # FileLinesList = ProcessLineExtender(FileLinesList) + # + # Process EdkI INF style comment if found + # + OrigLines = [Line for Line in FileLinesList] + FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList) + # # Judge whether the INF file is Binary INF or not # @@ -338,6 +345,17 @@ class InfParser(InfSectionParser): ST.ERR_INF_PARSER_HEADER_MISSGING, File=self.FullPath) + # + # EDKII INF should not have EDKI style comment + # + if EdkCommentStartPos != -1: + Logger.Error("InfParser", + FORMAT_INVALID, + ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII, + File=self.FullPath, + Line=EdkCommentStartPos + 1, + ExtraData=OrigLines[EdkCommentStartPos]) + # # extract [Event] [Hob] [BootMode] sections # diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/UPT/UPT.py index a9066a259a..b168a51daa 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -43,7 +43,7 @@ import RmPkg from Library.Misc import CheckEnvVariable from Library import GlobalData from Core.IpiDb import IpiDatabase -from Common.BuildVersion import gBUILD_VERSION +from BuildVersion import gBUILD_VERSION ## # Version and Copyright -- cgit v1.2.3