aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaewoong Jung <jungjw@google.com>2019-07-16 18:25:41 -0700
committerMichael Bestas <mkbestas@lineageos.org>2019-12-11 19:03:32 +0200
commit050d2048e953d7f29e65f4627eefdad4b4b25685 (patch)
tree6b5457adbb76be436ea6cd7a958684f83e03d57a
parent1f6212b40da44508f878f95c489639b61d786f4d (diff)
downloadbuild_soong-050d2048e953d7f29e65f4627eefdad4b4b25685.tar.gz
build_soong-050d2048e953d7f29e65f4627eefdad4b4b25685.tar.bz2
build_soong-050d2048e953d7f29e65f4627eefdad4b4b25685.zip
Add overrides property to prebuilt_apex
Bug: 137218697 Test: apex_test.go Change-Id: I55a42e1e4af60d6d7185515a380c786312b8b29b
-rw-r--r--apex/apex.go22
-rw-r--r--apex/apex_test.go42
2 files changed, 35 insertions, 29 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 036b660a..4e82ee50 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1332,6 +1332,13 @@ type PrebuiltProperties struct {
// Optional name for the installed apex. If unspecified, name of the
// module is used as the file name
Filename *string
+
+ // Names of modules to be overridden. Listed modules can only be other binaries
+ // (in Make or Soong).
+ // This does not completely prevent installation of the overridden binaries, but if both
+ // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
+ // from PRODUCT_PACKAGES.
+ Overrides []string
}
func (p *Prebuilt) installable() bool {
@@ -1426,17 +1433,16 @@ func (p *Prebuilt) Name() string {
return p.prebuilt.Name(p.ModuleBase.Name())
}
-func (p *Prebuilt) AndroidMk() android.AndroidMkData {
- return android.AndroidMkData{
+func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
+ return android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(p.inputApex),
Include: "$(BUILD_PREBUILT)",
- Extra: []android.AndroidMkExtraFunc{
- func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", p.installFilename)
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !p.installable())
- },
+ AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
+ entries.SetString("LOCAL_MODULE_PATH", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
+ entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
+ entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...)
},
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a3f92640..1ae1073c 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -29,7 +29,7 @@ import (
var buildDir string
-func testApex(t *testing.T, bp string) *android.TestContext {
+func testApex(t *testing.T, bp string) (*android.TestContext, android.Config) {
var config android.Config
config, buildDir = setup(t)
defer teardown(buildDir)
@@ -188,7 +188,7 @@ func testApex(t *testing.T, bp string) *android.TestContext {
_, errs = ctx.PrepareBuildActions(config)
android.FailIfErrored(t, errs)
- return ctx
+ return ctx, config
}
func setup(t *testing.T) (config android.Config, buildDir string) {
@@ -238,7 +238,7 @@ func ensureListNotContains(t *testing.T, result []string, notExpected string) {
// Minimal test
func TestBasicApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_defaults {
name: "myapex-defaults",
manifest: ":myapex.manifest",
@@ -362,7 +362,7 @@ func TestBasicApex(t *testing.T) {
}
func TestBasicZipApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -410,7 +410,7 @@ func TestBasicZipApex(t *testing.T) {
}
func TestApexWithStubs(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -494,7 +494,7 @@ func TestApexWithStubs(t *testing.T) {
}
func TestApexWithExplicitStubsDependency(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -561,7 +561,7 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
}
func TestApexWithSystemLibsStubs(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -682,7 +682,7 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
}
func TestFilesInSubDir(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -742,7 +742,7 @@ func TestFilesInSubDir(t *testing.T) {
}
func TestUseVendor(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -792,7 +792,7 @@ func TestUseVendor(t *testing.T) {
}
func TestStaticLinking(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -832,7 +832,7 @@ func TestStaticLinking(t *testing.T) {
}
func TestKeys(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex_keytest",
key: "myapex.key",
@@ -886,7 +886,7 @@ func TestKeys(t *testing.T) {
}
func TestMacro(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -930,7 +930,7 @@ func TestMacro(t *testing.T) {
}
func TestHeaderLibsDependency(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -978,7 +978,7 @@ func TestHeaderLibsDependency(t *testing.T) {
}
func TestNonTestApex(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1029,7 +1029,7 @@ func TestTestApex(t *testing.T) {
if android.InAnyApex("mylib_common_test") {
t.Fatal("mylib_common_test must not be used in any other tests since this checks that global state is not updated in an illegal way!")
}
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -1077,7 +1077,7 @@ func TestTestApex(t *testing.T) {
}
func TestApexWithTarget(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1157,7 +1157,7 @@ func TestApexWithTarget(t *testing.T) {
}
func TestApexWithShBinary(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1185,7 +1185,7 @@ func TestApexWithShBinary(t *testing.T) {
}
func TestApexInProductPartition(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
@@ -1217,7 +1217,7 @@ func TestApexInProductPartition(t *testing.T) {
}
func TestApexKeyFromOtherModule(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
apex_key {
name: "myapex.key",
public_key: ":my.avbpubkey",
@@ -1250,7 +1250,7 @@ func TestApexKeyFromOtherModule(t *testing.T) {
}
func TestPrebuilt(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
prebuilt_apex {
name: "myapex",
arch: {
@@ -1273,7 +1273,7 @@ func TestPrebuilt(t *testing.T) {
}
func TestPrebuiltFilenameOverride(t *testing.T) {
- ctx := testApex(t, `
+ ctx, _ := testApex(t, `
prebuilt_apex {
name: "myapex",
src: "myapex-arm.apex",