[edk2] [PATCH 1/1] BaseTools: Sync MdePkg/Library/UefiDevicePathLib/DevicePathToText.c code
Sync MdePkg/Library/UefiDevicePathLib/DevicePathToText.c code Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/DevicePath/DevicePath.c | 2 +- BaseTools/Source/C/DevicePath/DevicePathFromText.c | 59 ++ BaseTools/Source/C/Include/Protocol/DevicePath.h | 2 +- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c index 956bbffb5f..356f5f7e24 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -23,11 +23,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // Utility version information // #define UTILITY_MAJOR_VERSION 0 #define UTILITY_MINOR_VERSION 1 -EFI_GUID gEfiDebugPortDevicePathGuid = DEVICE_PATH_MESSAGING_DEBUGPORT; +EFI_GUID gEfiDebugPortProtocolGuid = DEVICE_PATH_MESSAGING_DEBUGPORT; EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID; EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID; EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID; EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID; EFI_GUID gEfiUartDevicePathGuid = EFI_UART_DEVICE_PATH_GUID; diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c index bb74e2e170..555efa1acd 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -762,11 +762,20 @@ DevPathFromTextAcpiExp ( ACPI_EXTENDED_DP, Length ); AcpiEx->HID = EisaIdFromText (HIDStr); - AcpiEx->CID = EisaIdFromText (CIDStr); + // + // According to UEFI spec, the CID parametr is optional and has a default value of 0. + // So when the CID parametr is not specified or specified as 0 in the text device node. + // Set the CID to 0 in the ACPI extension device path structure. + // + if (*CIDStr == L'\0' || *CIDStr == L'0') { +AcpiEx->CID = 0; + } else { +AcpiEx->CID = EisaIdFromText (CIDStr); + } AcpiEx->UID = 0; AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); // // HID string is NULL @@ -1601,19 +1610,19 @@ DevPathFromTextEmmc ( EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextDebugPort ( CHAR16 *TextDeviceNode ) { - VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend; + VENDOR_DEVICE_PATH *Vend; - Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode ( + Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, -(UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH) +(UINT16) sizeof (VENDOR_DEVICE_PATH) ); - CopyGuid (>Guid, ); + CopyGuid (>Guid, ); return (EFI_DEVICE_PATH_PROTOCOL *) Vend; } /** @@ -1904,26 +1913,46 @@ ConvertFromTextUsbClass ( VIDStr = GetNextParamStr (); PIDStr = GetNextParamStr (); if (UsbClassText->ClassExist) { ClassStr = GetNextParamStr (); -UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); +if (*ClassStr == L'\0') { + UsbClass->DeviceClass = 0xFF; +} else { + UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); +} } else { UsbClass->DeviceClass = UsbClassText->Class; } if (UsbClassText->SubClassExist) { SubClassStr = GetNextParamStr (); -UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); +if (*SubClassStr == L'\0') { + UsbClass->DeviceSubClass = 0xFF; +} else { + UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); +} } else { UsbClass->DeviceSubClass = UsbClassText->SubClass; } ProtocolStr = GetNextParamStr (); - UsbClass->VendorId= (UINT16) Strtoi (VIDStr); - UsbClass->ProductId = (UINT16) Strtoi (PIDStr); - UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + if (*VIDStr == L'\0') { +UsbClass->VendorId= 0x; + } else { +UsbClass->VendorId= (UINT16) Strtoi (VIDStr); + } + if (*PIDStr == L'\0') { +UsbClass->ProductId = 0x; + } else { +UsbClass->ProductId = (UINT16) Strtoi (PIDStr); + } + if (*ProtocolStr == L'\0') { +UsbClass->DeviceProtocol = 0xFF; + } else { +UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + } return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass; } @@ -3259,11 +3288,19 @@ DevPathFromTextSata ( MESSAGING_DEVICE_PATH, MSG_SATA_DP, (UINT16) sizeof (SATA_DEVICE_PATH)
[edk2] [PATCH 1/1] BaseTools: Roll back code modify by commit 9e47e6f90880
Roll back code modify by commit 9e47e6f90880, if ForceRebase not False or True, the GenFv command not need add parameter Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index e867693d7c..ea61f723a7 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -572,13 +572,13 @@ class GenFdsGlobalVariable: Cmd = ["GenFv"] if BaseAddress: Cmd += ("-r", BaseAddress) -if not ForceRebase: +if ForceRebase == False: Cmd += ("-F", "FALSE") -else: +elif ForceRebase == True: Cmd += ("-F", "TRUE") if Capsule: Cmd.append("-c") if Dump: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/1] BaseTools: Use VENDOR_DEVICE_PATH structure for Debug Port device path
Copy code from Commit 9343d0a1cd09544686b14dba5b428d7bc811f6b9 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/DevicePath/DevicePath.c | 2 +- BaseTools/Source/C/DevicePath/DevicePathFromText.c | 6 +++--- BaseTools/Source/C/Include/Protocol/DevicePath.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c index 956bbffb5f..356f5f7e24 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -23,11 +23,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // Utility version information // #define UTILITY_MAJOR_VERSION 0 #define UTILITY_MINOR_VERSION 1 -EFI_GUID gEfiDebugPortDevicePathGuid = DEVICE_PATH_MESSAGING_DEBUGPORT; +EFI_GUID gEfiDebugPortProtocolGuid = DEVICE_PATH_MESSAGING_DEBUGPORT; EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID; EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID; EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID; EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID; EFI_GUID gEfiUartDevicePathGuid = EFI_UART_DEVICE_PATH_GUID; diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c index bb74e2e170..2647a2020c 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -1601,19 +1601,19 @@ DevPathFromTextEmmc ( EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextDebugPort ( CHAR16 *TextDeviceNode ) { - VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend; + VENDOR_DEVICE_PATH *Vend; - Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode ( + Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH) ); - CopyGuid (>Guid, ); + CopyGuid (>Guid, ); return (EFI_DEVICE_PATH_PROTOCOL *) Vend; } /** diff --git a/BaseTools/Source/C/Include/Protocol/DevicePath.h b/BaseTools/Source/C/Include/Protocol/DevicePath.h index 68bb37e479..0295582cbd 100644 --- a/BaseTools/Source/C/Include/Protocol/DevicePath.h +++ b/BaseTools/Source/C/Include/Protocol/DevicePath.h @@ -1378,11 +1378,11 @@ extern EFI_GUID gEfiDebugPortVariableGuid; // // DebugPort device path definitions... // #define DEVICE_PATH_MESSAGING_DEBUGPORT EFI_DEBUGPORT_PROTOCOL_GUID -extern EFI_GUID gEfiDebugPortDevicePathGuid; +extern EFI_GUID gEfiDebugPortProtocolGuid; typedef struct { EFI_DEVICE_PATH_PROTOCOL Header; EFI_GUID Guid; } DEBUGPORT_DEVICE_PATH; -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/1] BaseTools: Fix BPDG tool print traceback info issue
Fix BPDG tool print traceback info issue and remove abundant code Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/BPDG/BPDG.py | 5 - BaseTools/Source/Python/Common/VpdInfoFile.py | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py index 2ec1516c0a..c30e062a69 100644 --- a/BaseTools/Source/Python/BPDG/BPDG.py +++ b/BaseTools/Source/Python/BPDG/BPDG.py @@ -151,11 +151,14 @@ def StartBpdg(InputFileName, MapFileName, VpdFileName, Force): GenVPD.GenerateVpdFile(MapFileName, VpdFileName) EdkLogger.info("- Vpd pcd fixed done! -") if __name__ == '__main__': -r = main() +try: +r = main() +except FatalError as e: +r = e ## 0-127 is a safe return range, and 1 is a standard default error if r < 0 or r > 127: r = 1 sys.exit(r) diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 0485bf482e..2fb8e66fe9 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -252,11 +252,10 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): print(out) while PopenObject.returncode is None : PopenObject.wait() if PopenObject.returncode != 0: -if PopenObject.returncode != 0: -EdkLogger.debug(EdkLogger.DEBUG_1, "Fail to call BPDG tool", str(error)) -EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to execute BPDG tool with exit code: %d, the error message is: \n %s" % \ +EdkLogger.debug(EdkLogger.DEBUG_1, "Fail to call BPDG tool", str(error)) +EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to execute BPDG tool with exit code: %d, the error message is: \n %s" % \ (PopenObject.returncode, str(error))) return PopenObject.returncode -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] BaseTools: covert "unicode string" to "byte array" if value type diff.
Unicode string should be start with 'L"' or "L'", but like as "Less" is not Unicode string > -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Carsey, Jaben > Sent: Thursday, October 18, 2018 2:49 AM > To: Laszlo Ersek ; Zhao, ZhiqiangX > > Cc: edk2-devel@lists.01.org; Gao, Liming > Subject: Re: [edk2] [PATCH] BaseTools: covert "unicode string" to "byte > array" if value type diff. > > > > > -Original Message- > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > > Laszlo Ersek > > Sent: Wednesday, October 17, 2018 11:37 AM > > To: Zhao, ZhiqiangX > > Cc: edk2-devel@lists.01.org; Gao, Liming > > Subject: Re: [edk2] [PATCH] BaseTools: covert "unicode string" to "byte > > array" if value type diff. > > > > Hi, > > > > On 10/17/18 13:08, Zhaozh1x wrote: > > > For the same one VOID* pcd, if the default value type of one sku is > > > "unicode string", the other skus are "OtherVOID*"(ascii string or > > > byte array),Then covert "unicode string" to "byte array". > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > Signed-off-by: ZhiqiangX Zhao > > > Cc: Liming Gao > > > Cc: Yonghong Zhu > > > Reviewed-by: Bob Feng > > > --- > > > BaseTools/Source/Python/Workspace/DscBuildData.py | 9 + > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py > > b/BaseTools/Source/Python/Workspace/DscBuildData.py > > > index 7854e71db6..9b783de84b 100644 > > > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > > > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > > > @@ -2877,6 +2877,15 @@ class DscBuildData(PlatformBuildClassObject): > > > elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in > > pcd.SkuInfoList: > > > del pcd.SkuInfoList[TAB_COMMON] > > > > > > +#For the same one VOID* pcd, if the default value type of one > > > sku is > > "unicode string", > > > +#the other skus are "OtherVOID*"(ascii string or byte array),Then > > covert "unicode string" to "byte array". > > > +for pcd in Pcds.values(): > > > +PcdValueTypeList = [] > > > +for sku in pcd.SkuInfoList.values(): > > > +PcdValueTypeList.append("UnicodeString" if > > sku.DefaultValue.startswith("L") else "OtherVOID*") > > > +if "UnicodeString" in PcdValueTypeList and "OtherVOID*" in > > PcdValueTypeList: > > If you use a set instead of a list here, it will save memory any then instead > of > testing for both items being there, you could just check the length being > 1 > which would also be faster than 2 "in" tests. > > > > +for sku in pcd.SkuInfoList.values(): > > > +sku.DefaultValue = StringToArray(sku.DefaultValue) if > > sku.DefaultValue.startswith("L") else sku.DefaultValue > > > > > > map(self.FilterSkuSettings, Pcds.values()) > > > return Pcds > > > > > > > no comments on the code change, just a superficial one on the subject > > line: please replace "covert" with "convert". > > > > There are two more instances of the typo in the patch: in the commit > > message, and in the new code too. (Three occurrences in total.) > > > > Normally I shouldn't obsess about such small typos, in case they don't > > obscure the intended meaning. However, "covert" did confuse me, > because > > it is an existent word, and it has a specific meaning in computing: > > > > https://en.wikipedia.org/wiki/Covert_channel > > > > Thanks! > > Laszlo > > ___ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > ___ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/1] BaseTools: Fix regression boot hang issue by commit 0e982cf03dd5
Fix regression boot hang issue by commit 0e982cf03dd5023b90def60c3656e5e18135ebac Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/Fv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 510f2834a8..c66fc38327 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -202,12 +202,12 @@ class FV (FvClassObject): Signature = FvHeaderBuffer[0x28:0x32] if Signature and Signature.startswith('_FVH'): GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV Successfully" % self.UiFvName) GenFdsGlobalVariable.SharpCounter = 0 -Buffer.write(FvFileObj.read()) FvFileObj.seek(0) +Buffer.write(FvFileObj.read()) # FV alignment position. FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F) if FvAlignmentValue >= 0x400: if FvAlignmentValue >= 0x10: if FvAlignmentValue >= 0x100: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Regression bug Linux script used windows line format
regression by 15e20228258c1714cd90207a52101a5b1b54cd2c and 9f3594782de9051cbf599f9af006903ed3f6669e Linux execute script must use '\n' not '\r\n' for end of line Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/BinWrappers/PosixLike/BPDG | 2 +- BaseTools/BinWrappers/PosixLike/GenFds | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG index bca1bae96a..276c7ea207 100755 --- a/BaseTools/BinWrappers/PosixLike/BPDG +++ b/BaseTools/BinWrappers/PosixLike/BPDG @@ -9,6 +9,6 @@ fi full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" -exec "${python_exe:-python}" -m $cmd.$cmd "$@" +exec "${python_exe:-python}" -m $cmd.$cmd "$@" diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds index bca1bae96a..276c7ea207 100755 --- a/BaseTools/BinWrappers/PosixLike/GenFds +++ b/BaseTools/BinWrappers/PosixLike/GenFds @@ -9,6 +9,6 @@ fi full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a discussion of why $0 is not a good choice here dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" -exec "${python_exe:-python}" -m $cmd.$cmd "$@" +exec "${python_exe:-python}" -m $cmd.$cmd "$@" -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH V2] BaseTools: Fix regression issue by b23414f6540d
V2: Renaming function DepexExpressionTokenList to DepexExpressionDict instead of changing the callers Fix regression issue by b23414f6540d4f336b6f00b44681911d469f9a04 AttributeError: 'ModuleAutoGen' object has no attribute 'DepexExpressionDict' Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 3b1ddc74e8..d30a9be6ee 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2899,11 +2899,11 @@ class ModuleAutoGen(AutoGen): ## Merge dependency expression # # @retval listThe token list of the dependency expression after parsed # @cached_property -def DepexExpressionTokenList(self): +def DepexExpressionDict(self): if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes: return {} RetVal = {self.ModuleType:''} -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix regression issue by b23414f6540d
Fix regression issue by b23414f6540d4f336b6f00b44681911d469f9a04 AttributeError: 'ModuleAutoGen' object has no attribute 'DepexExpressionDict' Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/build/BuildReport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index deb88a7817..63c040ec07 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -423,11 +423,11 @@ class DepexReport(object): if Match: self.Depex = Match.group(1).strip() self.Source = "DXS" break else: -self.Depex = M.DepexExpressionDict.get(M.ModuleType, "") +self.Depex = M.DepexExpressionTokenList.get(M.ModuleType, "") self.ModuleDepex = " ".join(M.Module.DepexExpression[M.Arch, M.ModuleType]) if not self.ModuleDepex: self.ModuleDepex = "(None)" LibDepexList = [] -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 3/3] BaseTools: Use hashlib instead of md5
Use from hashlib import md5 instead of import md5 due to md5 deprecated in python3 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py | 4 ++-- BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py | 4 ++-- BaseTools/Source/Python/UPT/InstallPkg.py | 12 ++-- BaseTools/Source/Python/UPT/MkPkg.py | 4 ++-- BaseTools/Source/Python/UPT/RmPkg.py | 4 ++-- BaseTools/Source/Python/Workspace/MetaFileParser.py | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py index 0ba07ccebc..e2dd6a02dc 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py @@ -17,11 +17,11 @@ GenDEC ''' import os import stat import codecs -import md5 +from hashlib import md5 from Core.FileHook import __FileHookOpen__ from Library.Parsing import GenSection from Library.CommentGenerating import GenHeaderCommentSection from Library.CommentGenerating import GenGenericCommentF from Library.CommentGenerating import GenDecTailComment @@ -644,11 +644,11 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO Content += PcdErrString File = codecs.open(ContainerFile, 'w', Encoding) File.write(u'\uFEFF' + Content) File.stream.close() -Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read()) +Md5Sigature = md5(__FileHookOpen__(str(ContainerFile), 'rb').read()) Md5Sum = Md5Sigature.hexdigest() if (ContainerFile, Md5Sum) not in PackageObject.FileList: PackageObject.FileList.append((ContainerFile, Md5Sum)) return ContainerFile diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py index b62c705137..c2a240a884 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py @@ -16,11 +16,11 @@ GenInf ''' import os import stat import codecs -import md5 +from hashlib import md5 from Core.FileHook import __FileHookOpen__ from Library.StringUtils import GetSplitValueList from Library.Parsing import GenSection from Library.Parsing import GetWorkspacePackage from Library.Parsing import ConvertArchForInstall @@ -253,11 +253,11 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD if not os.path.exists(ContainerFile): File = codecs.open(ContainerFile, 'wb', Encoding) File.write(u'\uFEFF' + Content) File.stream.close() -Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read()) +Md5Sigature = md5(__FileHookOpen__(str(ContainerFile), 'rb').read()) Md5Sum = Md5Sigature.hexdigest() if (ContainerFile, Md5Sum) not in ModuleObject.FileList: ModuleObject.FileList.append((ContainerFile, Md5Sum)) return ContainerFile diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py b/BaseTools/Source/Python/UPT/InstallPkg.py index 3573886d5a..c553d707fd 100644 --- a/BaseTools/Source/Python/UPT/InstallPkg.py +++ b/BaseTools/Source/Python/UPT/InstallPkg.py @@ -21,11 +21,11 @@ from Core.FileHook import __FileHookOpen__ import os.path from os import chmod from os import SEEK_SET from os import SEEK_END import stat -import md5 +from hashlib import md5 import copy from sys import stdin from sys import platform from shutil import rmtree from shutil import copyfile @@ -174,11 +174,11 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1): # # verify MD5 signature when existed # if DistPkg.Header.Signature != '': -Md5Sigature = md5.new(__FileHookOpen__(ContentFile, 'rb').read()) +Md5Sigature = md5(__FileHookOpen__(ContentFile, 'rb').read()) if DistPkg.Header.Signature != Md5Sigature.hexdigest(): ContentZipFile.Close() Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE, ExtraData=ContentFile) @@ -213,11 +213,11 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi # all packages installed, else hard to resolve modules' package # dependency (Hard to get the location of the newly installed package) # for Package in PackageList: FilePath = PackageToDec(Package, DistPkg.Header) -Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read()) +Md5Sigature = md5(__FileHookOpen__(str(FilePath), 'rb').read()) Md5Sum = Md5Sigature.hexdigest() if (FilePath, Md5Sum) not in Package.FileList: Package.FileList.append((FilePath, Md5Sum)) return NewDict @@ -273,11 +273,11 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile,
[edk2] [PATCH 2/3] BaseTools: remove cmp due to deprecated in python3
remove cmp due to deprecated in python3 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 6 +++--- BaseTools/Source/Python/BPDG/GenVpd.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 06ff84b4cd..a926a27c6e 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -997,11 +997,11 @@ class WorkspaceAutoGen(AutoGen): # def _CheckAllPcdsTokenValueConflict(self): for Pa in self.AutoGenObjectList: for Package in Pa.PackageList: PcdList = Package.Pcds.values() -PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0))) +PcdList.sort(key=lambda x: int(x.TokenValue, 0)) Count = 0 while (Count < len(PcdList) - 1) : Item = PcdList[Count] ItemNext = PcdList[Count + 1] # @@ -1018,11 +1018,11 @@ class WorkspaceAutoGen(AutoGen): else: break; # # Sort same token value PCD list with TokenGuid and TokenCName # -SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName))) +SameTokenValuePcdList.sort(key=lambda x: "%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName)) SameTokenValuePcdListCount = 0 while (SameTokenValuePcdListCount < len(SameTokenValuePcdList) - 1): Flag = False TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount] TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1] @@ -1043,11 +1043,11 @@ class WorkspaceAutoGen(AutoGen): SameTokenValuePcdListCount += 1 Count += SameTokenValuePcdListCount Count += 1 PcdList = Package.Pcds.values() -PcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName))) +PcdList.sort(key=lambda x: "%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName)) Count = 0 while (Count < len(PcdList) - 1) : Item = PcdList[Count] ItemNext = PcdList[Count + 1] # diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py index cd272a2d9a..c5e91a3e81 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -502,16 +502,16 @@ class GenVPD : def FixVpdOffset (self): # At first, the offset should start at 0 # Sort fixed offset list in order to find out where has free spaces for the pcd's offset # value is "*" to insert into. -self.PcdFixedOffsetSizeList.sort(lambda x, y: cmp(x.PcdBinOffset, y.PcdBinOffset)) +self.PcdFixedOffsetSizeList.sort(key=lambda x: x.PcdBinOffset) # # Sort the un-fixed pcd's offset by it's size. # -self.PcdUnknownOffsetList.sort(lambda x, y: cmp(x.PcdBinSize, y.PcdBinSize)) +self.PcdUnknownOffsetList.sort(key=lambda x: x.PcdBinSize) index =0 for pcd in self.PcdUnknownOffsetList: index += 1 if pcd.PcdCName == ".".join(("gEfiMdeModulePkgTokenSpaceGuid", "PcdNvStoreDefaultValueBuffer")): -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/3] BaseTools: Modify class OrderedListDict
class OrderedListDict(OrderedDict, defaultdict) will encounter multiple bases have instance lay-out conflict error on python3 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index d987bbf441..8d8a3e2789 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -19,15 +19,19 @@ import Common.GlobalData as GlobalData from Workspace.BuildClassObject import StructurePcd from Common.BuildToolError import RESOURCE_NOT_AVAILABLE from Common.BuildToolError import OPTION_MISSING from Common.BuildToolError import BUILD_ERROR -class OrderedListDict(OrderedDict, defaultdict): +class OrderedListDict(OrderedDict): def __init__(self, *args, **kwargs): super(OrderedListDict, self).__init__(*args, **kwargs) self.default_factory = list +def __missing__(self, key): +self[key] = Value = self.default_factory() +return Value + ## Get all packages from platform for specified arch, target and toolchain # # @param Platform: DscBuildData instance # @param BuildDatabase: The database saves all data for all metafiles # @param Arch: Current arch -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 0/3] Optimizing code
Modify class OrderedListDict, remove cmp and use hashlib instead of md5 Yunhua Feng (3): BaseTools: Modify class OrderedListDict BaseTools: remove cmp due to deprecated in python3 BaseTools: Use hashlib instead of md5 BaseTools/Source/Python/AutoGen/AutoGen.py| 6 +++--- BaseTools/Source/Python/BPDG/GenVpd.py| 4 ++-- BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py | 4 ++-- BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py | 4 ++-- BaseTools/Source/Python/UPT/InstallPkg.py | 12 ++-- BaseTools/Source/Python/UPT/MkPkg.py | 4 ++-- BaseTools/Source/Python/UPT/RmPkg.py | 4 ++-- BaseTools/Source/Python/Workspace/MetaFileParser.py | 6 +++--- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 6 +- 9 files changed, 27 insertions(+), 23 deletions(-) -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Check GUID C structure format
GUID C format must conform to {8,4,4,{2,2,2,2,2,2,2,2}} Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/GlobalData.py | 7 +++ BaseTools/Source/Python/Common/Misc.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py index fac7cde708..57048bcae6 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -64,10 +64,17 @@ g4HexChar = re.compile(r'{}{{4}}'.format(_HexChar)) gHexPattern = re.compile(r'0[xX]{}+'.format(_HexChar)) gHexPatternAll = re.compile(r'0[xX]{}+$'.format(_HexChar)) ## Regular expressions for string identifier checking gIdentifierPattern = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) +## Regular expression for GUID c structure format +_GuidCFormatPattern = r"{{\s*0[xX]{Hex}{{1,8}}\s*,\s*0[xX]{Hex}{{1,4}}\s*,\s*0[xX]{Hex}{{1,4}}" \ + r"\s*,\s*{{\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \ + r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \ + r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \ + r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}\s*}}\s*}}".format(Hex=_HexChar) +gGuidCFormatPattern = re.compile(r"{}".format(_GuidCFormatPattern)) # # A global variable for whether current build in AutoGen phase or not. # gAutoGenPhase = False diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 74a5f0bca5..a92d2d69a8 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -358,10 +358,12 @@ def GuidStructureByteArrayToGuidString(GuidValue): # @param GuidValue The GUID value in C structure format # # @retval string The GUID value in ---- format # def GuidStructureStringToGuidString(GuidValue): +if not GlobalData.gGuidCFormatPattern.match(GuidValue): +return '' guidValueString = GuidValue.lower().replace("{", "").replace("}", "").replace(" ", "").replace(";", "") guidValueList = guidValueString.split(",") if len(guidValueList) != 11: return '' #EdkLogger.error(None, None, "Invalid GUID value string %s" % GuidValue) @@ -1325,11 +1327,11 @@ def ParseFieldValue (Value): return Value, 8 if Value.startswith(TAB_GUID) and Value.endswith(')'): Value = Value.split('(', 1)[1][:-1].strip() if Value[0] == '{' and Value[-1] == '}': TmpValue = GuidStructureStringToGuidString(Value) -if len(TmpValue) == 0: +if not TmpValue: raise BadExpression("Invalid GUID value string %s" % Value) Value = TmpValue if Value[0] == '"' and Value[-1] == '"': Value = Value[1:-1] try: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Remove duplicate function declaration
Remove duplicate function declaration Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/DevicePath/UefiDevicePathLib.h | 7 --- 1 file changed, 7 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/UefiDevicePathLib.h b/BaseTools/Source/C/DevicePath/UefiDevicePathLib.h index 7bc974d771..1801eb33e6 100644 --- a/BaseTools/Source/C/DevicePath/UefiDevicePathLib.h +++ b/BaseTools/Source/C/DevicePath/UefiDevicePathLib.h @@ -378,17 +378,10 @@ CreateDeviceNode ( UINT8 NodeType, UINT8 NodeSubType, UINT16 NodeLength ); - EFI_DEVICE_PATH_PROTOCOL * -CreateDeviceNode ( - UINT8 NodeType, - UINT8 NodeSubType, - UINT16 NodeLength - ); - BOOLEAN IsDevicePathMultiInstance ( CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ); -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix report flexible value issue
Report flexible value in INF file encounter error Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/build/BuildReport.py | 5 + 1 file changed, 5 insertions(+) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index 50717b7c86..deb88a7817 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -983,10 +983,15 @@ class PcdReport(object): if ModulePcdSet is not None: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not in ModulePcdSet: continue InfDefaultValue, PcdValue = ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] Pcd.DefaultValue = PcdValue +if InfDefaultValue: +try: +InfDefaultValue = ValueExpressionEx(InfDefaultValue, Pcd.DatumType, self._GuidDict)(True) +except BadExpression as InfDefaultValue: +EdkLogger.error('BuildReport', FORMAT_INVALID, "PCD Value: %s, Type: %s" % (InfDefaultValue, Pcd.DatumType)) if InfDefaultValue == "": InfDefaultValue = None BuildOptionMatch = False if GlobalData.BuildOptionPcd: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools:Fix incorrect %EDK_TOOLS_PATH%
For non-root folder, such as "X:\bp", the EDK_TOOLS_PATH will resolve to "X:\bp\edk2\BaseTools". This is OK. But if WORKSPACE is at a root folder, such as "X:\", the EDK_TOOLS_PATH will look like "X:\\BaseTools". The *double backslash* can fail the command like "del" and thus affect the %ERRORLEVEL% variable, which may break subsequent build processing. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- edksetup.bat | 39 +-- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/edksetup.bat b/edksetup.bat index 97e2330e8c..c32755a471 100755 --- a/edksetup.bat +++ b/edksetup.bat @@ -57,26 +57,37 @@ if /I "%1"=="/h" goto Usage if /I "%1"=="/?" goto Usage if /I "%1"=="/help" goto Usage if /I "%1"=="NewBuild" shift if not defined EDK_TOOLS_PATH ( - if exist %WORKSPACE%\BaseTools ( -set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools - ) else ( -if defined PACKAGES_PATH ( - for %%i IN (%PACKAGES_PATH%) DO ( -if exist %%~fi\BaseTools ( - set EDK_TOOLS_PATH=%%~fi\BaseTools - goto checkNt32Flag -) + goto SetEdkToolsPath +) else ( + goto checkNt32Flag +) + +:SetEdkToolsPath +if %WORKSPACE:~-1% EQU \ ( + @set EDK_BASETOOLS=%WORKSPACE%BaseTools +) else ( + @set EDK_BASETOOLS=%WORKSPACE%\BaseTools +) +if exist %EDK_BASETOOLS% ( + set EDK_TOOLS_PATH=%EDK_BASETOOLS% + set EDK_BASETOOLS= +) else ( + if defined PACKAGES_PATH ( +for %%i IN (%PACKAGES_PATH%) DO ( + if exist %%~fi\BaseTools ( +set EDK_TOOLS_PATH=%%~fi\BaseTools +goto checkNt32Flag ) -) else ( - echo. - echo !!! ERROR !!! Cannot find BaseTools !!! - echo. - goto BadBaseTools ) + ) else ( +echo. +echo !!! ERROR !!! Cannot find BaseTools !!! +echo. +goto BadBaseTools ) ) :checkNt32Flag if exist %EDK_TOOLS_PATH%\Source set BASE_TOOLS_PATH=%EDK_TOOLS_PATH% -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Optimizing code for function doesn't match
Optimizing code for function doesn't match name and comment Fix https://bugzilla.tianocore.org/show_bug.cgi?id=924 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/BuildEngine.py | 30 -- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Python/AutoGen/BuildEngine.py index 8a32343846..4291da9001 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -528,30 +528,28 @@ class BuildRule: ExtraData="Unknown subsection: %s" % self.RuleContent[LineIndex]) ## Parse sub-section # # @param LineIndex The line index of build rule text # -def ParseInputFile(self, LineIndex): +def ParseInputFileSubSection(self, LineIndex): FileList = [File.strip() for File in self.RuleContent[LineIndex].split(",")] for ToolChainFamily in self._FamilyList: -InputFiles = self._RuleInfo[ToolChainFamily, self._State] -if InputFiles is None: -InputFiles = [] -self._RuleInfo[ToolChainFamily, self._State] = InputFiles -InputFiles.extend(FileList) +if self._RuleInfo[ToolChainFamily, self._State] is None: +self._RuleInfo[ToolChainFamily, self._State] = [] +self._RuleInfo[ToolChainFamily, self._State].extend(FileList) ## Parse sub-section +## Parse sub-section +## Parse sub-section # # @param LineIndex The line index of build rule text # -def ParseCommon(self, LineIndex): +def ParseCommonSubSection(self, LineIndex): for ToolChainFamily in self._FamilyList: -Items = self._RuleInfo[ToolChainFamily, self._State] -if Items is None: -Items = [] -self._RuleInfo[ToolChainFamily, self._State] = Items -Items.append(self.RuleContent[LineIndex]) +if self._RuleInfo[ToolChainFamily, self._State] is None: +self._RuleInfo[ToolChainFamily, self._State] = [] +self._RuleInfo[ToolChainFamily, self._State].append(self.RuleContent[LineIndex]) ## Get a build rule via [] operator # # @param FileExt The extension of a file # @param ToolChainFamily The tool chain family name @@ -582,14 +580,14 @@ class BuildRule: _StateHandler = { _SectionHeader : ParseSectionHeader, _Section : ParseSection, _SubSectionHeader : ParseSubSectionHeader, _SubSection: ParseSubSection, -_InputFile : ParseInputFile, -_OutputFile: ParseCommon, -_ExtraDependency : ParseCommon, -_Command : ParseCommon, +_InputFile : ParseInputFileSubSection, +_OutputFile: ParseCommonSubSection, +_ExtraDependency : ParseCommonSubSection, +_Command : ParseCommonSubSection, _UnknownSection: SkipSection, } # This acts like the main() function for the script, unless it is 'import'ed into another # script. -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Debug message make confused
Debug message make confused Fix https://bugzilla.tianocore.org/show_bug.cgi?id=995 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 06ff84b4cd..033ad644c1 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -3238,11 +3238,11 @@ class ModuleAutoGen(AutoGen): ToolChainFamilySet = {"", "*", self.ToolChainFamily, self.BuildRuleFamily} for F in self.Module.Sources: # match tool chain if F.TagName not in ToolChainTagSet: EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, " -"but [%s] is needed" % (F.TagName, str(F), self.ToolChain)) +"but [%s] is currently used" % (F.TagName, str(F), self.ToolChain)) continue # match tool chain family or build rule family if F.ToolChainFamily not in ToolChainFamilySet: EdkLogger.debug( EdkLogger.DEBUG_0, -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Use gGuidPattern for Guid regular expression
Use GlobalData.py gGuidPattern for Guid regular expression Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/GenFds.py | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 156aae1d0e..2307a19cbe 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -42,10 +42,11 @@ from Common.Misc import GuidStructureStringToGuidString from Common.BuildVersion import gBUILD_VERSION from Common.MultipleWorkspace import MultipleWorkspace as mws from . import FfsFileStatement import glob from struct import unpack +from Common.GlobalData import gGuidPattern ## Version and Copyright versionNumber = "1.0" + ' ' + gBUILD_VERSION __version__ = "%prog Version " + versionNumber __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation All rights reserved." @@ -603,15 +604,11 @@ class GenFds : GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref") GuidXRefFile = BytesIO('') GuidDict = {} ModuleList = [] FileGuidList = [] -GuidPattern = re.compile("\s*([0-9a-fA-F]){8}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){12}\s*") +GuidPattern = gGuidPattern for Arch in ArchList: PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] for ModuleFile in PlatformDataBase.Modules: Module = BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] if Module in ModuleList: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix the different token with the same PCD
If the different token with the same PCD names are used in the driver, build can pass. If the different token with the same PCD name are used in the different library, then the driver build will fail. The reason is that the driver autogen.c is not generated correctly for the second case. BaseTools should check the duplicated PCD name is the driver and its linked libraries. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/GenC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 3b396491d0..97ae7bc77a 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -935,11 +935,11 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if Info.IsLibrary: PcdList = Info.LibraryPcdList else: -PcdList = Info.ModulePcdList +PcdList = Info.ModulePcdList + Info.LibraryPcdList PcdExCNameTest = 0 for PcdModule in PcdList: if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName: PcdExCNameTest += 1 # get out early once we found > 1... -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 3/3] BaseTools: fix --genfds-multi-thread generate makefile issue
1. when inf file is binary module, not generate makefile, so need generate ffs with previous method. 2. generate Ui section maybe override and the string is not $(MODULE_NAME) like as: INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf 3. Trim generate incorrect Offset.raw when some vfr not generate .lst file in Debug directory, Trim get the VFR name with the .c files replacement. 4. fix some depex file not generate issue Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/EfiSection.py | 12 ++-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 4 +++- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 6 -- BaseTools/Source/Python/GenFds/GuidSection.py | 2 ++ BaseTools/Source/Python/Trim/Trim.py | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index 5029ec7a18..e6323c7879 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -62,10 +62,11 @@ class EfiSection (EfiSectionClassObject): InfFileName = FfsInf.InfFileName SectionType = FfsInf.__ExtendMacro__(self.SectionType) Filename = FfsInf.__ExtendMacro__(self.FileName) BuildNum = FfsInf.__ExtendMacro__(self.BuildNum) StringData = FfsInf.__ExtendMacro__(self.StringData) +ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)') NoStrip = True if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'): if FfsInf.KeepReloc != None: NoStrip = FfsInf.KeepReloc elif FfsInf.KeepRelocFromRule != None: @@ -89,12 +90,13 @@ class EfiSection (EfiSectionClassObject): if not self.Optional: FileList.append(Filename) elif os.path.exists(Filename): FileList.append(Filename) -elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex: -if IsMakefile: +elif IsMakefile: +SuffixMap = FfsInf.GetFinalTargetSuffixMap() +if '.depex' in SuffixMap: FileList.append(Filename) else: FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile) if IsSect : return FileList, self.Alignment @@ -177,10 +179,12 @@ class EfiSection (EfiSectionClassObject): StringData = FfsInf.Ui InfOverrideUiString = True if InfOverrideUiString: Num = SecNum +if IsMakefile and StringData == ModuleNameStr: +StringData = "$(MODULE_NAME)" OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', Ui=StringData, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) @@ -190,10 +194,12 @@ class EfiSection (EfiSectionClassObject): Num = '%s.%d' %(SecNum , Index) OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType)) f = open(File, 'r') UiString = f.read() f.close() +if IsMakefile and UiString == ModuleNameStr: +UiString = "$(MODULE_NAME)" GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', Ui=UiString, IsMakefile=IsMakefile) OutputFileList.append(OutputFile) else: if StringData != None and len(StringData) > 0: @@ -206,10 +212,12 @@ class EfiSection (EfiSectionClassObject): return '', None else: EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss UI Section value" %InfFileName) Num = SecNum +if IsMakefile and StringData == ModuleNameStr: +StringData = "$(MODULE_NAME)" OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE', Ui=StringData, IsMakefile=IsMakefile)
[edk2] [PATCH 2/3] BaseTools: argument genfds-multi-thread create GenSec command issue
Issue: genfds-multi-thread create makefile before section file generation, so it get alignment is zero from empty file. It is incorrect. solution: GenSec get section alignment from input file when the input alignment is zero. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/GenSec/GenSec.c | 133 +++-- 1 file changed, 126 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index 56767d5a9b..9f592742e1 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -9,10 +9,16 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ +#ifndef __GNUC__ +#include +#include +#include +#include +#endif #include #include #include #include @@ -25,10 +31,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "CommonLib.h" #include "Compress.h" #include "Crc32.h" #include "EfiUtilityMsgs.h" #include "ParseInf.h" +#include "FvLib.h" +#include "PeCoffLib.h" // // GenSec Tool Information // #define UTILITY_NAME"GenSec" @@ -183,12 +191,13 @@ Returns: fprintf (stdout, " -j Number, --buildnumber Number\n\ Number is an integer value between 0 and 65535\n\ used in Ver section.\n"); fprintf (stdout, " --sectionalign SectionAlign\n\ SectionAlign points to section alignment, which support\n\ -the alignment scope 1~16M. It is specified in same\n\ -order that the section file is input.\n"); +the alignment scope 0~16M. If SectionAlign is specified\n\ +as 0, tool get alignment value from SectionFile.It is\n\ +specified in same order that the section file is input.\n"); fprintf (stdout, " --dummy dummyfile\n\ compare dummpyfile with input_file to decide whether\n\ need to set PROCESSING_REQUIRED attribute.\n"); fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n"); fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n"); @@ -983,10 +992,107 @@ Returns: *OutFileBuffer = FileBuffer; return EFI_SUCCESS; } +EFI_STATUS +FfsRebaseImageRead ( +IN VOID*FileHandle, +IN UINTN FileOffset, +IN OUT UINT32 *ReadSize, +OUT VOID*Buffer +) + /*++ + +Routine Description: + +Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file + +Arguments: + + FileHandle - The handle to the PE/COFF file + + FileOffset - The offset, in bytes, into the file to read + + ReadSize - The number of bytes to read from the file starting at FileOffset + + Buffer - A pointer to the buffer to read the data into. + + Returns: + + EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset + + --*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + UINT32 Length; + + Destination8 = Buffer; + Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset); + Length= *ReadSize; + while (Length--) { +*(Destination8++) = *(Source8++); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + /* +InFile is input file for getting alignment +return the alignment +*/ +{ + FILE *InFileHandle; + UINT8 *PeFileBuffer; + UINTN PeFileSize; + UINT32 CurSecHdrSize; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_COMMON_SECTION_HEADER *CommonHeader; + EFI_STATUS Status; + + InFileHandle= NULL; + PeFileBuffer= NULL; + *Alignment = 0; + + memset (, 0, sizeof (ImageContext)); + + InFileHandle = fopen(LongFilePath(InFile), "rb"); + if (InFileHandle == NULL){ +Error (NULL, 0, 0001, "Error opening file", InFile); +return EFI_ABORTED; + } + PeFileSize = _filelength (fileno(InFileHandle)); + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { +fclose (InFileHandle); +Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); +return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); +
[edk2] [PATCH 1/3] BaseTools: Correct GenSec argument dummy free memory issue
Free DummyFileBuffer and set DummyFileBuffer to NULL. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/GenSec/GenSec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index fb5bc5e992..56767d5a9b 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1,9 +1,9 @@ /** @file Creates output file that is a properly formed section per the PI spec. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, 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 which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -1374,10 +1374,11 @@ Returns: if (SectGuidHeaderLength == 0) { SectGuidAttribute |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED; } if (DummyFileBuffer != NULL) { free (DummyFileBuffer); +DummyFileBuffer = NULL; } if (InFileBuffer != NULL) { free (InFileBuffer); } } -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Remove EdkIIWorkspaceBuild.py from source code
Remove EdkIIWorkspaceBuild.py from source code Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- .../Source/Python/Common/EdkIIWorkspaceBuild.py| 1670 BaseTools/Source/Python/Makefile |1 - 2 files changed, 1671 deletions(-) delete mode 100644 BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py deleted file mode 100644 index c0966d5265..00 --- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py +++ /dev/null @@ -1,1670 +0,0 @@ -## @file -# This file is used to define each component of the build database -# -# Copyright (c) 2007 - 2014, 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 -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -## -# Import Modules -# -import Common.LongFilePathOs as os, string, copy, pdb, copy -import EdkLogger -import DataType -from InfClassObject import * -from DecClassObject import * -from DscClassObject import * -from String import * -from BuildToolError import * -from Misc import sdict -import Database as Database -import time as time - -## PcdClassObject -# -# This Class is used for PcdObject -# -# @param object: Inherited from object class -# @param Name: Input value for Name of Pcd, default is None -# @param Guid: Input value for Guid of Pcd, default is None -# @param Type: Input value for Type of Pcd, default is None -# @param DatumType: Input value for DatumType of Pcd, default is None -# @param Value: Input value for Value of Pcd, default is None -# @param Token: Input value for Token of Pcd, default is None -# @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None -# @param SkuInfoList:Input value for SkuInfoList of Pcd, default is {} -# @param IsOverrided:Input value for IsOverrided of Pcd, default is False -# -# @var TokenCName: To store value for TokenCName -# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName -# @var Type: To store value for Type -# @var DatumType:To store value for DatumType -# @var TokenValue: To store value for TokenValue -# @var MaxDatumSize: To store value for MaxDatumSize -# @var SkuInfoList: To store value for SkuInfoList -# @var IsOverrided: To store value for IsOverrided -# @var Phase:To store value for Phase, default is "DXE" -# -class PcdClassObject(object): -def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False): -self.TokenCName = Name -self.TokenSpaceGuidCName = Guid -self.Type = Type -self.DatumType = DatumType -self.DefaultValue = Value -self.TokenValue = Token -self.MaxDatumSize = MaxDatumSize -self.SkuInfoList = SkuInfoList -self.IsOverrided = IsOverrided -self.Phase = "DXE" - -## Convert the class to a string -# -# Convert each member of the class to string -# Organize to a signle line format string -# -# @retval Rtn Formatted String -# -def __str__(self): -Rtn = '\tTokenCName=' + str(self.TokenCName) + ', ' + \ - 'TokenSpaceGuidCName=' + str(self.TokenSpaceGuidCName) + ', ' + \ - 'Type=' + str(self.Type) + ', ' + \ - 'DatumType=' + str(self.DatumType) + ', ' + \ - 'DefaultValue=' + str(self.DefaultValue) + ', ' + \ - 'TokenValue=' + str(self.TokenValue) + ', ' + \ - 'MaxDatumSize=' + str(self.MaxDatumSize) + ', ' -for Item in self.SkuInfoList.values(): -Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName -Rtn = Rtn + str(self.IsOverrided) - -return Rtn - -## Override __eq__ function -# -# Check whether pcds are the same -# -# @retval False The two pcds are different -# @retval True The two pcds are the same -# -def __eq__(self, Other): -return Other is not None and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName - -## Override __hash__ function -# -# Use (TokenCName, TokenSpaceGuidCName) as key in hash table -# -# @retval truple()
[edk2] [PATCH] BaseTools: argument genfds-multi-thread create GenSec command issue
Issue: genfds-multi-thread create makefile before section file generation, so it get alignment is zero from empty file. It is incorrect. solution: GenSec get section alignment from input file when the input alignment is zero. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/GenSec/GenSec.c | 133 +++-- 1 file changed, 126 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index fb5bc5e992..fdffc44f0e 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -9,10 +9,16 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ +#ifndef __GNUC__ +#include +#include +#include +#include +#endif #include #include #include #include @@ -25,10 +31,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "CommonLib.h" #include "Compress.h" #include "Crc32.h" #include "EfiUtilityMsgs.h" #include "ParseInf.h" +#include "FvLib.h" +#include "PeCoffLib.h" // // GenSec Tool Information // #define UTILITY_NAME"GenSec" @@ -183,12 +191,13 @@ Returns: fprintf (stdout, " -j Number, --buildnumber Number\n\ Number is an integer value between 0 and 65535\n\ used in Ver section.\n"); fprintf (stdout, " --sectionalign SectionAlign\n\ SectionAlign points to section alignment, which support\n\ -the alignment scope 1~16M. It is specified in same\n\ -order that the section file is input.\n"); +the alignment scope 0~16M. If SectionAlign is specified\n\ +as 0, tool get alignment value from SectionFile.It is\n\ +specified in same order that the section file is input.\n"); fprintf (stdout, " --dummy dummyfile\n\ compare dummpyfile with input_file to decide whether\n\ need to set PROCESSING_REQUIRED attribute.\n"); fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n"); fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n"); @@ -983,10 +992,107 @@ Returns: *OutFileBuffer = FileBuffer; return EFI_SUCCESS; } +EFI_STATUS +FfsRebaseImageRead ( +IN VOID*FileHandle, +IN UINTN FileOffset, +IN OUT UINT32 *ReadSize, +OUT VOID*Buffer +) + /*++ + +Routine Description: + +Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file + +Arguments: + + FileHandle - The handle to the PE/COFF file + + FileOffset - The offset, in bytes, into the file to read + + ReadSize - The number of bytes to read from the file starting at FileOffset + + Buffer - A pointer to the buffer to read the data into. + + Returns: + + EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset + + --*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + UINT32 Length; + + Destination8 = Buffer; + Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset); + Length= *ReadSize; + while (Length--) { +*(Destination8++) = *(Source8++); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + /* +InFile is input file for getting alignment +return the alignment +*/ +{ + FILE *InFileHandle; + UINT8 *PeFileBuffer; + UINTN PeFileSize; + UINT32 CurSecHdrSize; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_COMMON_SECTION_HEADER *CommonHeader; + EFI_STATUS Status; + + InFileHandle= NULL; + PeFileBuffer= NULL; + *Alignment = 0; + + memset (, 0, sizeof (ImageContext)); + + InFileHandle = fopen(LongFilePath(InFile), "rb"); + if (InFileHandle == NULL){ +Error (NULL, 0, 0001, "Error opening file", InFile); +return EFI_ABORTED; + } + PeFileSize = _filelength (fileno(InFileHandle)); + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { +fclose (InFileHandle); +Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); +return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); +
[edk2] [PATCH] BaseTools: Correct GenSec argument dummy free memory issue
Free DummyFileBuffer and set DummyFileBuffer to NULL. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/GenSec/GenSec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index fb5bc5e992..56767d5a9b 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1,9 +1,9 @@ /** @file Creates output file that is a properly formed section per the PI spec. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, 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 which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -1374,10 +1374,11 @@ Returns: if (SectGuidHeaderLength == 0) { SectGuidAttribute |= EFI_GUIDED_SECTION_PROCESSING_REQUIRED; } if (DummyFileBuffer != NULL) { free (DummyFileBuffer); +DummyFileBuffer = NULL; } if (InFileBuffer != NULL) { free (InFileBuffer); } } -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: --hash --binary-destination generate wrong binary path
Option --hash --binary-destination generate Binaries section in the inf file, but the path of ASL file is begin with Output directory, so need replace Output directory with '', will get the file name RamDisk.aml Incorrect AML file path in inf file on linux: [Binaries.X64] PE32|RamDiskDxe.efi ASL|home/tiano/Desktop/hash/edk2/Build/OvmfX64/RELEASE_GCC5/X64 /MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe/OUTPUT/RamDisk.aml DXE_DEPEX|RamDiskDxe.depex BIN|RamDiskDxeOffset.bin Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 439e360955..95e3e912b1 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4062,11 +4062,11 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']] OutputDir = self.OutputDir.replace('\\', '/').strip('/') DebugDir = self.DebugDir.replace('\\', '/').strip('/') for Item in self.CodaTargetList: -File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').strip('/') +File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/') if File not in self.OutputFile: self.OutputFile.append(File) if os.path.isabs(File): File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/') if Item.Target.Ext.lower() == '.aml': -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix parse OFFSET_OF get wrong offset
Fix parse OFFSET_OF get wrong offset Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 5a0ade9e7e..47fa190eb8 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -888,12 +888,13 @@ class ValueExpressionEx(ValueExpression): ReLabel = re.compile('LABEL\((\w+)\)') ReOffset = re.compile('OFFSET_OF\((\w+)\)') LabelOffset = 0 for Index, Item in enumerate(PcdValueList): # compute byte offset of every LABEL -Item = Item.strip() LabelList = ReLabel.findall(Item) +Item = ReLabel.sub('', Item) +Item = Item.strip() if LabelList: for Label in LabelList: if not IsValidCString(Label): raise BadExpression('%s is not a valid c variable name' % Label) if Label not in LabelDict.keys(): @@ -1001,12 +1002,14 @@ class ValueExpressionEx(ValueExpression): if RealValue: return PcdValue if __name__ == '__main__': -pass -while True: +Value = "{UINT32(OFFSET_OF(Cert0)),UINT32(OFFSET_OF(Cert1)), UINT32(OFFSET_OF(Cert2)), UINT32(OFFSET_OF(Cert3)), UINT32(OFFSET_OF(Cert4)), UINT32(OFFSET_OF(Cert5)), UINT32(OFFSET_OF(Cert6)), UINT32(OFFSET_OF(Cert7)), UINT32(OFFSET_OF(Cert8)), LABEL(Cert0) UINT8(1),LABEL(Cert1) UINT16(2), LABEL(Cert2) UINT32(4), LABEL(Cert3) UINT64(8), LABEL(Cert4) 'ABC', LABEL(Cert5) \"ABC\", LABEL(Cert6) L'ABC', LABEL(Cert7) L\"ABC\", LABEL(Cert8) 0}" +Ret = ValueExpressionEx(Value, "VOID*")(True) +print Ret +while False: input = raw_input('Input expr: ') if input in 'qQ': break try: print ValueExpression(input)(True) -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Dsc/Fdf conditional statement parse issue
Set PCD value with --pcd argument not replace DSC/Fdf PCD value. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/FdfParser.py | 4 BaseTools/Source/Python/Workspace/MetaFileParser.py | 4 2 files changed, 8 insertions(+) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 44a3564c7c..fc2b409847 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -923,10 +923,14 @@ class FdfParser: if ScopeMacro: MacroDict.update(ScopeMacro) MacroDict.update(GlobalData.gGlobalDefines) MacroDict.update(GlobalData.gCommandLineDefines) +if GlobalData.BuildOptionPcd: +for Item in GlobalData.BuildOptionPcd: +PcdName, TmpValue = Item.split("=") +MacroDict[PcdName.strip()] = TmpValue # Highest priority return MacroDict def __EvaluateConditional(self, Expression, Line, Op = None, Value = None): diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 95ea6fb45a..6809003d98 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1241,10 +1241,14 @@ class DscParser(MetaFileParser): Macros.update(GlobalData.gPlatformDefines) Macros.update(GlobalData.gCommandLineDefines) # PCD cannot be referenced in macro definition if self._ItemType not in [MODEL_META_DATA_DEFINE, MODEL_META_DATA_GLOBAL_DEFINE]: Macros.update(self._Symbols) +if GlobalData.BuildOptionPcd: +for Item in GlobalData.BuildOptionPcd: +PcdName, TmpValue = Item.split("=") +Macros[PcdName.strip()] = TmpValue return Macros def _PostProcess(self): Processer = { MODEL_META_DATA_SECTION_HEADER : self.__ProcessSectionHeader, -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Dsc conditional statement parse issue
Set PCD value with --pcd argument not replace DSC PCD value. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 + 1 file changed, 5 insertions(+) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 95ea6fb45a..69a591b8f3 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1601,10 +1601,15 @@ class DscParser(MetaFileParser): if ValList[Index] == 'False': ValList[Index] = '0' if (not self._DirectiveEvalStack) or (False not in self._DirectiveEvalStack): GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue +if GlobalData.BuildOptionPcd: +for Item in GlobalData.BuildOptionPcd: +PcdName, TmpValue = Item.split("=") +if PcdName.strip() == TAB_SPLIT.join(self._ValueList[0:2]): +PcdValue = TmpValue self._Symbols[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue try: self._ValueList[2] = '|'.join(ValList) except Exception: print ValList -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: report error if flag in LABEL() invalid
Flag in LABEL() is not valid C variable name, will report error Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index f1516d5c7b..40e6d32280 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -117,10 +117,16 @@ def SplitPcdValueString(String): raise BadExpression(ERR_STRING_TOKEN % Item) if Item: RetList.append(Item) return RetList +def IsValidCString(Str): +ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') +if not ValidString.match(Str): +return False +return True + ## ReplaceExprMacro # def ReplaceExprMacro(String, Macros, ExceptionList = None): StrList = SplitString(String) for i, String in enumerate(StrList): @@ -883,17 +889,17 @@ class ValueExpressionEx(ValueExpression): ReOffset = re.compile('OFFSET_OF\((\w+)\)') LabelOffset = 0 for Index, Item in enumerate(PcdValueList): # compute byte offset of every LABEL Item = Item.strip() -try: -LabelList = ReLabel.findall(Item) +LabelList = ReLabel.findall(Item) +if LabelList: for Label in LabelList: +if not IsValidCString(Label): +raise BadExpression('%s is invalid c variable string' % Label) if Label not in LabelDict.keys(): LabelDict[Label] = str(LabelOffset) -except: -pass if Item.startswith('UINT8'): LabelOffset = LabelOffset + 1 elif Item.startswith('UINT16'): LabelOffset = LabelOffset + 2 elif Item.startswith('UINT32'): -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: GlobalData.gConfDirectory is None when run GenFds
When run GenFds, GlobalData.gConfDirectory is None, On Linux self._ToolChainFamily default Value is "MSFT", and then generate the wrong PcdValueInit Makefile Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/GenFds.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index dcba9f24cb..1c601d94b4 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -1,9 +1,9 @@ ## @file # generate flash image # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2007 - 2018, 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 # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php @@ -162,10 +162,12 @@ def main(): ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath +if not GlobalData.gConfDirectory: +GlobalData.gConfDirectory = GenFdsGlobalVariable.ConfDir BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: TargetTxt = TargetTxtClassObject.TargetTxtClassObject() TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) # if no build target given in command line, get it from target.txt -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix eval parse string issue
eval argument start with " or ', but it is unicode string, will encounter error: List = list(eval(Value)) # translate escape character File "", line 1 'jà=îµ¢Ã"Fà^ SyntaxError: EOL while scanning string literal Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Misc.py | 30 ++ 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index a7e7797d04..af374d804d 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1552,37 +1552,59 @@ def ParseFieldValue (Value): raise BadExpression('%s' % Message) Value, Size = ParseFieldValue(Value) return Value, 16 if Value.startswith('L"') and Value.endswith('"'): # Unicode String -List = list(eval(Value[1:])) # translate escape character +# translate escape character +Value = Value[1:] +try: +Value = eval(Value) +except: +Value = Value[1:-1] +List = list(Value) List.reverse() Value = 0 for Char in List: Value = (Value << 16) | ord(Char) return Value, (len(List) + 1) * 2 if Value.startswith('"') and Value.endswith('"'): # ASCII String -List = list(eval(Value)) # translate escape character +# translate escape character +try: +Value = eval(Value) +except: +Value = Value[1:-1] +List = list(Value) List.reverse() Value = 0 for Char in List: Value = (Value << 8) | ord(Char) return Value, len(List) + 1 if Value.startswith("L'") and Value.endswith("'"): # Unicode Character Constant -List = list(eval(Value[1:])) # translate escape character +# translate escape character +Value = Value[1:] +try: +Value = eval(Value) +except: +Value = Value[1:-1] +List = list(Value) if len(List) == 0: raise BadExpression('Length %s is %s' % (Value, len(List))) List.reverse() Value = 0 for Char in List: Value = (Value << 16) | ord(Char) return Value, len(List) * 2 if Value.startswith("'") and Value.endswith("'"): # Character constant -List = list(eval(Value)) # translate escape character +# translate escape character +try: +Value = eval(Value) +except: +Value = Value[1:-1] +List = list(Value) if len(List) == 0: raise BadExpression('Length %s is %s' % (Value, len(List))) List.reverse() Value = 0 for Char in List: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH V2]BaseTools: Fix flexible PCD single quote and double quote bugs
V2: 1. Fix parse DSC file split PCD Value {'9','a','#'} build error 2. Fix parse --pcd gUefiOvmfPkgTokenSpaceGuid.test10="\'A\'" build error, If PCD type is UINT8 or UINT16 or UINT32 or UINT64 V1: 1. Argument --pcd format as below: Some examples that to match --pcd format and DSC format --pcd DSC format L"ABC"L"ABC" "AB\\\"C" "AB\"C" "AB\tC" "AB\tC" "AB\\\'C" "AB\'C" "\'ABC\'" 'ABC’ L"\'AB\\\"C\'"L'AB\"C' "\'AB\\\'C\'" 'AB\'C' "\'AB\tC\'" 'AB\tC' H"{0, L\"AB\\\"B\", \'ab\\\"c\'}" {0, L"AB\"B", 'ab\"c'} H"{0, L\"AB\\\"B\",\'ab\\\'c\'}" {0, L"AB\"B", 'ab\'c'} 2. {'#', '|'} split string incorrectly. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/GenMake.py| 20 +--- BaseTools/Source/Python/Common/Expression.py | 60 --- BaseTools/Source/Python/Common/Misc.py| 31 +++- BaseTools/Source/Python/Common/String.py | 46 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++- 5 files changed, 123 insertions(+), 65 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index afe6f2f99c..4b924d21e0 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1553,17 +1553,23 @@ class TopLevelMakefile(BuildFile): if GlobalData.BuildOptionPcd: for index, option in enumerate(GlobalData.gCommand): if "--pcd" == option and GlobalData.gCommand[index+1]: pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -if pcdValue.startswith('H'): -pcdValue = 'H' + '"' + pcdValue[1:] + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith("L'"): -ExtraOption += "--pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith('L'): -pcdValue = 'L' + '"' + pcdValue[1:] + '"' +for Item in GlobalData.BuildOptionPcd: +if '.'.join(Item[0:2]) == pcdName: +pcdValue = Item[2] +if pcdValue.startswith('L') or pcdValue.startswith('"'): +pcdValue, Size = ParseFieldValue(pcdValue) +NewVal = '{' +for S in range(Size): +NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) +NewVal += ',' +pcdValue = NewVal[:-1] + '}' +break +if pcdValue.startswith('{'): +pcdValue = 'H' + '"' + pcdValue + '"' ExtraOption += " --pcd " + pcdName + '=' + pcdValue else: ExtraOption += " --pcd " + GlobalData.gCommand[index+1] MakefileName = self._FILE_NAME_[self._FileType] diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index edb0a60de6..f1516d5c7b 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -43,28 +43,41 @@ ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARC ## SplitString # Split string to list according double quote # For example: abc"de\"f"ghi"jkl"mn will be: ['abc', '"de\"f"', 'ghi', '"jkl"', 'mn'] # def SplitString(String): -# There might be escaped quote: "abc\"def\\\"ghi" -Str = String.replace('', '//').replace('\\\"', '\\\'') +# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi' +Str = String RetList = [] -InQuote = False +InSingleQuote = False +InDoubleQuote = False Item = '' for i, ch in enumerate(Str): -if ch == '"': -InQuote = not InQuote -if not InQuote: +if ch == '"' and not InSingleQuote: +if Str[i - 1] != '\\': +InDoubleQuote = not InDoubleQuote +if not InDoubleQuote: +Item += String[i] +RetList.append(Item) +Item = '' +continue +if Item: +RetList.append(Item) +Item = '' +elif ch == "'" and not InDoubleQuote: +if Str[i - 1] != '\\': +InSingleQuote = not InSingleQuote +if not
[edk2] [PATCH] BaseTools: Fix report not used --pcd value incorrectly
Argument --pcd gUefiOvmfPkgTokenSpaceGuid.test10=H"{1}", If the PCD is not used, report value {0x01, 0x00}, is incorrect. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/build/BuildReport.py | 1 + 1 file changed, 1 insertion(+) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index 21144991bf..58595d62b3 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -976,10 +976,11 @@ class PcdReport(object): BuildOptionMatch = False if GlobalData.BuildOptionPcd: for pcd in GlobalData.BuildOptionPcd: if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) == (pcd[0], pcd[1]): PcdValue = pcd[2] +Pcd.DefaultValue = PcdValue BuildOptionMatch = True break if First: if ModulePcdSet == None: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix flexible PCD single quote and double quote bugs
1. Argument --pcd format as below: Some examples that to match --pcd format and DSC format --pcd DSC format L"ABC"L"ABC" "AB\\\"C" "AB\"C" "AB\tC" "AB\tC" "AB\\\'C" "AB\'C" "\'ABC\'" 'ABC’ L"\'AB\\\"C\'"L'AB\"C' "\'AB\\\'C\'" 'AB\'C' "\'AB\tC\'" 'AB\tC' H"{0, L\"AB\\\"B\", \'ab\\\"c\'}" {0, L"AB\"B", 'ab\"c'} H"{0, L\"AB\\\"B\",\'ab\\\'c\'}" {0, L"AB\"B", 'ab\'c'} 2. {'#', '|'} split string incorrectly. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/GenMake.py| 20 +--- BaseTools/Source/Python/Common/Expression.py | 60 --- BaseTools/Source/Python/Common/Misc.py| 31 +++- BaseTools/Source/Python/Common/String.py | 33 - BaseTools/Source/Python/Workspace/DscBuildData.py | 37 +++--- 5 files changed, 115 insertions(+), 66 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index afe6f2f99c..4b924d21e0 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1553,17 +1553,23 @@ class TopLevelMakefile(BuildFile): if GlobalData.BuildOptionPcd: for index, option in enumerate(GlobalData.gCommand): if "--pcd" == option and GlobalData.gCommand[index+1]: pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') -if pcdValue.startswith('H'): -pcdValue = 'H' + '"' + pcdValue[1:] + '"' -ExtraOption += " --pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith("L'"): -ExtraOption += "--pcd " + pcdName + '=' + pcdValue -elif pcdValue.startswith('L'): -pcdValue = 'L' + '"' + pcdValue[1:] + '"' +for Item in GlobalData.BuildOptionPcd: +if '.'.join(Item[0:2]) == pcdName: +pcdValue = Item[2] +if pcdValue.startswith('L') or pcdValue.startswith('"'): +pcdValue, Size = ParseFieldValue(pcdValue) +NewVal = '{' +for S in range(Size): +NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) +NewVal += ',' +pcdValue = NewVal[:-1] + '}' +break +if pcdValue.startswith('{'): +pcdValue = 'H' + '"' + pcdValue + '"' ExtraOption += " --pcd " + pcdName + '=' + pcdValue else: ExtraOption += " --pcd " + GlobalData.gCommand[index+1] MakefileName = self._FILE_NAME_[self._FileType] diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index edb0a60de6..f1516d5c7b 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -43,28 +43,41 @@ ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARC ## SplitString # Split string to list according double quote # For example: abc"de\"f"ghi"jkl"mn will be: ['abc', '"de\"f"', 'ghi', '"jkl"', 'mn'] # def SplitString(String): -# There might be escaped quote: "abc\"def\\\"ghi" -Str = String.replace('', '//').replace('\\\"', '\\\'') +# There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi' +Str = String RetList = [] -InQuote = False +InSingleQuote = False +InDoubleQuote = False Item = '' for i, ch in enumerate(Str): -if ch == '"': -InQuote = not InQuote -if not InQuote: +if ch == '"' and not InSingleQuote: +if Str[i - 1] != '\\': +InDoubleQuote = not InDoubleQuote +if not InDoubleQuote: +Item += String[i] +RetList.append(Item) +Item = '' +continue +if Item: +RetList.append(Item) +Item = '' +elif ch == "'" and not InDoubleQuote: +if Str[i - 1] != '\\': +InSingleQuote = not InSingleQuote +if not InSingleQuote: Item += String[i] RetList.append(Item) Item = '' continue if Item: RetList.append(Item)
[edk2] [PATCH] BaseTools: Update ValueExpressionEx for flexible PCD
1. Byte array number should less than 0xFF. 2. Add SplitPcdValueString for PCD split Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 205 +-- 1 file changed, 130 insertions(+), 75 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 28320d78a9..edb0a60de6 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -66,10 +66,48 @@ def SplitString(String): raise BadExpression(ERR_STRING_TOKEN % Item) if Item: RetList.append(Item) return RetList +def SplitPcdValueString(String): +# There might be escaped comma in GUID() or DEVICE_PATH() or " " +# or ' ' or L' ' or L" " +Str = String +RetList = [] +InParenthesis = 0 +InSingleQuote = False +InDoubleQuote = False +Item = '' +for i, ch in enumerate(Str): +if ch == '(': +InParenthesis += 1 +if ch == ')': +if InParenthesis: +InParenthesis -= 1 +else: +raise BadExpression(ERR_STRING_TOKEN % Item) +if ch == '"' and not InSingleQuote: +if String[i-1] != '\\': +InDoubleQuote = not InDoubleQuote +if ch == "'" and not InDoubleQuote: +if String[i-1] != '\\': +InSingleQuote = not InSingleQuote +if ch == ',': +if InParenthesis or InSingleQuote or InDoubleQuote: +Item += String[i] +continue +elif Item: +RetList.append(Item) +Item = '' +continue +Item += String[i] +if InSingleQuote or InDoubleQuote or InParenthesis: +raise BadExpression(ERR_STRING_TOKEN % Item) +if Item: +RetList.append(Item) +return RetList + ## ReplaceExprMacro # def ReplaceExprMacro(String, Macros, ExceptionList = None): StrList = SplitString(String) for i, String in enumerate(StrList): @@ -731,28 +769,46 @@ class ValueExpressionEx(ValueExpression): PcdValue = Value.result except BadExpression, Value: if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: PcdValue = PcdValue.strip() if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): -PcdValue = PcdValue[1:-1].split(',') +PcdValue = SplitPcdValueString(PcdValue[1:-1]) if type(PcdValue) == type([]): TmpValue = 0 Size = 0 +ValueType = '' for Item in PcdValue: +Item = Item.strip() if Item.startswith('UINT8'): ItemSize = 1 -if Item.startswith('UINT16'): +ValueType = 'UINT8' +elif Item.startswith('UINT16'): ItemSize = 2 +ValueType = 'UINT16' elif Item.startswith('UINT32'): ItemSize = 4 +ValueType = 'UINT32' elif Item.startswith('UINT64'): ItemSize = 8 +ValueType = 'UINT64' +elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'): +ItemSize = 0 +ValueType = 'VOID*' else: ItemSize = 0 -Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) +ValueType = 'UINT8' +Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) if ItemSize == 0: +try: +tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0) +if tmpValue > 255: +raise BadExpression("Byte array number %s should less than 0xFF." % Item) +except BadExpression, Value: +raise BadExpression(Value) +except ValueError: +pass ItemValue, ItemSize = ParseFieldValue(Item) else: ItemValue = ParseFieldValue(Item)[0] if type(ItemValue) == type(''): @@ -792,88 +848,85 @@ class ValueExpressionEx(ValueExpression): for I in
[edk2] [PATCH] BaseTools: Fix parse flexible PCD value bugs
1. UINT64 Value {"A", "B"}, the expect value 0x420041. 2. Byte array number should less than 0xFF. {256, 0xff} will report error because of 256 larger than 0xFF 3. comma in GUID() and DEVICE_PATH() split issue Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 157 +-- 1 file changed, 101 insertions(+), 56 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 74d1b08f76..ed86b21e54 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -66,10 +66,37 @@ def SplitString(String): raise BadExpression(ERR_STRING_TOKEN % Item) if Item: RetList.append(Item) return RetList +def SplitPcdValueString(String): +# There might be escaped comma in GUID() or DEVICE_PATH() +Str = String +RetList = [] +InParenthesis = 0 +Item = '' +for i, ch in enumerate(Str): +if ch == '(': +InParenthesis += 1 +if ch == ')': +if InParenthesis: +InParenthesis -= 1 +else: +raise BadExpression(ERR_STRING_TOKEN % Item) +if ch == ',': +if InParenthesis: +Item += String[i] +continue +elif Item: +RetList.append(Item) +Item = '' +continue +Item += String[i] +if Item: +RetList.append(Item) +return RetList + ## ReplaceExprMacro # def ReplaceExprMacro(String, Macros, ExceptionList = None): StrList = SplitString(String) for i, String in enumerate(StrList): @@ -731,32 +758,50 @@ class ValueExpressionEx(ValueExpression): PcdValue = Value.result except BadExpression, Value: if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: PcdValue = PcdValue.strip() if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): -PcdValue = PcdValue[1:-1].split(',') +PcdValue = SplitPcdValueString(PcdValue[1:-1]) if type(PcdValue) == type([]): TmpValue = 0 Size = 0 +ValueType = '' for Item in PcdValue: +Item = Item.strip() if Item.startswith('UINT8'): ItemSize = 1 -if Item.startswith('UINT16'): +ValueType = 'UINT8' +elif Item.startswith('UINT16'): ItemSize = 2 +ValueType = 'UINT16' elif Item.startswith('UINT32'): ItemSize = 4 +ValueType = 'UINT32' elif Item.startswith('UINT64'): ItemSize = 8 +ValueType = 'UINT64' +elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'): +ItemSize = 0 +ValueType = 'VOID*' else: ItemSize = 0 -Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True) +ValueType = 'UINT8' + +Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) if ItemSize == 0: +try: +tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0) +if tmpValue > 255: +raise BadExpression("Byte array number %s should less than 0xFF." % Item) +except ValueError: +pass +except BadExpression, Value: +raise BadExpression(Value) ItemValue, ItemSize = ParseFieldValue(Item) else: ItemValue = ParseFieldValue(Item)[0] - if type(ItemValue) == type(''): ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue) TmpValue = (ItemValue << (Size * 8)) | TmpValue Size = Size + ItemSize @@ -792,64 +837,62 @@ class ValueExpressionEx(ValueExpression): for I in range((TmpValue.bit_length() + 7) / 8): TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))
[edk2] [PATCH] BaseTool: correct the generate compress section process
First generate a dummy file with section alignment, then compress the dummy file to generate the compress file Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/CompressSection.py | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py index 98532ed8e6..56e71a3545 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -58,10 +58,11 @@ class CompressSection (CompressSectionClassObject) : if FfsInf != None: self.CompType = FfsInf.__ExtendMacro__(self.CompType) self.Alignment = FfsInf.__ExtendMacro__(self.Alignment) SectFiles = tuple() +SectAlign = [] Index = 0 MaxAlign = None for Sect in self.SectionList: Index = Index + 1 SecIndex = '%s.%d' %(SecNum, Index) @@ -74,27 +75,23 @@ class CompressSection (CompressSectionClassObject) : if ReturnSectList != []: if AlignValue == None: AlignValue = "1" for FileData in ReturnSectList: SectFiles += (FileData,) - -if MaxAlign != None: -if self.Alignment == None: -self.Alignment = MaxAlign -else: -if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment): -self.Alignment = MaxAlign +SectAlign.append(AlignValue) OutputFile = OutputPath + \ os.sep + \ ModuleName + \ 'SEC' + \ SecNum + \ Ffs.SectionSuffix['COMPRESS'] OutputFile = os.path.normpath(OutputFile) +DummyFile = OutputFile + '.dummy' +GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile) -GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'], +GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'], CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile) OutputFileList = [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix COMPRESS alignment incorrect issue
Doesn't generate the correct alignment for the leaf section in the compression section. Below FFS rule doesn't work as the expectation. [Rule.Common.PEIM.PE32] FILE PEIM = $(NAMED_GUID) { PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex COMPRESS { PE32 PE32 Align=Auto$(INF_OUTPUT)/$(MODULE_NAME).efi UI STRING="$(MODULE_NAME)" Optional VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) } } Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/CompressSection.py | 14 ++ 1 file changed, 14 insertions(+) diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py index 64ad275d83..98532ed8e6 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -59,18 +59,32 @@ class CompressSection (CompressSectionClassObject) : self.CompType = FfsInf.__ExtendMacro__(self.CompType) self.Alignment = FfsInf.__ExtendMacro__(self.Alignment) SectFiles = tuple() Index = 0 +MaxAlign = None for Sect in self.SectionList: Index = Index + 1 SecIndex = '%s.%d' %(SecNum, Index) ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile) +if AlignValue != None: +if MaxAlign == None: +MaxAlign = AlignValue +if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign): +MaxAlign = AlignValue if ReturnSectList != []: +if AlignValue == None: +AlignValue = "1" for FileData in ReturnSectList: SectFiles += (FileData,) +if MaxAlign != None: +if self.Alignment == None: +self.Alignment = MaxAlign +else: +if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment): +self.Alignment = MaxAlign OutputFile = OutputPath + \ os.sep + \ ModuleName + \ 'SEC' + \ -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix flexible PCD DEVICE_PATH parse issue
When the format of DEVICE_PATH have string, like as: {DEVICE_PATH("BBS(1,"AB",0)")} have string "AB", will get the wrong value. Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b34cb4c3be..08523e4669 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1597,11 +1597,12 @@ def ParseFieldValue (Value): RetSize += Size for I in range(Size): Value = (Value << 8) | ((ItemValue >> 8 * I) & 0xff) return Value, RetSize if Value.startswith('DEVICE_PATH(') and Value.endswith(')'): -Value = Value.split('"')[1] +Value = Value.replace("DEVICE_PATH(", '').rstrip(')') +Value = Value.strip().strip('"') return ParseDevPathValue(Value) if Value.lower().startswith('0x'): Value = int(Value, 16) if Value == 0: return 0, 1 -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Report error GUID format if incorrectly
Flexible GUID format support like these: 1. { GUID("11E13869-1896-4A07-8B21-D8B23DD2A2B4") } 2. { GUID({ 0x11e13869, 0x1896, 0x4a07,{ 0x8b, 0x21, 0xd8, 0xb2, 0x3d, 0xd2, 0xa2, 0xb4 } }) } 3. { GUID(gEfiBlockIoProtocolGuid) } Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Misc.py | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b8c2ce1ddc..5a0bcd9bf7 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1535,16 +1535,10 @@ def ParseFieldValue (Value): if Value.startswith('GUID') and Value.endswith(')'): Value = Value.split('(', 1)[1][:-1].strip() if Value[0] == '{' and Value[-1] == '}': -Value = Value[1:-1].strip() -Value = Value.split('{', 1) -Value = ['%02x' % int(Item, 16) for Item in (Value[0] + Value[1][:-1]).split(',')] -if len(Value[0]) != 8: -Value[0] = '%08X' % int(Value[0], 16) -if len(Value[1]) != 4: -Value[1] = '%04X' % int(Value[1], 16) -if len(Value[2]) != 4: -Value[2] = '%04X' % int(Value[2], 16) -Value = '-'.join(Value[0:3]) + '-' + ''.join(Value[3:5]) + '-' + ''.join(Value[5:11]) +TmpValue = GuidStructureStringToGuidString(Value) +if len(TmpValue) == 0: +raise BadExpression("Invalid GUID value string %s" % Value) +Value = TmpValue if Value[0] == '"' and Value[-1] == '"': Value = Value[1:-1] try: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix build argument --pcd for flexible format bugs
Build argument --pcd flexible format, like as: 1. VOID* type gTokenSpaceGuid.Test=H"{flexible format}" gTokenSpaceGuid.Test=L"string" gTokenSpaceGuid.Test="string" gTokenSpaceGuid.Test=L'string' gTokenSpaceGuid.Test='string' 2. UINT8/UINT16/UINT32/UINT64 type gTokenSpaceGuid.Test=H"{flexible format}" gTokenSpaceGuid.Test=L"string" gTokenSpaceGuid.Test="string" gTokenSpaceGuid.Test=L'string' gTokenSpaceGuid.Test='string' In linux, single quotes need escape gTokenSpaceGuid.Test=L\'string\' gTokenSpaceGuid.Test=\'string\' Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/GenMake.py| 2 + BaseTools/Source/Python/Common/Misc.py| 4 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 73 +-- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 7d3374a493..9df5d8e2d7 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1554,6 +1554,8 @@ class TopLevelMakefile(BuildFile): if pcdValue.startswith('H'): pcdValue = 'H' + '"' + pcdValue[1:] + '"' ExtraOption += " --pcd " + pcdName + '=' + pcdValue +elif pcdValue.startswith("L'"): +ExtraOption += "--pcd " + pcdName + '=' + pcdValue elif pcdValue.startswith('L'): pcdValue = 'L' + '"' + pcdValue[1:] + '"' ExtraOption += " --pcd " + pcdName + '=' + pcdValue diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index d80f645d2e..b8c2ce1ddc 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2353,10 +2353,10 @@ def PackRegistryFormatGuid(Guid): def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']: -if Value.startswith('L'): +if Value.startswith('L') or Value.startswith('"'): if not Value[1]: EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"') -Value = Value[0] + '"' + Value[1:] + '"' +Value = Value elif Value.startswith('H'): if not Value[1]: EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"') diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 1da4f03ab8..d9165f2ac7 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -999,10 +999,39 @@ class DscBuildData(PlatformBuildClassObject): try: pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) except BadExpression, Value: -if Value.result > 1: -EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) -pcdvalue = 'H' + pcdvalue +EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % +(TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) +if PcdDatumType == "VOID*": +pcdvalue = 'H' + pcdvalue +elif pcdvalue.startswith("L'"): +try: +pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True) +except BadExpression, Value: +EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % +(TokenSpaceGuidCName, TokenCName, pcdvalue, Value)) +if pcdvalue.startswith('{'): +pcdvalue = 'H' + pcdvalue +elif pcdvalue.startswith("'"): +try: +pcdvalue =
Re: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
sorry L'' and '' is single quote and not include any character, so we will report error message Any question, please let me know. Thanks. Best Regards Feng, Yunhua -Original Message- From: Yao, Jiewen Sent: Friday, February 2, 2018 9:45 PM To: Feng, YunhuaX <yunhuax.f...@intel.com>; edk2-devel@lists.01.org Cc: Gao, Liming <liming@intel.com> Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Good. I am just confused on the commit message --- when the value is L'' or '', will report error. Would you please clarify what does that mean? Thank you Yao Jiewen > -Original Message----- > From: Feng, YunhuaX > Sent: Friday, February 2, 2018 9:42 PM > To: Yao, Jiewen <jiewen@intel.com>; edk2-devel@lists.01.org > Cc: Gao, Liming <liming@intel.com> > Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support > L'a' and 'a' > > Yes, you are right. > > L"String" and "String" still support, and we add L'String' and 'String' > L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00} > L'ab' ==> {0x61, 0x00, 0x62, 0x00} > > Any question, please let me know. Thanks. > > Best Regards > Feng, Yunhua > > -Original Message- > From: Yao, Jiewen > Sent: Friday, February 2, 2018 8:17 PM > To: Feng, YunhuaX <yunhuax.f...@intel.com>; edk2-devel@lists.01.org > Cc: Gao, Liming <liming@intel.com>; Yao, Jiewen > <jiewen@intel.com> > Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support > L'a' and 'a' > > Hello > May I know why we do not support L"String" ? > > My understanding is that L'String' is a string without NULL > terminator, L"String" is a string with NULL terminator, right? > > Thank you > Yao Jiewen > > > -Original Message- > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf > > Of Feng, YunhuaX > > Sent: Friday, February 2, 2018 5:02 PM > > To: edk2-devel@lists.01.org > > Cc: Gao, Liming <liming@intel.com> > > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* > > support > L'a' > > and 'a' > > > > Type VOID* support L'a' and 'a', the value transfer to c style value. > > L'a' --> {0x61, 0x00} > > L'ab' --> {0x61, 0x00, 0x62, 0x00} > > 'a' --> {0x61} > > 'ab' --> {0x61, 0x62} > > > > when the value is L'' or '', will report error > > > > Cc: Liming Gao <liming@intel.com> > > Cc: Yonghong Zhu <yonghong@intel.com> > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Yunhua Feng <yunhuax.f...@intel.com> > > --- > > BaseTools/Source/Python/Common/Expression.py | 19 > --- > > BaseTools/Source/Python/Common/Misc.py | 4 > > 2 files changed, 20 insertions(+), 3 deletions(-) > > > > diff --git a/BaseTools/Source/Python/Common/Expression.py > > b/BaseTools/Source/Python/Common/Expression.py > > index b8c48460ff..6a1103df2c 100644 > > --- a/BaseTools/Source/Python/Common/Expression.py > > +++ b/BaseTools/Source/Python/Common/Expression.py > > @@ -740,7 +740,12 @@ class ValueExpressionEx(ValueExpression): > > try: > > PcdValue = ValueExpression.__call__(self, RealValue, Depth) > > if self.PcdType == 'VOID*' and > > (PcdValue.startswith("'") or > > PcdValue.startswith("L'")): > > -raise BadExpression > > +PcdValue, Size = ParseFieldValue(PcdValue) > > +PcdValueList = [] > > +for I in range(Size): > > +PcdValueList.append('0x%02X'%(PcdValue & 0xff)) > > +PcdValue = PcdValue >> 8 > > +PcdValue = '{' + ','.join(PcdValueList) + '}' > > elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', > > 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ > >PcdValue.startswith('"') or > > PcdValue.startswith("L'") or PcdValue.startswith('L"') or > PcdValue.startswith('{')): > > raise BadExpression @@ -755,6 +760,8 @@ class > > ValueExpressionEx(ValueExpression): > > TmpValue = 0 > > Size = 0 > > for Item in PcdValue: > > +if Item.startswith('UINT8'): > > +ItemSize = 1 > > if Item.startswith('UINT16'): > >
Re: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
Yes, you are right. L"String" and "String" still support, and we add L'String' and 'String' L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00} L'ab' ==> {0x61, 0x00, 0x62, 0x00} Any question, please let me know. Thanks. Best Regards Feng, Yunhua -Original Message- From: Yao, Jiewen Sent: Friday, February 2, 2018 8:17 PM To: Feng, YunhuaX <yunhuax.f...@intel.com>; edk2-devel@lists.01.org Cc: Gao, Liming <liming@intel.com>; Yao, Jiewen <jiewen@intel.com> Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Hello May I know why we do not support L"String" ? My understanding is that L'String' is a string without NULL terminator, L"String" is a string with NULL terminator, right? Thank you Yao Jiewen > -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Feng, YunhuaX > Sent: Friday, February 2, 2018 5:02 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming <liming@intel.com> > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* support L'a' > and 'a' > > Type VOID* support L'a' and 'a', the value transfer to c style value. > L'a' --> {0x61, 0x00} > L'ab' --> {0x61, 0x00, 0x62, 0x00} > 'a' --> {0x61} > 'ab' --> {0x61, 0x62} > > when the value is L'' or '', will report error > > Cc: Liming Gao <liming@intel.com> > Cc: Yonghong Zhu <yonghong@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yunhua Feng <yunhuax.f...@intel.com> > --- > BaseTools/Source/Python/Common/Expression.py | 19 --- > BaseTools/Source/Python/Common/Misc.py | 4 > 2 files changed, 20 insertions(+), 3 deletions(-) > > diff --git a/BaseTools/Source/Python/Common/Expression.py > b/BaseTools/Source/Python/Common/Expression.py > index b8c48460ff..6a1103df2c 100644 > --- a/BaseTools/Source/Python/Common/Expression.py > +++ b/BaseTools/Source/Python/Common/Expression.py > @@ -740,7 +740,12 @@ class ValueExpressionEx(ValueExpression): > try: > PcdValue = ValueExpression.__call__(self, RealValue, Depth) > if self.PcdType == 'VOID*' and (PcdValue.startswith("'") > or > PcdValue.startswith("L'")): > -raise BadExpression > +PcdValue, Size = ParseFieldValue(PcdValue) > +PcdValueList = [] > +for I in range(Size): > +PcdValueList.append('0x%02X'%(PcdValue & 0xff)) > +PcdValue = PcdValue >> 8 > +PcdValue = '{' + ','.join(PcdValueList) + '}' > elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', > 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ >PcdValue.startswith('"') or > PcdValue.startswith("L'") or PcdValue.startswith('L"') or > PcdValue.startswith('{')): > raise BadExpression > @@ -755,6 +760,8 @@ class ValueExpressionEx(ValueExpression): > TmpValue = 0 > Size = 0 > for Item in PcdValue: > +if Item.startswith('UINT8'): > +ItemSize = 1 > if Item.startswith('UINT16'): > ItemSize = 2 > elif Item.startswith('UINT32'): > @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression): > TmpValue = (ItemValue << (Size * 8)) | TmpValue > Size = Size + ItemSize > else: > -TmpValue, Size = ParseFieldValue(PcdValue) > +try: > +TmpValue, Size = ParseFieldValue(PcdValue) > +except BadExpression: > +raise BadExpression("Type: %s, Value: %s, > + format > or value error" % (self.PcdType, PcdValue)) > if type(TmpValue) == type(''): > TmpValue = int(TmpValue) > else: > @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression): > else: > raise BadExpression('%s not > defined before use' % Offset) > ValueType = "" > -if Item.startswith('UINT16'): > +if Item.startswith('UINT8'): > ItemSize = 1 > ValueType = "UINT8" >
[edk2] [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
Type VOID* support L'a' and 'a', the value transfer to c style value. L'a' --> {0x61, 0x00} L'ab' --> {0x61, 0x00, 0x62, 0x00} 'a' --> {0x61} 'ab' --> {0x61, 0x62} when the value is L'' or '', will report error Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/Expression.py | 19 --- BaseTools/Source/Python/Common/Misc.py | 4 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index b8c48460ff..6a1103df2c 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -740,7 +740,12 @@ class ValueExpressionEx(ValueExpression): try: PcdValue = ValueExpression.__call__(self, RealValue, Depth) if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or PcdValue.startswith("L'")): -raise BadExpression +PcdValue, Size = ParseFieldValue(PcdValue) +PcdValueList = [] +for I in range(Size): +PcdValueList.append('0x%02X'%(PcdValue & 0xff)) +PcdValue = PcdValue >> 8 +PcdValue = '{' + ','.join(PcdValueList) + '}' elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): raise BadExpression @@ -755,6 +760,8 @@ class ValueExpressionEx(ValueExpression): TmpValue = 0 Size = 0 for Item in PcdValue: +if Item.startswith('UINT8'): +ItemSize = 1 if Item.startswith('UINT16'): ItemSize = 2 elif Item.startswith('UINT32'): @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression): TmpValue = (ItemValue << (Size * 8)) | TmpValue Size = Size + ItemSize else: -TmpValue, Size = ParseFieldValue(PcdValue) +try: +TmpValue, Size = ParseFieldValue(PcdValue) +except BadExpression: +raise BadExpression("Type: %s, Value: %s, format or value error" % (self.PcdType, PcdValue)) if type(TmpValue) == type(''): TmpValue = int(TmpValue) else: @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression): else: raise BadExpression('%s not defined before use' % Offset) ValueType = "" -if Item.startswith('UINT16'): +if Item.startswith('UINT8'): ItemSize = 1 ValueType = "UINT8" elif Item.startswith('UINT16'): @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression): if Size > 0: PcdValue = '{' + ValueStr[:-2] + '}' +else: +raise BadExpression("Type: %s, Value: %s, format or value error"%(self.PcdType, PcdValue)) + if PcdValue == 'True': PcdValue = '1' if PcdValue == 'False': diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b34cb4c3be..d80f645d2e 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1572,6 +1572,8 @@ def ParseFieldValue (Value): if Value.startswith("L'") and Value.endswith("'"): # Unicode Character Constant List = list(Value[2:-1]) +if len(List) == 0: +raise BadExpression('Length %s is %s' % (Value, len(List))) List.reverse() Value = 0 for Char in List: @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value): if Value.startswith("'") and Value.endswith("'"): # Character constant List = list(Value[1:-1]) +if len(List) == 0: +raise BadExpression('Length %s is %s' % (Value, len(List))) List.reverse() Value = 0 for Char in List: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: StructurePcd array Value support flexible format
if StructurePcd set item value is array, support flexible format like as: gEfiStructuredPcdPkgTokenSpaceGuid.Test.Array | {flexible format} {flexible format} = {L"ABC"} | {L'ABC'} | {"ABC"} | {UINT8(0x10)} | {UINT16(0x10)} | {UINT32(0x10)} | {UINT64(0x10)} | {DEVICE_PATH("PciRoot(0)/Pci(0,0)")} | {GUID(gPcdPkgTokenSpaceGuid)} | {L"ABC", L'ABC', UINT8(0x10)} Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Workspace/DscBuildData.py | 35 +-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index ad5b267fd1..1da4f03ab8 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1528,7 +1528,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray: -Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0]) +try: +Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) +except BadExpression: +EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) +Value, ValueSize = ParseFieldValue(Value) CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName = '' @@ -1550,7 +1555,12 @@ class DscBuildData(PlatformBuildClassObject): FieldName = "." + FieldName IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray: -Value, ValueSize = ParseFieldValue (FieldList[FieldName.strip(".")][0]) +try: +Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) +except BadExpression: +EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) +Value, ValueSize = ParseFieldValue(Value) CApp = CApp + ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); else: NewFieldName = '' @@ -1588,6 +1598,13 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0]) +if IsArray: +try: +FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) +except BadExpression: +EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2])) + try: Value, ValueSize = ParseFieldValue (FieldList[FieldName][0]) except Exception: @@ -1613,6 +1630,13 @@ class DscBuildData(PlatformBuildClassObject): continue if Pcd.DefaultFromDSC
[edk2] [PATCH] BaseTools: Fix GCC build PcdValueCommon.c bug
error message: PcdValueCommon.c: In function '__PcdGetPtr': PcdValueCommon.c:315:11: error: variable 'Byte' set but not used [-Werror=unused-but-set-variable] UINT8 Byte; ^ cc1: all warnings being treated as errors Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/Common/PcdValueCommon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BaseTools/Source/C/Common/PcdValueCommon.c b/BaseTools/Source/C/Common/PcdValueCommon.c index 210f87b8b5..fa12869eda 100644 --- a/BaseTools/Source/C/Common/PcdValueCommon.c +++ b/BaseTools/Source/C/Common/PcdValueCommon.c @@ -310,11 +310,10 @@ Returns: { intIndex; CHAR8 *Value; UINT8 *Buffer; CHAR8 *End; - UINT8 Byte; Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName); if (Index < 0) { fprintf (stderr, "PCD %s.%s.%s.%s is not in database\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName); exit (EXIT_FAILURE); @@ -328,11 +327,11 @@ Returns: fprintf (stderr, "PCD %s.%s.%s.%s is a value. Use PcdGet()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName); exit (EXIT_FAILURE); break; case PcdDataTypePointer: Value = [Index].Value[1]; -for (*Size = 0, Byte = (UINT8) strtoul(Value, , 16); Value != End; Byte = (UINT8) strtoul(Value, , 16), *Size = *Size + 1) { +for (*Size = 0, strtoul(Value, , 16); Value != End; strtoul(Value, , 16), *Size = *Size + 1) { Value = End + 1; } Buffer = malloc(*Size + 1); if (Buffer == NULL) { *Size = 0; -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Optimizing DscDefaultValue process in BuildReport
DscDefaultValue from Dsc file has been parsed by ValueExpressionEx when Dsc file parse, so only DscDefaultValue from FDF file need ValueExpressionEx parse Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/build/BuildReport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index d6e943d2f1..f2a6e6d87e 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -950,13 +950,13 @@ class PcdReport(object): # # Get PCD default value and their override relationship # DecDefaultValue = self.DecPcdDefault.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType)) DscDefaultValue = self.DscPcdDefault.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName)) -DscDefaultValBak= DscDefaultValue +DscDefaultValBak = DscDefaultValue DscDefaultValue = self.FdfPcdSet.get((Pcd.TokenCName, Key), DscDefaultValue) -if DscDefaultValue: +if DscDefaultValue != DscDefaultValBak: DscDefaultValue = ValueExpressionEx(DscDefaultValue, Pcd.DatumType, self._GuidDict)(True) InfDefaultValue = None PcdValue = DecDefaultValue if DscDefaultValue: -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Fix increment build bug
Issue decription: step 1, build platform X64 step 2, build platform IA32 step 3, build platform X64 step 4, check all ffs files for X64, the content still has IA32 in it Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 371d5a8217..97e20753ae 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -1,9 +1,9 @@ ## @file # Global variables for GenFds # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2007 - 2018, 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 # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php @@ -498,11 +498,11 @@ class GenFdsGlobalVariable: SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if IsMakefile: if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) -elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): +elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input)) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and GenFdsGlobalVariable.LargeFileInFvFlags): GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True @@ -550,11 +550,11 @@ class GenFdsGlobalVariable: if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys(): GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath GenFdsGlobalVariable.SecCmdList = [] GenFdsGlobalVariable.CopyList = [] else: -if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): +if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): return GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS") @staticmethod def GenerateFirmwareVolume(Output, Input, BaseAddress=None, ForceRebase=None, Capsule=False, Dump=False, -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 1/2] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature
when set 'MAX_CONCURRENT_THREAD_NUMBER=0', will auto-detect number of processor threads for MAX_CONCURRENT_THREAD_NUMBER Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775 Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/build/build.py | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git BaseTools/Source/Python/build/build.py BaseTools/Source/Python/build/build.py index 38498046d7..de19756d99 100644 --- BaseTools/Source/Python/build/build.py +++ BaseTools/Source/Python/build/build.py @@ -2,7 +2,7 @@ # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P. -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2007 - 2018, 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 @@ -26,6 +26,7 @@ import platform import traceback import encodings.ascii import itertools +import multiprocessing from struct import * from threading import * @@ -936,7 +937,10 @@ class Build(): self.ThreadNumber = int(self.ThreadNumber, 0) if self.ThreadNumber == 0: -self.ThreadNumber = 1 +try: +self.ThreadNumber = multiprocessing.cpu_count() +except (ImportError, NotImplementedError): +self.ThreadNumber = 1 if not self.PlatformFile: PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM] -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature
Adding 'MAX_CONCURRENT_THREAD_NUMBER=0' option for user to enable 'auto-detect thread number' feature, and changing default value to '0' when initial build environment is configured. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775 Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Conf/target.template | 5 +++-- BaseTools/Source/Python/build/build.py | 6 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git BaseTools/Conf/target.template BaseTools/Conf/target.template index 787fc64fb1..ee8745610f 100644 --- BaseTools/Conf/target.template +++ BaseTools/Conf/target.template @@ -61,8 +61,9 @@ TOOL_CHAIN_TAG= MYTOOLS # MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this # value to one more than the number of your compurter -# cores or CPUs. Less than 2 means disable multithread build. -MAX_CONCURRENT_THREAD_NUMBER = 1 +# cores or CPUs. automatically detect number of processor threads +# when 'MAX_CONCURRENT_THREAD_NUMBER=0' +MAX_CONCURRENT_THREAD_NUMBER = 0 # BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed diff --git BaseTools/Source/Python/build/build.py BaseTools/Source/Python/build/build.py index 38498046d7..fd2681e05d 100644 --- BaseTools/Source/Python/build/build.py +++ BaseTools/Source/Python/build/build.py @@ -26,6 +26,7 @@ import platform import traceback import encodings.ascii import itertools +import multiprocessing from struct import * from threading import * @@ -936,7 +937,10 @@ class Build(): self.ThreadNumber = int(self.ThreadNumber, 0) if self.ThreadNumber == 0: -self.ThreadNumber = 1 +try: +self.ThreadNumber = multiprocessing.cpu_count() +except (ImportError, NotImplementedError): +self.ThreadNumber = 1 if not self.PlatformFile: PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM] -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH 2/2] BaseTools: Modify MAX_CONCURRENT_THREAD_NUMBER default values
Modify MAX_CONCURRENT_THREAD_NUMBER default values Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775 Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Conf/target.template | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git BaseTools/Conf/target.template BaseTools/Conf/target.template index 787fc64fb1..c50403bd06 100644 --- BaseTools/Conf/target.template +++ BaseTools/Conf/target.template @@ -1,5 +1,5 @@ # -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. +# Copyright (c) 2006 - 2018, 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 @@ -60,9 +60,10 @@ TOOL_CHAIN_CONF = Conf/tools_def.txt TOOL_CHAIN_TAG= MYTOOLS # MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this -# value to one more than the number of your compurter -# cores or CPUs. Less than 2 means disable multithread build. -MAX_CONCURRENT_THREAD_NUMBER = 1 +# value to one more than the number of your computer +# cores or CPUs. automatically detect number of processor threads +# when 'MAX_CONCURRENT_THREAD_NUMBER=0' +MAX_CONCURRENT_THREAD_NUMBER = 0 # BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] BaseTools: Correct Target Path in CodaTargetList replace Path
Target Path in CodaTargetList is DebugDir path, correct replace path with DebugDir Cc: Liming GaoCc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git BaseTools/Source/Python/AutoGen/AutoGen.py BaseTools/Source/Python/AutoGen/AutoGen.py index 8be5bfca83..2cd15dfd50 100644 --- BaseTools/Source/Python/AutoGen/AutoGen.py +++ BaseTools/Source/Python/AutoGen/AutoGen.py @@ -4149,8 +4149,9 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']] OutputDir = self.OutputDir.replace('\\', '/').strip('/') +DebugDir = self.DebugDir.replace('\\', '/').strip('/') for Item in self.CodaTargetList: -File = Item.Target.Path.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/') +File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').strip('/') if File not in self.OutputFile: self.OutputFile.append(File) if Item.Target.Ext.lower() == '.aml': -- 2.12.2.windows.2 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel