Merge "Delete SyspropMutator (again)"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index e4760b5..872e6a0 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -161,6 +161,7 @@
"frameworks/av/media/codecs": Bp2BuildDefaultTrueRecursively,
"frameworks/av/media/liberror": Bp2BuildDefaultTrueRecursively,
"frameworks/av/services/minijail": Bp2BuildDefaultTrueRecursively,
+ "frameworks/av/media/module/minijail": Bp2BuildDefaultTrueRecursively,
"frameworks/base/media/tests/MediaDump": Bp2BuildDefaultTrue,
"frameworks/base/services/tests/servicestests/aidl": Bp2BuildDefaultTrue,
"frameworks/base/startop/apps/test": Bp2BuildDefaultTrue,
@@ -698,7 +699,6 @@
"libBionicCtsGtestMain", // depends on unconverted modules: libgtest_isolated
"libBionicLoaderTests", // depends on unconverted modules: libmeminfo
"libapexutil_tests", // depends on unconverted modules: apex-info-list-tinyxml, libapexutil
- "libavservices_minijail_unittest",
"libcutils_sockets_test",
"libexpectedutils_test",
"libhwbinder_latency",
diff --git a/android/androidmk.go b/android/androidmk.go
index 006e43d..18e3e7a 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -366,7 +366,9 @@
// Collate the contributions this module makes to the dist.
distContributions := &distContributions{}
- distContributions.licenseMetadataFile = amod.licenseMetadataFile
+ if !exemptFromRequiredApplicableLicensesProperty(mod.(Module)) {
+ distContributions.licenseMetadataFile = amod.licenseMetadataFile
+ }
// Iterate over this module's dist structs, merged from the dist and dists properties.
for _, dist := range amod.Dists() {
@@ -458,10 +460,12 @@
ret = append(ret, fmt.Sprintf(".PHONY: %s\n", d.goals))
// Create dist-for-goals calls for each of the copy instructions.
for _, c := range d.copies {
- ret = append(
- ret,
- fmt.Sprintf("$(if $(strip $(ALL_TARGETS.%s.META_LIC)),,$(eval ALL_TARGETS.%s.META_LIC := %s))\n",
- c.from.String(), c.from.String(), distContributions.licenseMetadataFile.String()))
+ if distContributions.licenseMetadataFile != nil {
+ ret = append(
+ ret,
+ fmt.Sprintf("$(if $(strip $(ALL_TARGETS.%s.META_LIC)),,$(eval ALL_TARGETS.%s.META_LIC := %s))\n",
+ c.from.String(), c.from.String(), distContributions.licenseMetadataFile.String()))
+ }
ret = append(
ret,
fmt.Sprintf("$(call dist-for-goals,%s,%s:%s)\n", d.goals, c.from.String(), c.dest))
diff --git a/android/apex.go b/android/apex.go
index 00b7241..3c945ae 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -454,8 +454,6 @@
}
return InList(what, apex_available) ||
(what != AvailableToPlatform && InList(AvailableToAnyApex, apex_available)) ||
- (what == "com.android.btservices" && InList("com.android.bluetooth", apex_available)) || // TODO b/243054261
- (what == "com.android.bluetooth" && InList("com.android.btservices", apex_available)) || // TODO b/243054261
(strings.HasPrefix(what, "com.android.gki.") && InList(AvailableToGkiApex, apex_available))
}
diff --git a/android/bazel.go b/android/bazel.go
index eb6aca4..dd1de7b 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -32,10 +32,13 @@
Bp2BuildTopLevel = "."
)
-// Bp2buildAidlLibrary describes a filegroup module that are converted to aidl_library
-type Bp2buildAidlLibrary interface {
+// FileGroupAsLibrary describes a filegroup module that is converted to some library
+// such as aidl_library or proto_library.
+type FileGroupAsLibrary interface {
ShouldConvertToAidlLibrary(ctx BazelConversionPathContext) bool
+ ShouldConvertToProtoLibrary(ctx BazelConversionPathContext) bool
GetAidlLibraryLabel(ctx BazelConversionPathContext) string
+ GetProtoLibraryLabel(ctx BazelConversionPathContext) string
}
type BazelConversionStatus struct {
@@ -443,8 +446,8 @@
if ok, directoryPath := bp2buildDefaultTrueRecursively(packagePath, allowlist.defaultConfig); ok {
if moduleNameAllowed {
ctx.ModuleErrorf("A module cannot be in a directory marked Bp2BuildDefaultTrue"+
- " or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: '%s'",
- directoryPath)
+ " or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: '%s'"+
+ " Module: '%s'", directoryPath, moduleName)
return false
}
diff --git a/android/bazel_test.go b/android/bazel_test.go
index b578cca..dbe6067 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -266,7 +266,7 @@
{
description: "module allowlist and enabled directory",
shouldConvert: false,
- expectedErrors: []string{"A module cannot be in a directory marked Bp2BuildDefaultTrue or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: 'existing/build/dir'"},
+ expectedErrors: []string{"A module cannot be in a directory marked Bp2BuildDefaultTrue or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: 'existing/build/dir' Module: 'foo'"},
module: TestBazelModule{
TestModuleInfo: bazel.TestModuleInfo{
ModuleName: "foo",
@@ -287,7 +287,7 @@
{
description: "module allowlist and enabled subdirectory",
shouldConvert: false,
- expectedErrors: []string{"A module cannot be in a directory marked Bp2BuildDefaultTrue or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: 'existing/build/dir'"},
+ expectedErrors: []string{"A module cannot be in a directory marked Bp2BuildDefaultTrue or Bp2BuildDefaultTrueRecursively and also be in moduleAlwaysConvert. Directory: 'existing/build/dir' Module: 'foo'"},
module: TestBazelModule{
TestModuleInfo: bazel.TestModuleInfo{
ModuleName: "foo",
diff --git a/android/filegroup.go b/android/filegroup.go
index e609f63..6b11172 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -33,6 +33,8 @@
ctx.RegisterModuleType("filegroup", FileGroupFactory)
})
+var convertedProtoLibrarySuffix = "_bp2build_converted"
+
// IsFilegroup checks that a module is a filegroup type
func IsFilegroup(ctx bazel.OtherModuleContext, m blueprint.Module) bool {
return ctx.OtherModuleType(m) == "filegroup"
@@ -117,6 +119,24 @@
ctx.CreateBazelTargetModule(props, CommonAttributes{Name: fg.Name()}, attrs)
} else {
+ if fg.ShouldConvertToProtoLibrary(ctx) {
+ // TODO(b/246997908): we can remove this tag if we could figure out a
+ // solution for this bug.
+ tags := []string{"manual"}
+ attrs := &ProtoAttrs{
+ Srcs: srcs,
+ Strip_import_prefix: fg.properties.Path,
+ Tags: tags,
+ }
+
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
+ CommonAttributes{Name: fg.Name() + convertedProtoLibrarySuffix},
+ attrs)
+ }
+
+ // TODO(b/242847534): Still convert to a filegroup because other unconverted
+ // modules may depend on the filegroup
attrs := &bazelFilegroupAttributes{
Srcs: srcs,
}
@@ -150,14 +170,14 @@
type fileGroup struct {
ModuleBase
BazelModuleBase
- Bp2buildAidlLibrary
+ FileGroupAsLibrary
properties fileGroupProperties
srcs Paths
}
var _ MixedBuildBuildable = (*fileGroup)(nil)
var _ SourceFileProducer = (*fileGroup)(nil)
-var _ Bp2buildAidlLibrary = (*fileGroup)(nil)
+var _ FileGroupAsLibrary = (*fileGroup)(nil)
// filegroup contains a list of files that are referenced by other modules
// properties (such as "srcs") using the syntax ":<name>". filegroup are
@@ -243,11 +263,19 @@
}
func (fg *fileGroup) ShouldConvertToAidlLibrary(ctx BazelConversionPathContext) bool {
+ return fg.shouldConvertToLibrary(ctx, ".aidl")
+}
+
+func (fg *fileGroup) ShouldConvertToProtoLibrary(ctx BazelConversionPathContext) bool {
+ return fg.shouldConvertToLibrary(ctx, ".proto")
+}
+
+func (fg *fileGroup) shouldConvertToLibrary(ctx BazelConversionPathContext, suffix string) bool {
if len(fg.properties.Srcs) == 0 || !fg.ShouldConvertWithBp2build(ctx) {
return false
}
for _, src := range fg.properties.Srcs {
- if !strings.HasSuffix(src, ".aidl") {
+ if !strings.HasSuffix(src, suffix) {
return false
}
}
@@ -255,6 +283,14 @@
}
func (fg *fileGroup) GetAidlLibraryLabel(ctx BazelConversionPathContext) string {
+ return fg.getFileGroupAsLibraryLabel(ctx)
+}
+
+func (fg *fileGroup) GetProtoLibraryLabel(ctx BazelConversionPathContext) string {
+ return fg.getFileGroupAsLibraryLabel(ctx) + convertedProtoLibrarySuffix
+}
+
+func (fg *fileGroup) getFileGroupAsLibraryLabel(ctx BazelConversionPathContext) string {
if ctx.OtherModuleDir(fg.module) == ctx.ModuleDir() {
return ":" + fg.Name()
} else {
@@ -265,12 +301,19 @@
// Given a name in srcs prop, check to see if the name references a filegroup
// and the filegroup is converted to aidl_library
func IsConvertedToAidlLibrary(ctx BazelConversionPathContext, name string) bool {
+ if fg, ok := ToFileGroupAsLibrary(ctx, name); ok {
+ return fg.ShouldConvertToAidlLibrary(ctx)
+ }
+ return false
+}
+
+func ToFileGroupAsLibrary(ctx BazelConversionPathContext, name string) (FileGroupAsLibrary, bool) {
if module, ok := ctx.ModuleFromName(name); ok {
if IsFilegroup(ctx, module) {
- if fg, ok := module.(Bp2buildAidlLibrary); ok {
- return fg.ShouldConvertToAidlLibrary(ctx)
+ if fg, ok := module.(FileGroupAsLibrary); ok {
+ return fg, true
}
}
}
- return false
+ return nil, false
}
diff --git a/android/gen_notice.go b/android/gen_notice.go
index 2eb6bec..008aac5 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -111,6 +111,9 @@
}
func (m *genNoticeModule) DepsMutator(ctx BottomUpMutatorContext) {
+ if ctx.ContainsProperty("licenses") {
+ ctx.PropertyErrorf("licenses", "not supported on \"gen_notice\" modules")
+ }
if proptools.Bool(m.properties.Html) && proptools.Bool(m.properties.Xml) {
ctx.ModuleErrorf("can be html or xml but not both")
}
@@ -195,6 +198,16 @@
return nil, fmt.Errorf("unrecognized tag %q", tag)
}
+var _ AndroidMkEntriesProvider = (*genNoticeModule)(nil)
+
+// Implements AndroidMkEntriesProvider
+func (m *genNoticeModule) AndroidMkEntries() []AndroidMkEntries {
+ return []AndroidMkEntries{AndroidMkEntries{
+ Class: "ETC",
+ OutputFile: OptionalPathForPath(m.output),
+ }}
+}
+
// missingReferencesRule emits an ErrorRule for missing module references.
func missingReferencesRule(ctx BuilderContext, m *genNoticeModule) {
if len(m.missing) < 1 {
diff --git a/android/gen_notice_test.go b/android/gen_notice_test.go
index b45ce4f..99d982b 100644
--- a/android/gen_notice_test.go
+++ b/android/gen_notice_test.go
@@ -12,6 +12,19 @@
expectedErrors []string
}{
{
+ name: "gen_notice must not accept licenses property",
+ fs: map[string][]byte{
+ "top/Android.bp": []byte(`
+ gen_notice {
+ name: "top_license",
+ licenses: ["other_license"],
+ }`),
+ },
+ expectedErrors: []string{
+ `not supported on "gen_notice" modules`,
+ },
+ },
+ {
name: "bad gen_notice",
fs: map[string][]byte{
"top/Android.bp": []byte(`
diff --git a/android/proto.go b/android/proto.go
index 25cecf4..3cac9a1 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -155,14 +155,16 @@
// Bp2buildProtoInfo contains information necessary to pass on to language specific conversion.
type Bp2buildProtoInfo struct {
- Type *string
- Name string
+ Type *string
+ Name string
+ Proto_libs bazel.LabelList
}
-type protoAttrs struct {
+type ProtoAttrs struct {
Srcs bazel.LabelListAttribute
Strip_import_prefix *string
Deps bazel.LabelListAttribute
+ Tags []string
}
// For each package in the include_dirs property a proto_library target should
@@ -179,44 +181,71 @@
return info, false
}
- info.Name = m.Name() + "_proto"
- attrs := protoAttrs{
- Srcs: srcs,
- }
+ var protoLibraries bazel.LabelList
+ var directProtoSrcs bazel.LabelList
- for axis, configToProps := range m.GetArchVariantProperties(ctx, &ProtoProperties{}) {
- for _, rawProps := range configToProps {
- var props *ProtoProperties
- var ok bool
- if props, ok = rawProps.(*ProtoProperties); !ok {
- ctx.ModuleErrorf("Could not cast ProtoProperties to expected type")
- }
- if axis == bazel.NoConfigAxis {
- info.Type = props.Proto.Type
-
- if !proptools.BoolDefault(props.Proto.Canonical_path_from_root, canonicalPathFromRootDefault) {
- // an empty string indicates to strips the package path
- path := ""
- attrs.Strip_import_prefix = &path
- }
-
- for _, dir := range props.Proto.Include_dirs {
- if dep, ok := includeDirsToProtoDeps[dir]; ok {
- attrs.Deps.Add(bazel.MakeLabelAttribute(dep))
- } else {
- ctx.PropertyErrorf("Could not find the proto_library target for include dir", dir)
- }
- }
- } else if props.Proto.Type != info.Type && props.Proto.Type != nil {
- ctx.ModuleErrorf("Cannot handle arch-variant types for protos at this time.")
- }
+ // For filegroups that should be converted to proto_library just collect the
+ // labels of converted proto_library targets.
+ for _, protoSrc := range srcs.Value.Includes {
+ src := protoSrc.OriginalModuleName
+ if fg, ok := ToFileGroupAsLibrary(ctx, src); ok &&
+ fg.ShouldConvertToProtoLibrary(ctx) {
+ protoLibraries.Add(&bazel.Label{
+ Label: fg.GetProtoLibraryLabel(ctx),
+ })
+ } else {
+ directProtoSrcs.Add(&protoSrc)
}
}
- ctx.CreateBazelTargetModule(
- bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
- CommonAttributes{Name: info.Name},
- &attrs)
+ info.Name = m.Name() + "_proto"
+
+ if len(directProtoSrcs.Includes) > 0 {
+ attrs := ProtoAttrs{
+ Srcs: bazel.MakeLabelListAttribute(directProtoSrcs),
+ }
+ attrs.Deps.Append(bazel.MakeLabelListAttribute(protoLibraries))
+
+ for axis, configToProps := range m.GetArchVariantProperties(ctx, &ProtoProperties{}) {
+ for _, rawProps := range configToProps {
+ var props *ProtoProperties
+ var ok bool
+ if props, ok = rawProps.(*ProtoProperties); !ok {
+ ctx.ModuleErrorf("Could not cast ProtoProperties to expected type")
+ }
+ if axis == bazel.NoConfigAxis {
+ info.Type = props.Proto.Type
+
+ if !proptools.BoolDefault(props.Proto.Canonical_path_from_root, canonicalPathFromRootDefault) {
+ // an empty string indicates to strips the package path
+ path := ""
+ attrs.Strip_import_prefix = &path
+ }
+
+ for _, dir := range props.Proto.Include_dirs {
+ if dep, ok := includeDirsToProtoDeps[dir]; ok {
+ attrs.Deps.Add(bazel.MakeLabelAttribute(dep))
+ } else {
+ ctx.PropertyErrorf("Could not find the proto_library target for include dir", dir)
+ }
+ }
+ } else if props.Proto.Type != info.Type && props.Proto.Type != nil {
+ ctx.ModuleErrorf("Cannot handle arch-variant types for protos at this time.")
+ }
+ }
+ }
+
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
+ CommonAttributes{Name: info.Name},
+ &attrs)
+
+ protoLibraries.Add(&bazel.Label{
+ Label: ":" + info.Name,
+ })
+ }
+
+ info.Proto_libs = protoLibraries
return info, true
}
diff --git a/apex/apex.go b/apex/apex.go
index 949809a..2e54e7e 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3054,36 +3054,6 @@
//
// Module separator
//
- m["com.android.bluetooth"] = []string{
- "bluetooth-protos-lite",
- "internal_include_headers",
- "libaudio-a2dp-hw-utils",
- "libaudio-hearing-aid-hw-utils",
- "libbluetooth",
- "libbluetooth-types",
- "libbluetooth-types-header",
- "libbluetooth_gd",
- "libbluetooth_headers",
- "libbluetooth_jni",
- "libbt-audio-hal-interface",
- "libbt-bta",
- "libbt-common",
- "libbt-hci",
- "libbt-platform-protos-lite",
- "libbt-protos-lite",
- "libbt-sbc-decoder",
- "libbt-sbc-encoder",
- "libbt-stack",
- "libbt-utils",
- "libbtcore",
- "libbtdevice",
- "libbte",
- "libbtif",
- "libchrome",
- }
- //
- // Module separator
- //
m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
//
// Module separator
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 880ae75..12cffc3 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2261,6 +2261,134 @@
})
}
+func TestCcLibraryConvertedProtoFilegroups(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcProtoPreamble + `
+filegroup {
+ name: "a_fg_proto",
+ srcs: ["a_fg.proto"],
+}
+
+cc_library {
+ name: "a",
+ srcs: [
+ ":a_fg_proto",
+ "a.proto",
+ ],
+ proto: {
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("proto_library", "a_proto", AttrNameToString{
+ "deps": `[":a_fg_proto_bp2build_converted"]`,
+ "srcs": `["a.proto"]`,
+ }), MakeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", AttrNameToString{
+ "deps": `[
+ ":a_fg_proto_bp2build_converted",
+ ":a_proto",
+ ]`,
+ }), MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }), MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }), MakeBazelTargetNoRestrictions("proto_library", "a_fg_proto_bp2build_converted", AttrNameToString{
+ "srcs": `["a_fg.proto"]`,
+ "tags": `["manual"]`,
+ }), MakeBazelTargetNoRestrictions("filegroup", "a_fg_proto", AttrNameToString{
+ "srcs": `["a_fg.proto"]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryConvertedProtoFilegroupsNoProtoFiles(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcProtoPreamble + `
+filegroup {
+ name: "a_fg_proto",
+ srcs: ["a_fg.proto"],
+}
+
+cc_library {
+ name: "a",
+ srcs: [
+ ":a_fg_proto",
+ ],
+ proto: {
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", AttrNameToString{
+ "deps": `[":a_fg_proto_bp2build_converted"]`,
+ }), MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }), MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }), MakeBazelTargetNoRestrictions("proto_library", "a_fg_proto_bp2build_converted", AttrNameToString{
+ "srcs": `["a_fg.proto"]`,
+ "tags": `["manual"]`,
+ }), MakeBazelTargetNoRestrictions("filegroup", "a_fg_proto", AttrNameToString{
+ "srcs": `["a_fg.proto"]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryExternalConvertedProtoFilegroups(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Filesystem: map[string]string{
+ "path/to/A/Android.bp": `
+filegroup {
+ name: "a_fg_proto",
+ srcs: ["a_fg.proto"],
+}`,
+ },
+ Blueprint: soongCcProtoPreamble + `
+cc_library {
+ name: "a",
+ srcs: [
+ ":a_fg_proto",
+ "a.proto",
+ ],
+ proto: {
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("proto_library", "a_proto", AttrNameToString{
+ "deps": `["//path/to/A:a_fg_proto_bp2build_converted"]`,
+ "srcs": `["a.proto"]`,
+ }), MakeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", AttrNameToString{
+ "deps": `[
+ "//path/to/A:a_fg_proto_bp2build_converted",
+ ":a_proto",
+ ]`,
+ }), MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }), MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ }),
+ },
+ })
+}
+
func TestCcLibraryProtoFilegroups(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library",
diff --git a/bp2build/filegroup_conversion_test.go b/bp2build/filegroup_conversion_test.go
index de09a17..e978fb3 100644
--- a/bp2build/filegroup_conversion_test.go
+++ b/bp2build/filegroup_conversion_test.go
@@ -15,10 +15,10 @@
package bp2build
import (
- "android/soong/android"
"fmt"
-
"testing"
+
+ "android/soong/android"
)
func runFilegroupTestCase(t *testing.T, tc Bp2buildTestCase) {
@@ -121,3 +121,44 @@
]`}),
}})
}
+
+func TestFilegroupWithProtoSrcs(t *testing.T) {
+ runFilegroupTestCase(t, Bp2buildTestCase{
+ Description: "filegroup with proto and non-proto srcs",
+ Filesystem: map[string]string{},
+ Blueprint: `
+filegroup {
+ name: "foo",
+ srcs: ["proto/foo.proto"],
+ path: "proto",
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("proto_library", "foo_bp2build_converted", AttrNameToString{
+ "srcs": `["proto/foo.proto"]`,
+ "strip_import_prefix": `"proto"`,
+ "tags": `["manual"]`}),
+ MakeBazelTargetNoRestrictions("filegroup", "foo", AttrNameToString{
+ "srcs": `["proto/foo.proto"]`}),
+ }})
+}
+
+func TestFilegroupWithProtoAndNonProtoSrcs(t *testing.T) {
+ runFilegroupTestCase(t, Bp2buildTestCase{
+ Description: "filegroup with proto and non-proto srcs",
+ Filesystem: map[string]string{},
+ Blueprint: `
+filegroup {
+ name: "foo",
+ srcs: [
+ "foo.proto",
+ "buf.cpp",
+ ],
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("filegroup", "foo", AttrNameToString{
+ "srcs": `[
+ "foo.proto",
+ "buf.cpp",
+ ]`}),
+ }})
+}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index e001d24..51d8e22 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -79,10 +79,10 @@
if !exists || !android.IsFilegroup(otherModuleCtx, m) {
return labelStr, false
}
- // If the filegroup is already converted to aidl_library, skip creating
- // _c_srcs, _as_srcs, _cpp_srcs filegroups
- fg, _ := m.(android.Bp2buildAidlLibrary)
- if fg.ShouldConvertToAidlLibrary(ctx) {
+ // If the filegroup is already converted to aidl_library or proto_library,
+ // skip creating _c_srcs, _as_srcs, _cpp_srcs filegroups
+ fg, _ := m.(android.FileGroupAsLibrary)
+ if fg.ShouldConvertToAidlLibrary(ctx) || fg.ShouldConvertToProtoLibrary(ctx) {
return labelStr, false
}
return labelStr + suffix, true
@@ -506,19 +506,6 @@
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), anySrcs
}
-// Given a name in srcs prop, check to see if the name references a filegroup
-// and the filegroup is converted to aidl_library
-func isConvertedToAidlLibrary(ctx android.BazelConversionPathContext, name string) bool {
- if module, ok := ctx.ModuleFromName(name); ok {
- if android.IsFilegroup(ctx, module) {
- if fg, ok := module.(android.Bp2buildAidlLibrary); ok {
- return fg.ShouldConvertToAidlLibrary(ctx)
- }
- }
- }
- return false
-}
-
func bp2buildStdVal(std *string, prefix string, useGnu bool) *string {
defaultVal := prefix + "_std_default"
// If c{,pp}std properties are not specified, don't generate them in the BUILD file.
@@ -770,9 +757,8 @@
// Make a list of labels that correspond to filegroups that are already converted to aidl_library
for _, aidlSrc := range aidlSrcs.Value.Includes {
src := aidlSrc.OriginalModuleName
- if isConvertedToAidlLibrary(ctx, src) {
- module, _ := ctx.ModuleFromName(src)
- fg, _ := module.(android.Bp2buildAidlLibrary)
+ if fg, ok := android.ToFileGroupAsLibrary(ctx, src); ok &&
+ fg.ShouldConvertToAidlLibrary(ctx) {
aidlLibraries.Add(&bazel.Label{
Label: fg.GetAidlLibraryLabel(ctx),
})
diff --git a/cc/config/global.go b/cc/config/global.go
index f920471..a7701b9 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -316,9 +316,6 @@
"device/",
"vendor/",
}
-
- // Directories with warnings from Android.mk files.
- WarningAllowedOldProjects = []string{}
)
// BazelCcToolchainVars generates bzl file content containing variables for
diff --git a/cc/makevars.go b/cc/makevars.go
index 8154436..de8a8f2 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -53,7 +53,6 @@
func makeStringOfWarningAllowedProjects() string {
allProjects := append([]string{}, config.WarningAllowedProjects...)
- allProjects = append(allProjects, config.WarningAllowedOldProjects...)
sort.Strings(allProjects)
// Makefile rules use pattern "path/%" to match module paths.
if len(allProjects) > 0 {
diff --git a/cc/proto.go b/cc/proto.go
index 8e6d5ed..cf5ed04 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -178,7 +178,7 @@
var ret bp2buildProtoDeps
protoInfo, ok := android.Bp2buildProtoProperties(ctx, &m.ModuleBase, protoSrcs)
- if !ok {
+ if !ok || protoInfo.Proto_libs.IsEmpty() {
return ret
}
@@ -201,9 +201,8 @@
dep := android.BazelLabelForModuleDepSingle(ctx, depName)
ret.protoDep = &bazel.LabelAttribute{Value: &dep}
- protoLabel := bazel.Label{Label: ":" + protoInfo.Name}
var protoAttrs protoAttributes
- protoAttrs.Deps.SetValue(bazel.LabelList{Includes: []bazel.Label{protoLabel}})
+ protoAttrs.Deps.SetValue(protoInfo.Proto_libs)
name := m.Name() + suffix
diff --git a/cmd/extract_apks/main.go b/cmd/extract_apks/main.go
index 1cf64de..d200502 100644
--- a/cmd/extract_apks/main.go
+++ b/cmd/extract_apks/main.go
@@ -75,7 +75,7 @@
return nil, err
}
bytes := make([]byte, tocFile.FileHeader.UncompressedSize64)
- if _, err := rc.Read(bytes); err != io.EOF {
+ if _, err := rc.Read(bytes); err != nil && err != io.EOF {
return nil, err
}
rc.Close()
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index d8011d6..fdfd22e 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -201,6 +201,11 @@
if apex := global.AllApexSystemServerJars(ctx).ApexOfJar(lib); apex != "" {
return fmt.Sprintf("/apex/%s/javalib/%s.jar", apex, lib)
}
+
+ if apex := global.AllPlatformSystemServerJars(ctx).ApexOfJar(lib); apex == "system_ext" {
+ return fmt.Sprintf("/system_ext/framework/%s.jar", lib)
+ }
+
return fmt.Sprintf("/system/framework/%s.jar", lib)
}
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index 07e4fad..429b5ff 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -59,6 +59,15 @@
android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
}
+func testSystemExtSystemServerModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
+ return createTestModuleConfig(
+ name,
+ fmt.Sprintf("/system_ext/framework/%s.jar", name),
+ android.PathForOutput(ctx, fmt.Sprintf("%s/dexpreopt/%s.jar", name, name)),
+ android.PathForOutput(ctx, fmt.Sprintf("%s/aligned/%s.jar", name, name)),
+ android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
+}
+
func createTestModuleConfig(name, dexLocation string, buildPath, dexPath, enforceUsesLibrariesStatusFile android.OutputPath) *ModuleConfig {
return &ModuleConfig{
Name: name,
@@ -213,6 +222,29 @@
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
}
+func TestDexPreoptSystemExtSystemServerJars(t *testing.T) {
+ config := android.TestConfig("out", nil, "", nil)
+ ctx := android.BuilderContextForTesting(config)
+ globalSoong := globalSoongConfigForTests()
+ global := GlobalConfigForTests(ctx)
+ module := testSystemExtSystemServerModuleConfig(ctx, "service-A")
+
+ global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(
+ []string{"system_ext:service-A"})
+
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ wantInstalls := android.RuleBuilderInstalls{
+ {android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system_ext/framework/oat/arm/service-A.odex"},
+ {android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system_ext/framework/oat/arm/service-A.vdex"},
+ }
+
+ android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
+}
+
func TestDexPreoptApexStandaloneSystemServerJars(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
ctx := android.BuilderContextForTesting(config)
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 9316807..42a11fb 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -840,22 +840,7 @@
// isTestFragment returns true if the current module is a test bootclasspath_fragment.
func (b *BootclasspathFragmentModule) isTestFragment() bool {
- if b.testFragment {
- return true
- }
-
- // TODO(b/194063708): Once test fragments all use bootclasspath_fragment_test
- // Some temporary exceptions until all test fragments use the
- // bootclasspath_fragment_test module type.
- name := b.BaseModuleName()
- if strings.HasPrefix(name, "test_") {
- return true
- }
- if name == "apex.apexd_test_bootclasspath-fragment" {
- return true
- }
-
- return false
+ return b.testFragment
}
// produceHiddenAPIOutput produces the hidden API all-flags.csv file (and supporting files)
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index c63df59..2541f14 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -408,22 +408,6 @@
},
}
- bootclasspath_fragment {
- name: "test_fragment",
- contents: ["mysdklibrary"],
- hidden_api: {
- split_packages: [],
- },
- }
-
- bootclasspath_fragment {
- name: "apex.apexd_test_bootclasspath-fragment",
- contents: ["mysdklibrary"],
- hidden_api: {
- split_packages: [],
- },
- }
-
bootclasspath_fragment_test {
name: "a_test_fragment",
contents: ["mysdklibrary"],
@@ -445,12 +429,6 @@
fragment := result.Module("myfragment", "android_common").(*BootclasspathFragmentModule)
android.AssertBoolEquals(t, "not a test fragment", false, fragment.isTestFragment())
- fragment = result.Module("test_fragment", "android_common").(*BootclasspathFragmentModule)
- android.AssertBoolEquals(t, "is a test fragment by prefix", true, fragment.isTestFragment())
-
fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment())
-
- fragment = result.Module("apex.apexd_test_bootclasspath-fragment", "android_common").(*BootclasspathFragmentModule)
- android.AssertBoolEquals(t, "is a test fragment by name", true, fragment.isTestFragment())
}