From 24788182a9a934b550655cbee72c7f6932f90681 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Mon, 4 Feb 2019 14:34:10 -0800 Subject: [PATCH] Add prebuilt_etc_host module type. Change-Id: I667ac7325331fa2c1ecaa0f68c24bfb6d47aa8ad Fixes: 123380976 Test: prebuilt_etc_test.go + external/parameter-framework/Schemas.mk --- android/prebuilt_etc.go | 14 +++++++++++++- android/prebuilt_etc_test.go | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go index e1803427c..33647d7c9 100644 --- a/android/prebuilt_etc.go +++ b/android/prebuilt_etc.go @@ -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 } diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go index d1a80af9f..f31fc9ea9 100644 --- a/android/prebuilt_etc_test.go +++ b/android/prebuilt_etc_test.go @@ -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.") + } +}