From 80c04891de092e8aa7a594e90838a7a21490a5e6 Mon Sep 17 00:00:00 2001 From: Sundong Ahn Date: Tue, 23 Nov 2021 00:57:19 +0000 Subject: [PATCH] Add Sh_binaries property The sh_binary module is not supported the vendor variant. So, even if there is "vendor: true" in sh_binary module, the image variant is "image:" instead of "image:vendor.Tiramisu". But the vendor APEX has vendor variant, so vendor APEX module and sh_binary module have different variants and the sh_binary cannot be added to vendor apex. So the Sh_binaries property is added, and the image variant is removed at DepsMutator. Bug: 205065320 Test: make -j40 && sh_binary is added to vendor APEX && install check Change-Id: I30e2d96a73b45e7b06eff24550542cb010008c41 --- apex/apex.go | 21 ++++++++++++++++++--- apex/apex_test.go | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 20660d345..6bc0b649d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -111,6 +111,9 @@ type apexBundleProperties struct { // List of java libraries that are embedded inside this APEX bundle. Java_libs []string + // List of sh binaries that are embedded inside this APEX bundle. + Sh_binaries []string + // List of platform_compat_config files that are embedded inside this APEX bundle. Compat_configs []string @@ -604,6 +607,7 @@ var ( sharedLibTag = dependencyTag{name: "sharedLib", payload: true} testForTag = dependencyTag{name: "test for"} testTag = dependencyTag{name: "test", payload: true} + shBinaryTag = dependencyTag{name: "shBinary", payload: true} ) // TODO(jiyong): shorten this function signature @@ -748,6 +752,10 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { for _, d := range depsList { addDependenciesForNativeModules(ctx, d, target, imageVariation) } + ctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "os", Variation: target.OsVariation()}, + {Mutator: "arch", Variation: target.ArchVariation()}, + }, shBinaryTag, a.properties.Sh_binaries...) } // Common-arch dependencies come next @@ -1468,6 +1476,9 @@ func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb boots func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile { dirInApex := filepath.Join("bin", sh.SubDir()) + if sh.Target().NativeBridge == android.NativeBridgeEnabled { + dirInApex = filepath.Join(dirInApex, sh.Target().NativeBridgeRelativePath) + } fileToCopy := sh.OutputFile() af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh) af.symlinks = sh.Symlinks() @@ -1708,8 +1719,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { if cc, ok := child.(*cc.Module); ok { filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc)) return true // track transitive dependencies - } else if sh, ok := child.(*sh.ShBinary); ok { - filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py)) } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { @@ -1718,7 +1727,13 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { filesInfo = append(filesInfo, apexFileForRustExecutable(ctx, rust)) return true // track transitive dependencies } else { - ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName) + ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, nor (host) bootstrap_go_binary", depName) + } + case shBinaryTag: + if sh, ok := child.(*sh.ShBinary); ok { + filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) + } else { + ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName) } case bcpfTag: { diff --git a/apex/apex_test.go b/apex/apex_test.go index 59ea206f4..8034854c1 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4248,7 +4248,7 @@ func TestApexWithShBinary(t *testing.T) { apex { name: "myapex", key: "myapex.key", - binaries: ["myscript"], + sh_binaries: ["myscript"], updatable: false, }