From 8fb0e9734c84a4c819963f2e7c532a3198e5df94 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 18 Mar 2024 18:29:37 +0900 Subject: [PATCH] Ensure that genrule's host tool deps are for host Previously, when gathering transitive dependencies of genrule's host tool, TransitivePackagingSpecs() was used if available. However, when using this, it didn't check whether the dependencies are for host or not (i.e. device). This was fine because host module can only depend on host modules. However, this is preventing Soong from implementing the installation of the required modules by itself. Then a host module may depend on a device module or vice versa (because that's the symantics of the property). To prevent the issue, check the partition of the transitive dependencies of the host tool and filter out ones whose partition is not "" (which means host). Bug: 321626681 Test: builds Change-Id: I296a920b3b88e7601315a4e1768af9727d0061e6 --- genrule/genrule.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/genrule/genrule.go b/genrule/genrule.go index a2a3f7584..f8838d249 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -317,7 +317,17 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { // required relative locations of the tool and its dependencies, use those // instead. They will be copied to those relative locations in the sbox // sandbox. - packagedTools = append(packagedTools, specs...) + // Care must be taken since TransitivePackagingSpec may return device-side + // paths via the required property. Filter them out. + for i, ps := range specs { + if ps.Partition() != "" { + if i == 0 { + panic("first PackagingSpec is assumed to be the host-side tool") + } + continue + } + packagedTools = append(packagedTools, ps) + } // Assume that the first PackagingSpec of the module is the tool. addLocationLabel(tag.label, packagedToolLocation{specs[0]}) } else {