From 809bb724f576c64ba2ae7fb292689abf90569b5d Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 13 Feb 2019 21:33:49 +0900 Subject: [PATCH] Add ":name" support for manifest and androidManifest properties in apex The manifest and androidManifest properties in the apex module type now supports ":name" syntax. Bug: 123857186 Test: m (apex_test amended) Change-Id: Ic4e5a73cf73260d156ec61d07932ad07b2561413 --- apex/apex.go | 14 +++++++++++--- apex/apex_test.go | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 7633ad201..3b06a9958 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -511,6 +511,14 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { if cert != "" { ctx.AddDependency(ctx.Module(), certificateTag, cert) } + + if String(a.properties.Manifest) != "" { + android.ExtractSourceDeps(ctx, a.properties.Manifest) + } + + if String(a.properties.AndroidManifest) != "" { + android.ExtractSourceDeps(ctx, a.properties.AndroidManifest) + } } func (a *apexBundle) getCertString(ctx android.BaseContext) string { @@ -793,7 +801,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and certificate = java.Certificate{pem, key} } - manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")) + manifest := ctx.ExpandSource(proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"), "manifest") var abis []string for _, target := range ctx.MultiTargets() { @@ -890,7 +898,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and } if a.properties.AndroidManifest != nil { - androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest)) + androidManifestFile := ctx.ExpandSource(proptools.String(a.properties.AndroidManifest), "androidManifest") implicitInputs = append(implicitInputs, androidManifestFile) optFlags = append(optFlags, "--android_manifest "+androidManifestFile.String()) } @@ -969,7 +977,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) { if a.installable() { // For flattened APEX, do nothing but make sure that apex_manifest.json file is also copied along // with other ordinary files. - manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")) + manifest := ctx.ExpandSource(proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"), "manifest") // rename to apex_manifest.json copiedManifest := android.PathForModuleOut(ctx, "apex_manifest.json") diff --git a/apex/apex_test.go b/apex/apex_test.go index 13ddb55db..66f072590 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -53,6 +53,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory)) ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory)) ctx.RegisterModuleType("android_app_certificate", android.ModuleFactoryAdaptor(java.AndroidAppCertificateFactory)) + ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory)) ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.BottomUp("image", cc.ImageMutator).Parallel() ctx.BottomUp("link", cc.LinkageMutator).Parallel() @@ -143,6 +144,7 @@ func testApex(t *testing.T, bp string) *android.TestContext { "Android.bp": []byte(bp), "build/target/product/security": nil, "apex_manifest.json": nil, + "AndroidManifest.xml": nil, "system/sepolicy/apex/myapex-file_contexts": nil, "system/sepolicy/apex/myapex_keytest-file_contexts": nil, "system/sepolicy/apex/otherapex-file_contexts": nil, @@ -214,6 +216,8 @@ func TestBasicApex(t *testing.T) { ctx := testApex(t, ` apex_defaults { name: "myapex-defaults", + manifest: ":myapex.manifest", + androidManifest: ":myapex.androidmanifest", key: "myapex.key", native_shared_libs: ["mylib"], multilib: { @@ -234,6 +238,16 @@ func TestBasicApex(t *testing.T) { private_key: "testkey.pem", } + filegroup { + name: "myapex.manifest", + srcs: ["apex_manifest.json"], + } + + filegroup { + name: "myapex.androidmanifest", + srcs: ["AndroidManifest.xml"], + } + cc_library { name: "mylib", srcs: ["mylib.cpp"],