Merge "Add a host prebuilt module type for usr/share."
am: 368a97286b
Change-Id: I782d6168bb1a4d4fc16d23a6220fcca071428ccd
This commit is contained in:
commit
ecaae42150
2 changed files with 37 additions and 8 deletions
|
@ -26,6 +26,7 @@ func init() {
|
||||||
RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
||||||
RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
|
RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
|
||||||
RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
|
RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
|
||||||
|
RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
|
||||||
|
|
||||||
PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
|
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
|
||||||
|
@ -202,6 +203,15 @@ func PrebuiltUserShareFactory() Module {
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prebuild_usr_share_host is for host prebuilts that will be installed to <partition>/usr/share/<subdir>
|
||||||
|
func PrebuiltUserShareHostFactory() Module {
|
||||||
|
module := &PrebuiltEtc{installDirBase: "usr/share"}
|
||||||
|
InitPrebuiltEtcModule(module)
|
||||||
|
// This module is host-only
|
||||||
|
InitAndroidArchModule(module, HostSupported, MultilibCommon)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// coreMode is the variant for modules to be installed to system.
|
// coreMode is the variant for modules to be installed to system.
|
||||||
coreMode = "core"
|
coreMode = "core"
|
||||||
|
|
|
@ -19,17 +19,19 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testPrebuiltEtc(t *testing.T, bp string) *TestContext {
|
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
||||||
config, buildDir := setUp(t)
|
config, buildDir := setUp(t)
|
||||||
defer tearDown(buildDir)
|
defer tearDown(buildDir)
|
||||||
ctx := NewTestArchContext()
|
ctx := NewTestArchContext()
|
||||||
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
|
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
|
||||||
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
|
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
|
||||||
ctx.RegisterModuleType("prebuilt_usr_share", ModuleFactoryAdaptor(PrebuiltUserShareFactory))
|
ctx.RegisterModuleType("prebuilt_usr_share", ModuleFactoryAdaptor(PrebuiltUserShareFactory))
|
||||||
|
ctx.RegisterModuleType("prebuilt_usr_share_host", ModuleFactoryAdaptor(PrebuiltUserShareHostFactory))
|
||||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
|
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
|
||||||
})
|
})
|
||||||
|
@ -46,7 +48,7 @@ func testPrebuiltEtc(t *testing.T, bp string) *TestContext {
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
_, errs = ctx.PrepareBuildActions(config)
|
||||||
FailIfErrored(t, errs)
|
FailIfErrored(t, errs)
|
||||||
|
|
||||||
return ctx
|
return ctx, config
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUp(t *testing.T) (config Config, buildDir string) {
|
func setUp(t *testing.T) (config Config, buildDir string) {
|
||||||
|
@ -64,7 +66,7 @@ func tearDown(buildDir string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltEtcVariants(t *testing.T) {
|
func TestPrebuiltEtcVariants(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "foo.conf",
|
name: "foo.conf",
|
||||||
src: "foo.conf",
|
src: "foo.conf",
|
||||||
|
@ -98,7 +100,7 @@ func TestPrebuiltEtcVariants(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltEtcOutputPath(t *testing.T) {
|
func TestPrebuiltEtcOutputPath(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "foo.conf",
|
name: "foo.conf",
|
||||||
src: "foo.conf",
|
src: "foo.conf",
|
||||||
|
@ -113,7 +115,7 @@ func TestPrebuiltEtcOutputPath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltEtcGlob(t *testing.T) {
|
func TestPrebuiltEtcGlob(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "my_foo",
|
name: "my_foo",
|
||||||
src: "foo.*",
|
src: "foo.*",
|
||||||
|
@ -137,7 +139,7 @@ func TestPrebuiltEtcGlob(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
src: "foo.conf",
|
src: "foo.conf",
|
||||||
|
@ -181,7 +183,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltEtcHost(t *testing.T) {
|
func TestPrebuiltEtcHost(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc_host {
|
prebuilt_etc_host {
|
||||||
name: "foo.conf",
|
name: "foo.conf",
|
||||||
src: "foo.conf",
|
src: "foo.conf",
|
||||||
|
@ -196,7 +198,7 @@ func TestPrebuiltEtcHost(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
||||||
ctx := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_usr_share {
|
prebuilt_usr_share {
|
||||||
name: "foo.conf",
|
name: "foo.conf",
|
||||||
src: "foo.conf",
|
src: "foo.conf",
|
||||||
|
@ -210,3 +212,20 @@ func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
||||||
t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString())
|
t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
|
||||||
|
ctx, config := testPrebuiltEtc(t, `
|
||||||
|
prebuilt_usr_share_host {
|
||||||
|
name: "foo.conf",
|
||||||
|
src: "foo.conf",
|
||||||
|
sub_dir: "bar",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
buildOS := BuildOs.String()
|
||||||
|
p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc)
|
||||||
|
expected := filepath.Join("host", config.PrebuiltOS(), "usr", "share", "bar")
|
||||||
|
if p.installDirPath.RelPathString() != expected {
|
||||||
|
t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue