diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/apex/apex.go b/apex/apex.go index 58cbb13e9..a9be1a8ae 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -16,7 +16,6 @@ package apex import ( "fmt" - "path" "path/filepath" "sort" "strings" @@ -1242,7 +1241,7 @@ type apexBundle struct { container_certificate_file android.Path container_private_key_file android.Path - fileContexts android.Path + fileContexts android.WritablePath // list of files to be included in this apex filesInfo []apexFile @@ -1724,13 +1723,8 @@ func (c *flattenedApexContext) InstallBypassMake() bool { return true } -// Function called while walking an APEX's payload dependencies. -// -// Return true if the `to` module should be visited, false otherwise. -type payloadDepsCallback func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool - // Visit dependencies that contributes to the payload of this APEX -func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCallback) { +func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) { ctx.WalkDeps(func(child, parent android.Module) bool { am, ok := child.(android.ApexModule) if !ok || !am.CanHaveApexVariants() { @@ -1756,7 +1750,21 @@ func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCa } func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int { - ver := proptools.StringDefault(a.properties.Min_sdk_version, "current") + ver := proptools.String(a.properties.Min_sdk_version) + if ver == "" { + return android.FutureApiLevel + } + // Treat the current codenames as "current", which means future API version (10000) + // Otherwise, ApiStrToNum converts codename(non-finalized) to a value from [9000...] + // and would fail to build against "current". + if android.InList(ver, ctx.Config().PlatformVersionActiveCodenames()) { + return android.FutureApiLevel + } + // In "REL" branch, "current" is mapped to finalized sdk version + if ctx.Config().PlatformSdkCodename() == "REL" && ver == "current" { + return ctx.Config().PlatformSdkVersionInt() + } + // Finalized codenames are OKAY and will be converted to int intVer, err := android.ApiStrToNum(ctx, ver) if err != nil { ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) @@ -1784,7 +1792,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { return } - a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { if externalDep { // As soon as the dependency graph crosses the APEX boundary, don't go further. return false @@ -1820,6 +1828,17 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { } } +func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) { + if a.testApex || a.vndkApex { + return + } + // Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets + if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" { + return + } + android.CheckMinSdkVersion(a, ctx, a.minSdkVersion(ctx)) +} + // Ensures that a lib providing stub isn't statically linked func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) { // Practically, we only care about regular APEXes on the device. @@ -1827,7 +1846,7 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext return } - a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { if ccm, ok := to.(*cc.Module); ok { apexName := ctx.ModuleName() fromName := ctx.OtherModuleName(from) @@ -1866,7 +1885,7 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext } func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { - buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() + buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuildApps() switch a.properties.ApexType { case imageApex: if buildFlattenedAsDefault { @@ -1902,6 +1921,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.checkApexAvailability(ctx) a.checkUpdatable(ctx) + a.checkMinSdkVersion(ctx) a.checkStaticLinkingToStubLibraries(ctx) handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) @@ -1935,7 +1955,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { }) var filesInfo []apexFile - // TODO(jiyong) do this using walkPayloadDeps + // TODO(jiyong) do this using WalkPayloadDeps ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { depTag := ctx.OtherModuleDependencyTag(child) if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { @@ -2174,22 +2194,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.installDir = android.PathForModuleInstall(ctx, "apex") a.filesInfo = filesInfo - if a.properties.ApexType != zipApex { - if a.properties.File_contexts == nil { - a.fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts") - } else { - a.fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts) - if a.Platform() { - if matched, err := path.Match("system/sepolicy/**/*", a.fileContexts.String()); err != nil || !matched { - ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", a.fileContexts) - } - } - } - if !android.ExistentPathForSource(ctx, a.fileContexts.String()).Valid() { - ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts) - return - } - } // Optimization. If we are building bundled APEX, for the files that are gathered due to the // transitive dependencies, don't place them inside the APEX, but place a symlink pointing // the same library in the system partition, thus effectively sharing the same libraries @@ -2213,6 +2217,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // prepare apex_manifest.json a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) + a.buildFileContexts(ctx) + a.setCertificateAndPrivateKey(ctx) if a.properties.ApexType == flattenedApex { a.buildFlattenedApex(ctx) |