Loading android/allowlists/allowlists.go +5 −1 Original line number Diff line number Diff line Loading @@ -761,6 +761,11 @@ var ( // aidl "aidl", "libaidl-common", // java_resources containing only a single filegroup "libauto_value_plugin", "auto_value_plugin_resources", "auto_value_extension", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading Loading @@ -835,7 +840,6 @@ var ( "libprotobuf-internal-python-srcs", // TODO(b/210751803), we don't handle path property for filegroups "libprotobuf-java-full", // TODO(b/210751803), we don't handle path property for filegroups "libprotobuf-java-util-full", // TODO(b/210751803), we don't handle path property for filegroups "auto_value_plugin_resources", // TODO(b/210751803), we don't handle path property for filegroups // go deps: "analyze_bcpf", // depends on bpmodify a blueprint_go_binary. Loading android/filegroup.go +13 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,17 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { } } type FileGroupPath interface { GetPath(ctx TopDownMutatorContext) string } func (fg *fileGroup) GetPath(ctx TopDownMutatorContext) string { if fg.properties.Path != nil { return *fg.properties.Path } return "" } type fileGroupProperties struct { // srcs lists files that will be included in this filegroup Srcs []string `android:"path"` Loading Loading @@ -207,6 +218,7 @@ type fileGroup struct { BazelModuleBase DefaultableModuleBase FileGroupAsLibrary FileGroupPath properties fileGroupProperties srcs Paths } Loading @@ -214,6 +226,7 @@ type fileGroup struct { var _ MixedBuildBuildable = (*fileGroup)(nil) var _ SourceFileProducer = (*fileGroup)(nil) var _ FileGroupAsLibrary = (*fileGroup)(nil) var _ FileGroupPath = (*fileGroup)(nil) // filegroup contains a list of files that are referenced by other modules // properties (such as "srcs") using the syntax ":<name>". filegroup are Loading bp2build/java_library_conversion_test.go +40 −0 Original line number Diff line number Diff line Loading @@ -826,3 +826,43 @@ func TestJavaLibraryArchVariantSrcsWithExcludes(t *testing.T) { }, }) } func TestJavaLibraryJavaResourcesSingleFilegroup(t *testing.T) { runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{ Filesystem: map[string]string{ "res/a.res": "", "res/b.res": "", "res/dir1/b.res": "", }, Description: "java_library", Blueprint: `java_library { name: "java-lib-1", srcs: ["a.java"], java_resources: [":filegroup1"], bazel_module: { bp2build_available: true }, } filegroup { name: "filegroup1", path: "foo", srcs: ["foo/a", "foo/b"], } `, ExpectedBazelTargets: []string{ MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{ "srcs": `["a.java"]`, "resources": `[":filegroup1"]`, "resource_strip_prefix": `"foo"`, }), MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"), MakeBazelTargetNoRestrictions("filegroup", "filegroup1", AttrNameToString{ "srcs": `[ "foo/a", "foo/b", ]`}), }, }, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }) } java/java.go +14 −1 Original line number Diff line number Diff line Loading @@ -2704,6 +2704,15 @@ type javaResourcesAttributes struct { Resource_strip_prefix *string } func (m *Library) javaResourcesGetSingleFilegroupStripPrefix(ctx android.TopDownMutatorContext) (string, bool) { if otherM, ok := ctx.ModuleFromName(m.properties.Java_resources[0]); ok && len(m.properties.Java_resources) == 1 { if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup { return filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx)), true } } return "", false } func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes { var resources bazel.LabelList var resourceStripPrefix *string Loading @@ -2713,9 +2722,13 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte } if m.properties.Java_resources != nil { resources.Append(android.BazelLabelForModuleSrc(ctx, m.properties.Java_resources)) if prefix, ok := m.javaResourcesGetSingleFilegroupStripPrefix(ctx); ok { resourceStripPrefix = proptools.StringPtr(prefix) } else { resourceStripPrefix = proptools.StringPtr(ctx.ModuleDir()) } resources.Append(android.BazelLabelForModuleSrc(ctx, m.properties.Java_resources)) } //TODO(b/179889880) handle case where glob includes files outside package resDeps := ResourceDirsToFiles( Loading Loading
android/allowlists/allowlists.go +5 −1 Original line number Diff line number Diff line Loading @@ -761,6 +761,11 @@ var ( // aidl "aidl", "libaidl-common", // java_resources containing only a single filegroup "libauto_value_plugin", "auto_value_plugin_resources", "auto_value_extension", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading Loading @@ -835,7 +840,6 @@ var ( "libprotobuf-internal-python-srcs", // TODO(b/210751803), we don't handle path property for filegroups "libprotobuf-java-full", // TODO(b/210751803), we don't handle path property for filegroups "libprotobuf-java-util-full", // TODO(b/210751803), we don't handle path property for filegroups "auto_value_plugin_resources", // TODO(b/210751803), we don't handle path property for filegroups // go deps: "analyze_bcpf", // depends on bpmodify a blueprint_go_binary. Loading
android/filegroup.go +13 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,17 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { } } type FileGroupPath interface { GetPath(ctx TopDownMutatorContext) string } func (fg *fileGroup) GetPath(ctx TopDownMutatorContext) string { if fg.properties.Path != nil { return *fg.properties.Path } return "" } type fileGroupProperties struct { // srcs lists files that will be included in this filegroup Srcs []string `android:"path"` Loading Loading @@ -207,6 +218,7 @@ type fileGroup struct { BazelModuleBase DefaultableModuleBase FileGroupAsLibrary FileGroupPath properties fileGroupProperties srcs Paths } Loading @@ -214,6 +226,7 @@ type fileGroup struct { var _ MixedBuildBuildable = (*fileGroup)(nil) var _ SourceFileProducer = (*fileGroup)(nil) var _ FileGroupAsLibrary = (*fileGroup)(nil) var _ FileGroupPath = (*fileGroup)(nil) // filegroup contains a list of files that are referenced by other modules // properties (such as "srcs") using the syntax ":<name>". filegroup are Loading
bp2build/java_library_conversion_test.go +40 −0 Original line number Diff line number Diff line Loading @@ -826,3 +826,43 @@ func TestJavaLibraryArchVariantSrcsWithExcludes(t *testing.T) { }, }) } func TestJavaLibraryJavaResourcesSingleFilegroup(t *testing.T) { runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{ Filesystem: map[string]string{ "res/a.res": "", "res/b.res": "", "res/dir1/b.res": "", }, Description: "java_library", Blueprint: `java_library { name: "java-lib-1", srcs: ["a.java"], java_resources: [":filegroup1"], bazel_module: { bp2build_available: true }, } filegroup { name: "filegroup1", path: "foo", srcs: ["foo/a", "foo/b"], } `, ExpectedBazelTargets: []string{ MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{ "srcs": `["a.java"]`, "resources": `[":filegroup1"]`, "resource_strip_prefix": `"foo"`, }), MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"), MakeBazelTargetNoRestrictions("filegroup", "filegroup1", AttrNameToString{ "srcs": `[ "foo/a", "foo/b", ]`}), }, }, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }) }
java/java.go +14 −1 Original line number Diff line number Diff line Loading @@ -2704,6 +2704,15 @@ type javaResourcesAttributes struct { Resource_strip_prefix *string } func (m *Library) javaResourcesGetSingleFilegroupStripPrefix(ctx android.TopDownMutatorContext) (string, bool) { if otherM, ok := ctx.ModuleFromName(m.properties.Java_resources[0]); ok && len(m.properties.Java_resources) == 1 { if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup { return filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx)), true } } return "", false } func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes { var resources bazel.LabelList var resourceStripPrefix *string Loading @@ -2713,9 +2722,13 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte } if m.properties.Java_resources != nil { resources.Append(android.BazelLabelForModuleSrc(ctx, m.properties.Java_resources)) if prefix, ok := m.javaResourcesGetSingleFilegroupStripPrefix(ctx); ok { resourceStripPrefix = proptools.StringPtr(prefix) } else { resourceStripPrefix = proptools.StringPtr(ctx.ModuleDir()) } resources.Append(android.BazelLabelForModuleSrc(ctx, m.properties.Java_resources)) } //TODO(b/179889880) handle case where glob includes files outside package resDeps := ResourceDirsToFiles( Loading