Add apex_available to control the availablity of a module to APEXes

apex_available property controls the availability of a module to APEXes.
For example, `apex_available: ["myapex", "otherapex"]` makes the module
available only to the two APEXes: myapex and otherapex, and nothing
else, even to the platform.

If the module is intended to be available to any APEX, then a pseudo
name "//apex_available:anyapex" can be used.

If the module is intended to be available to the platform, then another
pseudo name "//apex_available:platform" is used.

For now, if unspecified, this property defaults to ["//apex_available:platform",
"//apex_available:anyapex"], which means the module is available to everybody.
This will be reduced to ["//apex_available:platform"], when marking for
apex_available for existing modules are finished.

Bug: 139870423
Bug: 128708192
Test: m
Change-Id: Id4b233c3056c7858f984cbf9427cfac4118b2682
This commit is contained in:
Jiyong Park
2019-09-30 16:04:35 +09:00
parent fdc9afa15b
commit 127b40b316
3 changed files with 206 additions and 2 deletions

View File

@@ -1215,6 +1215,16 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
}
// check apex_available requirements
for _, fi := range filesInfo {
if am, ok := fi.module.(android.ApexModule); ok {
if !am.AvailableFor(ctx.ModuleName()) {
ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
return
}
}
}
// 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 {