Loading androidmk/androidmk/androidmk_test.go +17 −17 Original line number Diff line number Diff line Loading @@ -876,7 +876,7 @@ include $(BUILD_PREBUILT) prebuilt_etc { name: "etc.test1", src: "mymod", sub_dir: "foo/bar", relative_install_path: "foo/bar", } `, Loading @@ -896,7 +896,7 @@ prebuilt_etc { name: "etc.test1", src: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", } `, Loading @@ -913,7 +913,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", device_specific: true, } Loading @@ -931,7 +931,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", product_specific: true, Loading @@ -950,7 +950,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", product_specific: true, } Loading @@ -968,7 +968,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", system_ext_specific: true, } Loading @@ -986,7 +986,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", system_ext_specific: true, Loading @@ -1005,7 +1005,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1023,7 +1023,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1041,7 +1041,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1059,7 +1059,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", recovery: true, } Loading Loading @@ -1098,7 +1098,7 @@ prebuilt_usr_share { name: "foo", src: "foo.txt", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading Loading @@ -1174,7 +1174,7 @@ prebuilt_usr_share_host { name: "foo", src: "foo.txt", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1193,7 +1193,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1212,7 +1212,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1231,7 +1231,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", proprietary: true, } `, Loading @@ -1251,7 +1251,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", proprietary: true, } `, Loading bpfix/bpfix/bpfix.go +3 −1 Original line number Diff line number Diff line Loading @@ -533,7 +533,7 @@ func (f etcPrebuiltModuleUpdate) update(m *parser.Module, path string) bool { updated = true } else if trimmedPath := strings.TrimPrefix(path, f.prefix+"/"); trimmedPath != path { m.Properties = append(m.Properties, &parser.Property{ Name: "sub_dir", Name: "relative_install_path", Value: &parser.String{Value: trimmedPath}, }) updated = true Loading Loading @@ -581,6 +581,8 @@ func rewriteAndroidmkPrebuiltEtc(f *Fixer) error { // 'srcs' --> 'src' conversion convertToSingleSource(mod, "src") renameProperty(mod, "sub_dir", "relative_install_dir") // The rewriter converts LOCAL_MODULE_PATH attribute into a struct attribute // 'local_module_path'. Analyze its contents and create the correct sub_dir:, // filename: and boolean attributes combination Loading bpfix/bpfix/bpfix_test.go +16 −0 Original line number Diff line number Diff line Loading @@ -742,6 +742,22 @@ func TestRewritePrebuiltEtc(t *testing.T) { } `, }, { name: "prebuilt_etc sub_dir", in: ` prebuilt_etc { name: "foo", src: "bar", sub_dir: "baz", } `, out: `prebuilt_etc { name: "foo", src: "bar", relative_install_dir: "baz", } `, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { Loading etc/prebuilt_etc.go +13 −3 Original line number Diff line number Diff line Loading @@ -42,9 +42,12 @@ type prebuiltEtcProperties struct { // Source file of this prebuilt. Src *string `android:"path,arch_variant"` // optional subdirectory under which this file is installed into // optional subdirectory under which this file is installed into, cannot be specified with relative_install_path, prefer relative_install_path Sub_dir *string `android:"arch_variant"` // optional subdirectory under which this file is installed into, cannot be specified with sub_dir Relative_install_path *string `android:"arch_variant"` // optional name for the installed file. If unspecified, name of the module is used as the file name Filename *string `android:"arch_variant"` Loading Loading @@ -158,7 +161,10 @@ func (p *PrebuiltEtc) OutputFile() android.OutputPath { } func (p *PrebuiltEtc) SubDir() string { return android.String(p.properties.Sub_dir) if subDir := proptools.String(p.properties.Sub_dir); subDir != "" { return subDir } return proptools.String(p.properties.Relative_install_path) } func (p *PrebuiltEtc) Installable() bool { Loading @@ -181,13 +187,17 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { } p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil { ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") } // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified // socInstallDirBase. installBaseDir := p.installDirBase if ctx.SocSpecific() && p.socInstallDirBase != "" { installBaseDir = p.socInstallDirBase } p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, proptools.String(p.properties.Sub_dir)) p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir()) // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. Loading etc/prebuilt_etc_test.go +54 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ func TestMain(m *testing.M) { os.Exit(run()) } func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) { func testPrebuiltEtcContext(t *testing.T, bp string) (*android.TestContext, android.Config) { fs := map[string][]byte{ "foo.conf": nil, "bar.conf": nil, Loading @@ -67,6 +67,14 @@ func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Con ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) ctx.Register(config) return ctx, config } func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) { t.Helper() ctx, config := testPrebuiltEtcContext(t, bp) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) Loading @@ -75,6 +83,24 @@ func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Con return ctx, config } func testPrebuiltEtcError(t *testing.T, pattern, bp string) { t.Helper() ctx, config := testPrebuiltEtcContext(t, bp) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) if len(errs) > 0 { android.FailIfNoMatchingErrors(t, pattern, errs) return } _, errs = ctx.PrepareBuildActions(config) if len(errs) > 0 { android.FailIfNoMatchingErrors(t, pattern, errs) return } t.Fatalf("missing expected error %q (0 errors are returned)", pattern) } func TestPrebuiltEtcVariants(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc { Loading Loading @@ -184,6 +210,33 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) { } } func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc { name: "foo.conf", src: "foo.conf", relative_install_path: "bar", } `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) expected := buildDir + "/target/product/test_device/system/etc/bar" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) { testPrebuiltEtcError(t, "relative_install_path is set. Cannot set sub_dir", ` prebuilt_etc { name: "foo.conf", src: "foo.conf", sub_dir: "bar", relative_install_path: "bar", } `) } func TestPrebuiltEtcHost(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc_host { Loading Loading
androidmk/androidmk/androidmk_test.go +17 −17 Original line number Diff line number Diff line Loading @@ -876,7 +876,7 @@ include $(BUILD_PREBUILT) prebuilt_etc { name: "etc.test1", src: "mymod", sub_dir: "foo/bar", relative_install_path: "foo/bar", } `, Loading @@ -896,7 +896,7 @@ prebuilt_etc { name: "etc.test1", src: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", } `, Loading @@ -913,7 +913,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", device_specific: true, } Loading @@ -931,7 +931,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", product_specific: true, Loading @@ -950,7 +950,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", product_specific: true, } Loading @@ -968,7 +968,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", system_ext_specific: true, } Loading @@ -986,7 +986,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", system_ext_specific: true, Loading @@ -1005,7 +1005,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1023,7 +1023,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1041,7 +1041,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", proprietary: true, } Loading @@ -1059,7 +1059,7 @@ include $(BUILD_PREBUILT) expected: ` prebuilt_etc { name: "etc.test1", sub_dir: "foo/bar", relative_install_path: "foo/bar", recovery: true, } Loading Loading @@ -1098,7 +1098,7 @@ prebuilt_usr_share { name: "foo", src: "foo.txt", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading Loading @@ -1174,7 +1174,7 @@ prebuilt_usr_share_host { name: "foo", src: "foo.txt", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1193,7 +1193,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1212,7 +1212,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", } `, }, Loading @@ -1231,7 +1231,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", proprietary: true, } `, Loading @@ -1251,7 +1251,7 @@ prebuilt_firmware { name: "foo", src: "foo.fw", sub_dir: "bar", relative_install_path: "bar", proprietary: true, } `, Loading
bpfix/bpfix/bpfix.go +3 −1 Original line number Diff line number Diff line Loading @@ -533,7 +533,7 @@ func (f etcPrebuiltModuleUpdate) update(m *parser.Module, path string) bool { updated = true } else if trimmedPath := strings.TrimPrefix(path, f.prefix+"/"); trimmedPath != path { m.Properties = append(m.Properties, &parser.Property{ Name: "sub_dir", Name: "relative_install_path", Value: &parser.String{Value: trimmedPath}, }) updated = true Loading Loading @@ -581,6 +581,8 @@ func rewriteAndroidmkPrebuiltEtc(f *Fixer) error { // 'srcs' --> 'src' conversion convertToSingleSource(mod, "src") renameProperty(mod, "sub_dir", "relative_install_dir") // The rewriter converts LOCAL_MODULE_PATH attribute into a struct attribute // 'local_module_path'. Analyze its contents and create the correct sub_dir:, // filename: and boolean attributes combination Loading
bpfix/bpfix/bpfix_test.go +16 −0 Original line number Diff line number Diff line Loading @@ -742,6 +742,22 @@ func TestRewritePrebuiltEtc(t *testing.T) { } `, }, { name: "prebuilt_etc sub_dir", in: ` prebuilt_etc { name: "foo", src: "bar", sub_dir: "baz", } `, out: `prebuilt_etc { name: "foo", src: "bar", relative_install_dir: "baz", } `, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { Loading
etc/prebuilt_etc.go +13 −3 Original line number Diff line number Diff line Loading @@ -42,9 +42,12 @@ type prebuiltEtcProperties struct { // Source file of this prebuilt. Src *string `android:"path,arch_variant"` // optional subdirectory under which this file is installed into // optional subdirectory under which this file is installed into, cannot be specified with relative_install_path, prefer relative_install_path Sub_dir *string `android:"arch_variant"` // optional subdirectory under which this file is installed into, cannot be specified with sub_dir Relative_install_path *string `android:"arch_variant"` // optional name for the installed file. If unspecified, name of the module is used as the file name Filename *string `android:"arch_variant"` Loading Loading @@ -158,7 +161,10 @@ func (p *PrebuiltEtc) OutputFile() android.OutputPath { } func (p *PrebuiltEtc) SubDir() string { return android.String(p.properties.Sub_dir) if subDir := proptools.String(p.properties.Sub_dir); subDir != "" { return subDir } return proptools.String(p.properties.Relative_install_path) } func (p *PrebuiltEtc) Installable() bool { Loading @@ -181,13 +187,17 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { } p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath if p.properties.Sub_dir != nil && p.properties.Relative_install_path != nil { ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir") } // If soc install dir was specified and SOC specific is set, set the installDirPath to the specified // socInstallDirBase. installBaseDir := p.installDirBase if ctx.SocSpecific() && p.socInstallDirBase != "" { installBaseDir = p.socInstallDirBase } p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, proptools.String(p.properties.Sub_dir)) p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir()) // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. Loading
etc/prebuilt_etc_test.go +54 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ func TestMain(m *testing.M) { os.Exit(run()) } func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) { func testPrebuiltEtcContext(t *testing.T, bp string) (*android.TestContext, android.Config) { fs := map[string][]byte{ "foo.conf": nil, "bar.conf": nil, Loading @@ -67,6 +67,14 @@ func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Con ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) ctx.Register(config) return ctx, config } func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) { t.Helper() ctx, config := testPrebuiltEtcContext(t, bp) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) Loading @@ -75,6 +83,24 @@ func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Con return ctx, config } func testPrebuiltEtcError(t *testing.T, pattern, bp string) { t.Helper() ctx, config := testPrebuiltEtcContext(t, bp) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) if len(errs) > 0 { android.FailIfNoMatchingErrors(t, pattern, errs) return } _, errs = ctx.PrepareBuildActions(config) if len(errs) > 0 { android.FailIfNoMatchingErrors(t, pattern, errs) return } t.Fatalf("missing expected error %q (0 errors are returned)", pattern) } func TestPrebuiltEtcVariants(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc { Loading Loading @@ -184,6 +210,33 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) { } } func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc { name: "foo.conf", src: "foo.conf", relative_install_path: "bar", } `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) expected := buildDir + "/target/product/test_device/system/etc/bar" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) { testPrebuiltEtcError(t, "relative_install_path is set. Cannot set sub_dir", ` prebuilt_etc { name: "foo.conf", src: "foo.conf", sub_dir: "bar", relative_install_path: "bar", } `) } func TestPrebuiltEtcHost(t *testing.T) { ctx, _ := testPrebuiltEtc(t, ` prebuilt_etc_host { Loading