Add prebuilt_etc_host module type.

Change-Id: I667ac7325331fa2c1ecaa0f68c24bfb6d47aa8ad
Fixes: 123380976
Test: prebuilt_etc_test.go + external/parameter-framework/Schemas.mk
This commit is contained in:
Jaewoong Jung 2019-02-04 14:34:10 -08:00
parent 54956abf1f
commit 24788182a9
2 changed files with 29 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import (
func init() {
RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
RegisterModuleType("prebuilt_etc_host", prebuiltEtcHostFactory)
PreDepsMutators(func(ctx RegisterMutatorsContext) {
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
@ -149,6 +150,9 @@ func (p *PrebuiltEtc) AndroidMk() AndroidMkData {
fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", *p.commonProperties.Owner)
}
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
if p.Host() {
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
}
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String())
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", p.outputFilePath.Base())
@ -178,6 +182,14 @@ func PrebuiltEtcFactory() Module {
return module
}
func prebuiltEtcHostFactory() Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module)
// This module is host-only
InitAndroidArchModule(module, HostSupported, MultilibCommon)
return module
}
const (
// coreMode is the variant for modules to be installed to system.
coreMode = "core"
@ -190,7 +202,7 @@ const (
// system or recovery.
func prebuiltEtcMutator(mctx BottomUpMutatorContext) {
m, ok := mctx.Module().(*PrebuiltEtc)
if !ok {
if !ok || m.Host() {
return
}

View File

@ -28,6 +28,7 @@ func testPrebuiltEtc(t *testing.T, bp string) *TestContext {
defer tearDown(buildDir)
ctx := NewTestArchContext()
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(prebuiltEtcHostFactory))
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
})
@ -177,3 +178,18 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
}
}
}
func TestPrebuiltEtcHost(t *testing.T) {
ctx := testPrebuiltEtc(t, `
prebuilt_etc_host {
name: "foo.conf",
src: "foo.conf",
}
`)
buildOS := BuildOs.String()
p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc)
if !p.Host() {
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
}
}