Merge "Revert "Supports VNDK APEX with different versions""
This commit is contained in:
72
apex/apex.go
72
apex/apex.go
@@ -182,7 +182,10 @@ func init() {
|
||||
android.RegisterModuleType("apex_defaults", defaultsFactory)
|
||||
android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
|
||||
|
||||
android.PreDepsMutators(RegisterPreDepsMutators)
|
||||
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.TopDown("apex_vndk_gather", apexVndkGatherMutator).Parallel()
|
||||
ctx.BottomUp("apex_vndk_add_deps", apexVndkAddDepsMutator).Parallel()
|
||||
})
|
||||
android.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
||||
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
|
||||
@@ -192,11 +195,6 @@ 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()
|
||||
@@ -209,39 +207,44 @@ var (
|
||||
vndkApexListMutex sync.Mutex
|
||||
)
|
||||
|
||||
func vndkApexList(config android.Config) map[string]string {
|
||||
func vndkApexList(config android.Config) map[string]*apexBundle {
|
||||
return config.Once(vndkApexListKey, func() interface{} {
|
||||
return map[string]string{}
|
||||
}).(map[string]string)
|
||||
return map[string]*apexBundle{}
|
||||
}).(map[string]*apexBundle)
|
||||
}
|
||||
|
||||
func apexVndkMutator(mctx android.TopDownMutatorContext) {
|
||||
// apexVndkGatherMutator gathers "apex_vndk" modules and puts them in a map with vndk_version as a key.
|
||||
func apexVndkGatherMutator(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 := 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)
|
||||
vndkVersion := proptools.String(ab.vndkProperties.Vndk_version)
|
||||
|
||||
// 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)
|
||||
mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other.BaseModuleName())
|
||||
}
|
||||
vndkApexList[vndkVersion] = mctx.ModuleName()
|
||||
vndkApexList[vndkVersion] = ab
|
||||
}
|
||||
}
|
||||
|
||||
func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
|
||||
if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) {
|
||||
vndkVersion := m.VndkVersion()
|
||||
// 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() {
|
||||
vndkApexList := vndkApexList(mctx.Config())
|
||||
if vndkApex, ok := vndkApexList[vndkVersion]; ok {
|
||||
mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApex)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -654,6 +657,7 @@ func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
||||
targets := ctx.MultiTargets()
|
||||
config := ctx.DeviceConfig()
|
||||
|
||||
@@ -824,9 +828,6 @@ 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 {
|
||||
@@ -1243,7 +1244,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 = filesInfo[i].moduleName + "." + ctx.ModuleName()
|
||||
filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName
|
||||
}
|
||||
|
||||
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||
@@ -1569,7 +1570,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, "apex_manifest.json." + ctx.ModuleName(), ".", etc, nil, nil})
|
||||
a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, ctx.ModuleName() + ".apex_manifest.json", ".", etc, nil, nil})
|
||||
|
||||
// rename to apex_pubkey
|
||||
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
|
||||
@@ -1578,7 +1579,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
||||
Input: a.public_key_file,
|
||||
Output: copiedPubkey,
|
||||
})
|
||||
a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + ctx.ModuleName(), ".", etc, nil, nil})
|
||||
a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, ctx.ModuleName() + ".apex_pubkey", ".", etc, nil, nil})
|
||||
|
||||
if ctx.Config().FlattenApex() {
|
||||
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
|
||||
@@ -1818,18 +1819,19 @@ 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
|
||||
//
|
||||
|
Reference in New Issue
Block a user