Merge changes I072ad8c3,I72e2f1c9,I47e27d2d into rvc-dev
* changes: cc: add min_sdk_version prop apex: respect filename property for apk-in-apex apex: Don't run apex mutators if disabled
This commit is contained in:
23
apex/apex.go
23
apex/apex.go
@@ -845,10 +845,13 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
|
|||||||
// Mark the direct and transitive dependencies of apex bundles so that they
|
// Mark the direct and transitive dependencies of apex bundles so that they
|
||||||
// can be built for the apex bundles.
|
// can be built for the apex bundles.
|
||||||
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
func apexDepsMutator(mctx android.TopDownMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
var apexBundles []android.ApexInfo
|
var apexBundles []android.ApexInfo
|
||||||
var directDep bool
|
var directDep bool
|
||||||
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
||||||
apexBundles = []android.ApexInfo{android.ApexInfo{
|
apexBundles = []android.ApexInfo{{
|
||||||
ApexName: mctx.ModuleName(),
|
ApexName: mctx.ModuleName(),
|
||||||
MinSdkVersion: a.minSdkVersion(mctx),
|
MinSdkVersion: a.minSdkVersion(mctx),
|
||||||
}}
|
}}
|
||||||
@@ -886,6 +889,9 @@ func inAnySdk(module android.Module) bool {
|
|||||||
|
|
||||||
// Create apex variations if a module is included in APEX(s).
|
// Create apex variations if a module is included in APEX(s).
|
||||||
func apexMutator(mctx android.BottomUpMutatorContext) {
|
func apexMutator(mctx android.BottomUpMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
|
||||||
am.CreateApexVariations(mctx)
|
am.CreateApexVariations(mctx)
|
||||||
} else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
} else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
|
||||||
@@ -923,6 +929,9 @@ func addFlattenedFileContextsInfos(ctx android.BaseModuleContext, fileContextsIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
|
||||||
|
if !mctx.Module().Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if ab, ok := mctx.Module().(*apexBundle); ok {
|
if ab, ok := mctx.Module().(*apexBundle); ok {
|
||||||
var variants []string
|
var variants []string
|
||||||
switch proptools.StringDefault(ab.properties.Payload_type, "image") {
|
switch proptools.StringDefault(ab.properties.Payload_type, "image") {
|
||||||
@@ -1746,15 +1755,16 @@ func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.Platform
|
|||||||
func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
|
func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
|
||||||
android.Module
|
android.Module
|
||||||
Privileged() bool
|
Privileged() bool
|
||||||
|
InstallApkName() string
|
||||||
OutputFile() android.Path
|
OutputFile() android.Path
|
||||||
JacocoReportClassesFile() android.Path
|
JacocoReportClassesFile() android.Path
|
||||||
Certificate() java.Certificate
|
Certificate() java.Certificate
|
||||||
}, pkgName string) apexFile {
|
}) apexFile {
|
||||||
appDir := "app"
|
appDir := "app"
|
||||||
if aapp.Privileged() {
|
if aapp.Privileged() {
|
||||||
appDir = "priv-app"
|
appDir = "priv-app"
|
||||||
}
|
}
|
||||||
dirInApex := filepath.Join(appDir, pkgName)
|
dirInApex := filepath.Join(appDir, aapp.InstallApkName())
|
||||||
fileToCopy := aapp.OutputFile()
|
fileToCopy := aapp.OutputFile()
|
||||||
af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
|
af := newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
|
||||||
af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
|
af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
|
||||||
@@ -2035,14 +2045,13 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
||||||
}
|
}
|
||||||
case androidAppTag:
|
case androidAppTag:
|
||||||
pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
|
|
||||||
if ap, ok := child.(*java.AndroidApp); ok {
|
if ap, ok := child.(*java.AndroidApp); ok {
|
||||||
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
|
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
} else if ap, ok := child.(*java.AndroidAppImport); ok {
|
} else if ap, ok := child.(*java.AndroidAppImport); ok {
|
||||||
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
|
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
|
||||||
} else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
|
} else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
|
||||||
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
|
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
|
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
|
||||||
}
|
}
|
||||||
|
@@ -3413,6 +3413,7 @@ func TestApexWithAppImports(t *testing.T) {
|
|||||||
dex_preopt: {
|
dex_preopt: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
|
filename: "AwesomePrebuiltAppFooPriv.apk",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
@@ -3421,7 +3422,47 @@ func TestApexWithAppImports(t *testing.T) {
|
|||||||
copyCmds := apexRule.Args["copy_commands"]
|
copyCmds := apexRule.Args["copy_commands"]
|
||||||
|
|
||||||
ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt/AppFooPrebuilt.apk")
|
ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt/AppFooPrebuilt.apk")
|
||||||
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt/AppFooPrivPrebuilt.apk")
|
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt/AwesomePrebuiltAppFooPriv.apk")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestApexWithAppImportsPrefer(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
apps: [
|
||||||
|
"AppFoo",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app {
|
||||||
|
name: "AppFoo",
|
||||||
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "none",
|
||||||
|
apex_available: [ "myapex" ],
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app_import {
|
||||||
|
name: "AppFoo",
|
||||||
|
apk: "AppFooPrebuilt.apk",
|
||||||
|
filename: "AppFooPrebuilt.apk",
|
||||||
|
presigned: true,
|
||||||
|
prefer: true,
|
||||||
|
}
|
||||||
|
`, withFiles(map[string][]byte{
|
||||||
|
"AppFooPrebuilt.apk": nil,
|
||||||
|
}))
|
||||||
|
|
||||||
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
|
"app/AppFoo/AppFooPrebuilt.apk",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexWithTestHelperApp(t *testing.T) {
|
func TestApexWithTestHelperApp(t *testing.T) {
|
||||||
@@ -3754,7 +3795,7 @@ func TestOverrideApex(t *testing.T) {
|
|||||||
copyCmds := apexRule.Args["copy_commands"]
|
copyCmds := apexRule.Args["copy_commands"]
|
||||||
|
|
||||||
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
|
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
|
||||||
ensureContains(t, copyCmds, "image.apex/app/app/override_app.apk")
|
ensureContains(t, copyCmds, "image.apex/app/override_app/override_app.apk")
|
||||||
|
|
||||||
apexBundle := module.Module().(*apexBundle)
|
apexBundle := module.Module().(*apexBundle)
|
||||||
name := apexBundle.Name()
|
name := apexBundle.Name()
|
||||||
@@ -4085,6 +4126,27 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
|
|||||||
ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
|
ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexMutatorsDontRunIfDisabled(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
}
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
`, func(fs map[string][]byte, config android.Config) {
|
||||||
|
delete(config.Targets, android.Android)
|
||||||
|
config.AndroidCommonTarget = android.Target{}
|
||||||
|
})
|
||||||
|
|
||||||
|
if expected, got := []string{""}, ctx.ModuleVariantsForTests("myapex"); !reflect.DeepEqual(expected, got) {
|
||||||
|
t.Errorf("Expected variants: %v, but got: %v", expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAppBundle(t *testing.T) {
|
func TestAppBundle(t *testing.T) {
|
||||||
ctx, _ := testApex(t, `
|
ctx, _ := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
|
3
cc/cc.go
3
cc/cc.go
@@ -211,6 +211,9 @@ type BaseProperties struct {
|
|||||||
// Minimum sdk version supported when compiling against the ndk
|
// Minimum sdk version supported when compiling against the ndk
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
|
||||||
|
// Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
|
||||||
|
Min_sdk_version *string
|
||||||
|
|
||||||
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
AndroidMkSharedLibs []string `blueprint:"mutated"`
|
||||||
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
||||||
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
|
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
|
||||||
|
17
java/app.go
17
java/app.go
@@ -500,6 +500,10 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
|
|||||||
return certificates
|
return certificates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidApp) InstallApkName() string {
|
||||||
|
return a.installApkName
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var apkDeps android.Paths
|
var apkDeps android.Paths
|
||||||
|
|
||||||
@@ -1110,6 +1114,10 @@ func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
a.generateAndroidBuildActions(ctx)
|
a.generateAndroidBuildActions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidAppImport) InstallApkName() string {
|
||||||
|
return a.BaseModuleName()
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
numCertPropsSet := 0
|
numCertPropsSet := 0
|
||||||
if String(a.properties.Certificate) != "" {
|
if String(a.properties.Certificate) != "" {
|
||||||
@@ -1167,6 +1175,8 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
dexOutput = dexUncompressed
|
dexOutput = dexUncompressed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apkFilename := proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+".apk")
|
||||||
|
|
||||||
// Sign or align the package
|
// Sign or align the package
|
||||||
// TODO: Handle EXTERNAL
|
// TODO: Handle EXTERNAL
|
||||||
if !Bool(a.properties.Presigned) {
|
if !Bool(a.properties.Presigned) {
|
||||||
@@ -1177,11 +1187,11 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
|
ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
|
||||||
}
|
}
|
||||||
a.certificate = certificates[0]
|
a.certificate = certificates[0]
|
||||||
signed := android.PathForModuleOut(ctx, "signed", ctx.ModuleName()+".apk")
|
signed := android.PathForModuleOut(ctx, "signed", apkFilename)
|
||||||
SignAppPackage(ctx, signed, dexOutput, certificates, nil)
|
SignAppPackage(ctx, signed, dexOutput, certificates, nil)
|
||||||
a.outputFile = signed
|
a.outputFile = signed
|
||||||
} else {
|
} else {
|
||||||
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", ctx.ModuleName()+".apk")
|
alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename)
|
||||||
TransformZipAlign(ctx, alignedApk, dexOutput)
|
TransformZipAlign(ctx, alignedApk, dexOutput)
|
||||||
a.outputFile = alignedApk
|
a.outputFile = alignedApk
|
||||||
a.certificate = presignedCertificate
|
a.certificate = presignedCertificate
|
||||||
@@ -1189,8 +1199,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
|
|
||||||
// TODO: Optionally compress the output apk.
|
// TODO: Optionally compress the output apk.
|
||||||
|
|
||||||
a.installPath = ctx.InstallFile(installDir,
|
a.installPath = ctx.InstallFile(installDir, apkFilename, a.outputFile)
|
||||||
proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+".apk"), a.outputFile)
|
|
||||||
|
|
||||||
// TODO: androidmk converter jni libs
|
// TODO: androidmk converter jni libs
|
||||||
}
|
}
|
||||||
|
@@ -150,6 +150,12 @@ type syspropLibraryProperties struct {
|
|||||||
|
|
||||||
// Whether public stub exists or not.
|
// Whether public stub exists or not.
|
||||||
Public_stub *bool `blueprint:"mutated"`
|
Public_stub *bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
Cpp struct {
|
||||||
|
// Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
|
||||||
|
// Forwarded to cc_library.min_sdk_version
|
||||||
|
Min_sdk_version *string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -326,6 +332,7 @@ type ccLibraryProperties struct {
|
|||||||
Vendor_available *bool
|
Vendor_available *bool
|
||||||
Host_supported *bool
|
Host_supported *bool
|
||||||
Apex_available []string
|
Apex_available []string
|
||||||
|
Min_sdk_version *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type javaLibraryProperties struct {
|
type javaLibraryProperties struct {
|
||||||
@@ -415,6 +422,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
|
|||||||
ccProps.Vendor_available = m.properties.Vendor_available
|
ccProps.Vendor_available = m.properties.Vendor_available
|
||||||
ccProps.Host_supported = m.properties.Host_supported
|
ccProps.Host_supported = m.properties.Host_supported
|
||||||
ccProps.Apex_available = m.ApexProperties.Apex_available
|
ccProps.Apex_available = m.ApexProperties.Apex_available
|
||||||
|
ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version
|
||||||
ctx.CreateModule(cc.LibraryFactory, &ccProps)
|
ctx.CreateModule(cc.LibraryFactory, &ccProps)
|
||||||
|
|
||||||
scope := "internal"
|
scope := "internal"
|
||||||
|
Reference in New Issue
Block a user