From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web10.7382.1609721455750389253 for ; Sun, 03 Jan 2021 16:50:56 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 04 Jan 2021 08:50:51 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Bob Feng'" , Cc: "'Yuwei Chen'" , "'Mingyue Liang'" References: <20201229121457.1066-1-bob.c.feng@intel.com> In-Reply-To: <20201229121457.1066-1-bob.c.feng@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUGF0Y2ggMS8xXSBCYXNlVG9vbHM6IEZpeCB0aGUgaXNzdWUgY2F1c2VkIGJ5IHRvc3RyaW5nKCkgcmVtb3ZhbCBvbiBQeTM5?= Date: Mon, 4 Jan 2021 08:50:52 +0800 Message-ID: <000601d6e233$a6f5e2b0$f4e1a810$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQI0bIdVb7LpHYzyYhnCX6THhLH7mqlbjdsQ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Bob: > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Bob Feng > =B7=A2=CB=CD=CA=B1=BC=E4: 2020=C4=EA12=D4=C229=C8=D5 20:15 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Liming Gao ; Yuwei Chen > ; Mingyue Liang > =D6=F7=CC=E2: [Patch 1/1] BaseTools: Fix the issue caused by = tostring() removal on > Py39 >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3136 >=20 > Python 3.9 remove the array.array.tostring and > array.array.fromstring() function. This patch > is to use other method to replace tostring() and > fromstring() >=20 > Signed-off-by: Bob Feng >=20 > Cc: Liming Gao > Cc: Yuwei Chen > Cc: Mingyue Liang > --- > .../Python/GenFds/GenFdsGlobalVariable.py | 23 > ++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > index dc1727c4666d..3019ec63c3bb 100644 > --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py > @@ -25,14 +25,15 @@ from Common.Misc import SaveFileOnChange >=20 > from Common.TargetTxtClassObject import TargetTxtDict > from Common.ToolDefClassObject import ToolDefDict > from AutoGen.BuildEngine import ToolBuildRule > import Common.DataType as DataType > -from Common.Misc import PathClass > +from Common.Misc import PathClass,CreateDirectory > from Common.LongFilePathSupport import OpenLongFilePath as open > from Common.MultipleWorkspace import MultipleWorkspace as mws > import Common.GlobalData as GlobalData > +from Common.BuildToolError import * >=20 > ## Global variables > # > # > class GenFdsGlobalVariable: > @@ -461,16 +462,32 @@ class GenFdsGlobalVariable: > Cmd +=3D ("-o", Output) > if ' '.join(Cmd).strip() not in > GenFdsGlobalVariable.SecCmdList: > GenFdsGlobalVariable.SecCmdList.append(' > '.join(Cmd).strip()) > else: > SectionData =3D array('B', [0, 0, 0, 0]) > - SectionData.fromstring(Ui.encode("utf_16_le")) > + > SectionData.fromlist(array('B',Ui.encode('utf-16-le')).tolist()) > SectionData.append(0) > SectionData.append(0) > Len =3D len(SectionData) >=20 > GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & = 0xff, > (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) > - SaveFileOnChange(Output, SectionData.tostring()) > + > + > + DirName =3D os.path.dirname(Output) > + if not CreateDirectory(DirName): > + EdkLogger.error(None, FILE_CREATE_FAILURE, > "Could not create directory %s" % DirName) > + else: > + if DirName =3D=3D '': > + DirName =3D os.getcwd() > + if not os.access(DirName, os.W_OK): > + EdkLogger.error(None, PERMISSION_FAILURE, > "Do not have write permission on directory %s" % DirName) > + > + try: > + with open(Output, "wb") as Fd: > + SectionData.tofile(Fd) > + Fd.flush() > + except IOError as X: > + EdkLogger.error(None, FILE_CREATE_FAILURE, > ExtraData=3D'IOError %s' % X) Does this change always update the file time stamp even if the file = content is not changed? Thanks Liming >=20 > elif Ver: > Cmd +=3D ("-n", Ver) > if BuildNumber: > Cmd +=3D ("-j", BuildNumber) > -- > 2.29.1.windows.1