diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/apex/apex.go b/apex/apex.go index dce9bea25..9382c191b 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -182,10 +182,7 @@ func init() { android.RegisterModuleType("apex_defaults", defaultsFactory) android.RegisterModuleType("prebuilt_apex", PrebuiltFactory) - android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { - ctx.TopDown("apex_vndk_gather", apexVndkGatherMutator).Parallel() - ctx.BottomUp("apex_vndk_add_deps", apexVndkAddDepsMutator).Parallel() - }) + android.PreDepsMutators(RegisterPreDepsMutators) android.PostDepsMutators(RegisterPostDepsMutators) android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { @@ -195,6 +192,11 @@ func init() { }) } +func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { + ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() + ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() +} + func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { ctx.TopDown("apex_deps", apexDepsMutator) ctx.BottomUp("apex", apexMutator).Parallel() @@ -207,44 +209,39 @@ var ( vndkApexListMutex sync.Mutex ) -func vndkApexList(config android.Config) map[string]*apexBundle { +func vndkApexList(config android.Config) map[string]string { return config.Once(vndkApexListKey, func() interface{} { - return map[string]*apexBundle{} - }).(map[string]*apexBundle) + return map[string]string{} + }).(map[string]string) } -// apexVndkGatherMutator gathers "apex_vndk" modules and puts them in a map with vndk_version as a key. -func apexVndkGatherMutator(mctx android.TopDownMutatorContext) { +func apexVndkMutator(mctx android.TopDownMutatorContext) { if ab, ok := mctx.Module().(*apexBundle); ok && ab.vndkApex { if ab.IsNativeBridgeSupported() { mctx.PropertyErrorf("native_bridge_supported", "%q doesn't support native bridge binary.", mctx.ModuleType()) } - vndkVersion := proptools.String(ab.vndkProperties.Vndk_version) + vndkVersion := ab.vndkVersion(mctx.DeviceConfig()) + // Ensure VNDK APEX mount point is formatted as com.android.vndk.v### + ab.properties.Apex_name = proptools.StringPtr("com.android.vndk.v" + vndkVersion) + // vndk_version should be unique vndkApexListMutex.Lock() defer vndkApexListMutex.Unlock() vndkApexList := vndkApexList(mctx.Config()) if other, ok := vndkApexList[vndkVersion]; ok { - mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other.BaseModuleName()) + mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other) } - vndkApexList[vndkVersion] = ab + vndkApexList[vndkVersion] = mctx.ModuleName() } } -// apexVndkAddDepsMutator adds (reverse) dependencies from vndk libs to apex_vndk modules. -// It filters only libs with matching targets. -func apexVndkAddDepsMutator(mctx android.BottomUpMutatorContext) { - if cc, ok := mctx.Module().(*cc.Module); ok && cc.IsVndkOnSystem() { +func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) { + if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) { + vndkVersion := m.VndkVersion() vndkApexList := vndkApexList(mctx.Config()) - if ab, ok := vndkApexList[cc.VndkVersion()]; ok { - targetArch := cc.Target().String() - for _, target := range ab.MultiTargets() { - if target.String() == targetArch { - mctx.AddReverseDependency(mctx.Module(), sharedLibTag, ab.Name()) - break - } - } + if vndkApex, ok := vndkApexList[vndkVersion]; ok { + mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApex) } } } @@ -657,7 +654,6 @@ func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { } func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { - targets := ctx.MultiTargets() config := ctx.DeviceConfig() @@ -828,6 +824,9 @@ func (a *apexBundle) installable() bool { } func (a *apexBundle) getImageVariation(config android.DeviceConfig) string { + if a.vndkApex { + return "vendor." + a.vndkVersion(config) + } if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) { return "vendor." + config.PlatformVndkVersion() } else { @@ -1244,7 +1243,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // prepend the name of this APEX to the module names. These names will be the names of // modules that will be defined if the APEX is flattened. for i := range filesInfo { - filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName + filesInfo[i].moduleName = filesInfo[i].moduleName + "." + ctx.ModuleName() } a.installDir = android.PathForModuleInstall(ctx, "apex") @@ -1570,7 +1569,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) { if a.installable() { // For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along // with other ordinary files. - a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, ctx.ModuleName() + ".apex_manifest.json", ".", etc, nil, nil}) + a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, "apex_manifest.json." + ctx.ModuleName(), ".", etc, nil, nil}) // rename to apex_pubkey copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey") @@ -1579,7 +1578,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) { Input: a.public_key_file, Output: copiedPubkey, }) - a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, ctx.ModuleName() + ".apex_pubkey", ".", etc, nil, nil}) + a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + ctx.ModuleName(), ".", etc, nil, nil}) if ctx.Config().FlattenApex() { apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName()) @@ -1819,19 +1818,18 @@ func vndkApexBundleFactory() android.Module { }{ proptools.StringPtr("both"), }) - - vndkVersion := proptools.StringDefault(bundle.vndkProperties.Vndk_version, "current") - if vndkVersion == "current" { - vndkVersion = ctx.DeviceConfig().PlatformVndkVersion() - bundle.vndkProperties.Vndk_version = proptools.StringPtr(vndkVersion) - } - - // Ensure VNDK APEX mount point is formatted as com.android.vndk.v### - bundle.properties.Apex_name = proptools.StringPtr("com.android.vndk.v" + vndkVersion) }) return bundle } +func (a *apexBundle) vndkVersion(config android.DeviceConfig) string { + vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current") + if vndkVersion == "current" { + vndkVersion = config.PlatformVndkVersion() + } + return vndkVersion +} + // // Defaults // |