From nobody Tue Nov 26 02:40:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61489+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61489+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592490446; cv=none; d=zohomail.com; s=zohoarc; b=PD+SXLVZwM7BcY5qDC2ALwYiJMOi8jjUgv4ENDYLLDpq1JCvNcF6/HE6LGqe1cngt/+JiNbbHG94mFejt0VkHiw9KurLHVsQ66FT6F5Di7sRFoVR6XeSwFtfLXmLW0vPCy/qgbp1OdtoOdfwS6tP9apgfy8EkMcA4cUH1JSJF0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592490446; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=lDWsrMZSCXnLqd3KiD6mJJoNLyOUAKbajb3W8PpoMyM=; b=g8LyJ9BZT8WmwSVRD/DTkxKpHT70Z0WK5pTOfd2MwNqRcIa7hPJHL1zKSrA7u7onOMqmozbL0fw6JPT41YBRi2opXU6IETH9Nzk96EUanu/D9tIaphKaYASvF7rP2IhBcxgBD6afHJL2zw9uHie5OZUTZW9DqtU34NxIPK6FaKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61489+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159249044662744.58864693449357; Thu, 18 Jun 2020 07:27:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CFSVYY1788612xDz9JoM0otV; Thu, 18 Jun 2020 07:27:25 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.49]) by mx.groups.io with SMTP id smtpd.web10.8740.1592490442759624864 for ; Thu, 18 Jun 2020 07:27:23 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05IERJ6X020245; Thu, 18 Jun 2020 15:27:19 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , sami.mujawar@arm.com, tomas.pilar@arm.com, bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v2 1/4] BaseTools: Generate multiple rules when multiple output files Date: Thu, 18 Jun 2020 15:27:10 +0100 Message-Id: <20200618142713.146412-2-pierre.gondois@arm.com> In-Reply-To: <20200618142713.146412-1-pierre.gondois@arm.com> References: <20200618142713.146412-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: k8zP1GvcuOwtyDxPMGXaHiU6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592490445; bh=XrefPP2Ihxbm+l6GkdF86EKvGnXlVB+PWlVxVaDXui8=; h=Cc:Date:From:Reply-To:Subject:To; b=Reeb44UQ75OkXZ8knWiuZZf9n5GUejch5wl5dcCWt8n1T27WDkYyQulDsqFsK4w6cp/ rBpO4Fv+UqMEg4ZBvi0dvWVCOIliL3O93NH/YBlLAZXLDVIkOKZn2Hh80Blyk6grYfmnS +9IIazEDfj549B0eADnt0qoy0q/rfpSJoOo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois This patch modifies the Makefile generation not to stop adding Makfile rules when the first final target is found. E.g.: If the following rules are described in build_rule.txt: -[Rule1]: .X files generate .Y and .Z files; -[Rule2]: .Z files generate .Z1 files. Currently, if a File1.X file was part of the sources of a module, only [Rule1] would be generated in the Makefile. Indeed, there are no rules to apply to .Y files: .Y files are a final target. However, there is still [Rule2] to apply to .Z files. This patch also adds a dependency between the first ouput file of a rule and the other output files. For instance, with the same example as above, File1.Y and File1.Z are generated by the following rule: File1.Y: File1.X and the new dependency is: File1.Z: File1.Y This is necessary to keep a dependency order during the execution of the Makefile. Indeed, .Y and .Z files are generated by the execution of a common set of commands, and without this rule, there is no explicit dependency relation between them. Signed-off-by: Pierre Gondois --- The changes can be seen at https://github.com/PierreARM/edk2/commits/pg/803= _Compile_AML_bytecode_array_into_OBJ_file_v2 Notes: Notes: v1: - Generate multiple rules when multiple output files are specified in the build_rule.txt file. [Pierre] v2: - Use the "FileType" variable in the _ApplyBuildRule function as it is in the current state. [Pierre] BaseTools/Source/Python/AutoGen/GenMake.py | 6 ++++ BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 38 +++++++++++--------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index bbb3c29446f53fa7f2cb61a216a5b119f72c3fbc..0314d0ea34d99a014379e8d30c4= 6ac0f0a7068ce 100755 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1054,6 +1054,12 @@ cleanlib: TargetDict =3D {"target": self.PlaceMacro(T.Target.Pat= h, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": Deps} self.BuildTargetList.append(self._BUILD_TARGET_TEMPLAT= E.Replace(TargetDict)) =20 + # Add a Makefile rule for targets generating multiple = files. + # The main output is a prerequisite for the other outp= ut files. + for i in T.Outputs[1:]: + AnnexeTargetDict =3D {"target": self.PlaceMacro(i.= Path, self.Macros), "cmd": "", "deps": self.PlaceMacro(T.Target.Path, self.= Macros)} + self.BuildTargetList.append(self._BUILD_TARGET_TEM= PLATE.Replace(AnnexeTargetDict)) + def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDi= ct, DependencyDict): if not CmdSumDict: for item in self._AutoGenObject.Targets[Type]: diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index aad591de65f086043d55aeea5661f59c53792e7c..dc8b1fe3d160cac2da22227fc23= 3e3aa0d92cb1e 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -860,7 +860,8 @@ class ModuleAutoGen(AutoGen): SubDirectory =3D os.path.join(self.OutputDir, File.SubDir) if not os.path.exists(SubDirectory): CreateDirectory(SubDirectory) - LastTarget =3D None + TargetList =3D set() + FinalTargetName =3D set() RuleChain =3D set() SourceList =3D [File] Index =3D 0 @@ -870,6 +871,9 @@ class ModuleAutoGen(AutoGen): self.BuildOption =20 while Index < len(SourceList): + # Reset the FileType if not the first iteration. + if Index > 0: + FileType =3D TAB_UNKNOWN_FILE Source =3D SourceList[Index] Index =3D Index + 1 =20 @@ -886,29 +890,25 @@ class ModuleAutoGen(AutoGen): elif Source.Ext in self.BuildRules: RuleObject =3D self.BuildRules[Source.Ext] else: - # stop at no more rules - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break + # No more rule to apply: Source is a final target. + FinalTargetName.add(Source) + continue =20 FileType =3D RuleObject.SourceFileType self._FileTypes[FileType].add(Source) =20 # stop at STATIC_LIBRARY for library if self.IsLibrary and FileType =3D=3D TAB_STATIC_LIBRARY: - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break + FinalTargetName.add(Source) + continue =20 Target =3D RuleObject.Apply(Source, self.BuildRuleOrder) if not Target: - if LastTarget: - self._FinalBuildTargetList.add(LastTarget) - break - elif not Target.Outputs: - # Only do build for target with outputs - self._FinalBuildTargetList.add(Target) + # No Target: Source is a final target. + FinalTargetName.add(Source) + continue =20 + TargetList.add(Target) self._BuildTargets[FileType].add(Target) =20 if not Source.IsBinary and Source =3D=3D File: @@ -916,12 +916,16 @@ class ModuleAutoGen(AutoGen): =20 # to avoid cyclic rule if FileType in RuleChain: - break + EdkLogger.error("build", ERROR_STATEMENT, "Cyclic dependen= cy detected while generating rule for %s" % str(Source)) =20 RuleChain.add(FileType) SourceList.extend(Target.Outputs) - LastTarget =3D Target - FileType =3D TAB_UNKNOWN_FILE + + # For each final target name, retrieve the corresponding TargetDes= cBlock instance. + for FTargetName in FinalTargetName: + for Target in TargetList: + if FTargetName =3D=3D Target.Target: + self._FinalBuildTargetList.add(Target) =20 @cached_property def Targets(self): --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61489): https://edk2.groups.io/g/devel/message/61489 Mute This Topic: https://groups.io/mt/74959530/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-