Loading android/prebuilt_etc.go +19 −7 Original line number Diff line number Diff line Loading @@ -20,12 +20,12 @@ import ( "strings" ) // prebuilt_etc is for prebuilts that will be installed to // <partition>/etc/<subdir> // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file. func init() { RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel() Loading Loading @@ -62,6 +62,8 @@ type PrebuiltEtc struct { sourceFilePath Path outputFilePath OutputPath // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share. installDirBase string installDirPath OutputPath additionalDependencies *Paths } Loading Loading @@ -124,7 +126,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) { return } p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir)) p.installDirPath = PathForModuleInstall(ctx, p.installDirBase, String(p.properties.Sub_dir)) // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. Loading Loading @@ -174,8 +176,9 @@ func InitPrebuiltEtcModule(p *PrebuiltEtc) { p.AddProperties(&p.properties) } // prebuilt_etc is for prebuilts that will be installed to <partition>/etc/<subdir> func PrebuiltEtcFactory() Module { module := &PrebuiltEtc{} module := &PrebuiltEtc{installDirBase: "etc"} InitPrebuiltEtcModule(module) // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) Loading @@ -183,13 +186,22 @@ func PrebuiltEtcFactory() Module { } func PrebuiltEtcHostFactory() Module { module := &PrebuiltEtc{} module := &PrebuiltEtc{installDirBase: "etc"} InitPrebuiltEtcModule(module) // This module is host-only InitAndroidArchModule(module, HostSupported, MultilibCommon) return module } // prebuilt_usr_share is for prebuilts that will be installed to <partition>/usr/share/<subdir> func PrebuiltUserShareFactory() Module { module := &PrebuiltEtc{installDirBase: "usr/share"} InitPrebuiltEtcModule(module) // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module } const ( // coreMode is the variant for modules to be installed to system. coreMode = "core" Loading android/prebuilt_etc_test.go +17 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ func testPrebuiltEtc(t *testing.T, bp string) *TestContext { ctx := NewTestArchContext() ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory)) ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory)) ctx.RegisterModuleType("prebuilt_usr_share", ModuleFactoryAdaptor(PrebuiltUserShareFactory)) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel() }) Loading Loading @@ -193,3 +194,19 @@ func TestPrebuiltEtcHost(t *testing.T) { t.Errorf("host bit is not set for a prebuilt_etc_host module.") } } func TestPrebuiltUserShareInstallDirPath(t *testing.T) { ctx := testPrebuiltEtc(t, ` prebuilt_usr_share { name: "foo.conf", src: "foo.conf", sub_dir: "bar", } `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/usr/share/bar" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) } } Loading
android/prebuilt_etc.go +19 −7 Original line number Diff line number Diff line Loading @@ -20,12 +20,12 @@ import ( "strings" ) // prebuilt_etc is for prebuilts that will be installed to // <partition>/etc/<subdir> // TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file. func init() { RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel() Loading Loading @@ -62,6 +62,8 @@ type PrebuiltEtc struct { sourceFilePath Path outputFilePath OutputPath // The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share. installDirBase string installDirPath OutputPath additionalDependencies *Paths } Loading Loading @@ -124,7 +126,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) { return } p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir)) p.installDirPath = PathForModuleInstall(ctx, p.installDirBase, String(p.properties.Sub_dir)) // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. Loading Loading @@ -174,8 +176,9 @@ func InitPrebuiltEtcModule(p *PrebuiltEtc) { p.AddProperties(&p.properties) } // prebuilt_etc is for prebuilts that will be installed to <partition>/etc/<subdir> func PrebuiltEtcFactory() Module { module := &PrebuiltEtc{} module := &PrebuiltEtc{installDirBase: "etc"} InitPrebuiltEtcModule(module) // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) Loading @@ -183,13 +186,22 @@ func PrebuiltEtcFactory() Module { } func PrebuiltEtcHostFactory() Module { module := &PrebuiltEtc{} module := &PrebuiltEtc{installDirBase: "etc"} InitPrebuiltEtcModule(module) // This module is host-only InitAndroidArchModule(module, HostSupported, MultilibCommon) return module } // prebuilt_usr_share is for prebuilts that will be installed to <partition>/usr/share/<subdir> func PrebuiltUserShareFactory() Module { module := &PrebuiltEtc{installDirBase: "usr/share"} InitPrebuiltEtcModule(module) // This module is device-only InitAndroidArchModule(module, DeviceSupported, MultilibFirst) return module } const ( // coreMode is the variant for modules to be installed to system. coreMode = "core" Loading
android/prebuilt_etc_test.go +17 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ func testPrebuiltEtc(t *testing.T, bp string) *TestContext { ctx := NewTestArchContext() ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory)) ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory)) ctx.RegisterModuleType("prebuilt_usr_share", ModuleFactoryAdaptor(PrebuiltUserShareFactory)) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel() }) Loading Loading @@ -193,3 +194,19 @@ func TestPrebuiltEtcHost(t *testing.T) { t.Errorf("host bit is not set for a prebuilt_etc_host module.") } } func TestPrebuiltUserShareInstallDirPath(t *testing.T) { ctx := testPrebuiltEtc(t, ` prebuilt_usr_share { name: "foo.conf", src: "foo.conf", sub_dir: "bar", } `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/usr/share/bar" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) } }