Merge "Fixed error return condition when the toc is read."
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index a39c368..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,
@@ -181,6 +182,7 @@
"hardware/interfaces/configstore/1.0": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/1.1": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/utils": Bp2BuildDefaultTrue,
+ "hardware/interfaces/graphics/allocator/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/2.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/3.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/4.0": Bp2BuildDefaultTrue,
@@ -222,6 +224,7 @@
"packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
"packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
"packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
+ "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
"packages/screensavers/Basic": Bp2BuildDefaultTrue,
"packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
@@ -331,6 +334,7 @@
"code_coverage.policy",
"code_coverage.policy.other",
"codec2_soft_exports",
+ "codecs_g711dec",
"com.android.media.swcodec-androidManifest",
"com.android.media.swcodec-ld.config.txt",
"com.android.media.swcodec-mediaswcodec.rc",
@@ -342,6 +346,7 @@
"flatbuffer_headers",
"gemmlowp_headers",
"gl_headers",
+ "libaidlcommonsupport",
"libandroid_runtime_lazy",
"libandroid_runtime_vm_headers",
"libaudioclient_aidl_conversion_util",
@@ -350,6 +355,7 @@
"libbinder_aidl",
"libbinder_headers",
"libbinder_headers_platform_shared",
+ "libbinderthreadstateutils",
"libbluetooth-types-header",
"libbufferhub_headers",
"libcodec2",
@@ -359,6 +365,10 @@
"libdvr_headers",
"libgsm",
"libgui_bufferqueue_sources",
+ "libgrallocusage",
+ "libgralloctypes",
+ "libnativewindow",
+ "libgraphicsenv",
"libhardware",
"libhardware_headers",
"libincfs_headers",
@@ -372,15 +382,28 @@
"libandroidio",
"libandroidio_srcs",
"libserviceutils",
+ "libstagefright_amrnbenc",
+ "libstagefright_amrnbdec",
+ "libstagefright_amrwbdec",
+ "libstagefright_amrwbenc",
+ "libstagefright_amrnb_common",
"libstagefright_enc_common",
+ "libstagefright_flacdec",
+ "libstagefright_foundation",
"libstagefright_foundation_headers",
"libstagefright_headers",
+ "libstagefright_m4vh263dec",
+ "libstagefright_m4vh263enc",
+ "libstagefright_mp3dec",
+ "libstagefright_mp3dec_headers",
"libsurfaceflinger_headers",
"libsync",
"libtextclassifier_hash_headers",
"libtextclassifier_hash_static",
"libtflite_kernel_utils",
"libtinyxml2",
+ "libgui_aidl",
+ "libui",
"libui-types",
"libui_headers",
"libvorbisidec",
@@ -388,11 +411,24 @@
"media_plugin_headers",
"mediaswcodec.policy",
"mediaswcodec.xml",
+ "neuralnetworks_types",
+ "neuralnetworks_utils_hal_aidl",
+ "neuralnetworks_utils_hal_common",
+ "neuralnetworks_utils_hal_1_0",
+ "neuralnetworks_utils_hal_1_1",
+ "neuralnetworks_utils_hal_1_2",
+ "neuralnetworks_utils_hal_1_3",
+ "libneuralnetworks_common",
"philox_random",
"philox_random_headers",
"server_configurable_flags",
"tensorflow_headers",
+ "libgui_headers",
+ "libstagefright_bufferpool@2.0",
+ "libstagefright_bufferpool@2.0.1",
+ "libSurfaceFlingerProp",
+
// fastboot
"bootimg_headers",
"fastboot",
@@ -663,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/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..e5eec87 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,20 @@
ctx.CreateBazelTargetModule(props, CommonAttributes{Name: fg.Name()}, attrs)
} else {
+ if fg.ShouldConvertToProtoLibrary(ctx) {
+ attrs := &ProtoAttrs{
+ Srcs: srcs,
+ Strip_import_prefix: fg.properties.Path,
+ }
+
+ 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 +166,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 +259,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 +279,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 +297,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..3a5d4da 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -155,11 +155,12 @@
// 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
@@ -179,44 +180,70 @@
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),
+ }
+
+ 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/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 880ae75..ba7af09 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2261,6 +2261,130 @@
})
}
+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{
+ "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"]`,
+ }), 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"]`,
+ }), 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{
+ "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/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 0637ba2..316fa3e 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1392,6 +1392,16 @@
Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
Blueprint: soongCcLibraryStaticPreamble +
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+
+cc_library {
+ name: "libm",
+ stubs: {
+ symbol_file: "libm.map.txt",
+ versions: ["current"],
+ },
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "used_in_bionic_oses",
target: {
@@ -1414,7 +1424,20 @@
cc_library_static {
name: "keep_for_empty_system_shared_libs",
shared_libs: ["libc"],
- system_shared_libs: [],
+ system_shared_libs: [],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "used_with_stubs",
+ shared_libs: ["libm"],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "keep_with_stubs",
+ shared_libs: ["libm"],
+ system_shared_libs: [],
include_build_directory: false,
}
`,
@@ -1424,7 +1447,15 @@
"implementation_dynamic_deps": `[":libc"]`,
"system_dynamic_deps": `[]`,
}),
+ MakeBazelTarget("cc_library_static", "keep_with_stubs", AttrNameToString{
+ "implementation_dynamic_deps": `select({
+ "//build/bazel/rules/apex:android-in_apex": [":libm_stub_libs_current"],
+ "//conditions:default": [":libm"],
+ })`,
+ "system_dynamic_deps": `[]`,
+ }),
MakeBazelTarget("cc_library_static", "used_in_bionic_oses", AttrNameToString{}),
+ MakeBazelTarget("cc_library_static", "used_with_stubs", AttrNameToString{}),
},
})
}
diff --git a/bp2build/filegroup_conversion_test.go b/bp2build/filegroup_conversion_test.go
index de09a17..d84d4b3 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,43 @@
]`}),
}})
}
+
+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"`}),
+ 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/Android.bp b/cc/Android.bp
index 1ead99b..2963c77 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -45,6 +45,7 @@
"snapshot_utils.go",
"stl.go",
"strip.go",
+ "sysprop.go",
"tidy.go",
"util.go",
"vendor_snapshot.go",
diff --git a/cc/bp2build.go b/cc/bp2build.go
index a2e0a31..51d8e22 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -36,6 +36,8 @@
cppSrcPartition = "cpp"
protoSrcPartition = "proto"
aidlSrcPartition = "aidl"
+
+ stubsSuffix = "_stub_libs_current"
)
// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
@@ -77,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
@@ -504,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.
@@ -768,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),
})
@@ -935,7 +923,7 @@
stubLibLabels := []bazel.Label{}
for _, l := range depsWithStubs {
- l.Label = l.Label + "_stub_libs_current"
+ l.Label = l.Label + stubsSuffix
stubLibLabels = append(stubLibLabels, l)
}
inApexSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
@@ -1096,12 +1084,20 @@
if la.systemDynamicDeps.IsNil() && len(la.usedSystemDynamicDepAsDynamicDep) > 0 {
toRemove := bazelLabelForSharedDeps(ctx, android.SortedStringKeys(la.usedSystemDynamicDepAsDynamicDep))
la.dynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, toRemove)
+ stubsToRemove := make([]bazel.Label, 0, len(la.usedSystemDynamicDepAsDynamicDep))
+ for _, lib := range toRemove.Includes {
+ lib.Label += stubsSuffix
+ stubsToRemove = append(stubsToRemove, lib)
+ }
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.MakeLabelList(stubsToRemove))
}
la.deps.ResolveExcludes()
diff --git a/cc/cc.go b/cc/cc.go
index d42ab6d..3129160 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -51,6 +51,7 @@
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
+ ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -2391,8 +2392,18 @@
}
}
+ // sysprop_library has to support both C++ and Java. So sysprop_library internally creates one
+ // C++ implementation library and one Java implementation library. When a module links against
+ // sysprop_library, the C++ implementation library has to be linked. syspropImplLibraries is a
+ // map from sysprop_library to implementation library; it will be used in whole_static_libs,
+ // static_libs, and shared_libs.
+ syspropImplLibraries := syspropImplLibraries(actx.Config())
+
for _, lib := range deps.WholeStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
@@ -2410,6 +2421,10 @@
depTag.excludeInApex = true
}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
+
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
actx.AddVariationDependencies([]blueprint.Variation{
@@ -2439,6 +2454,10 @@
depTag.excludeInApex = true
}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
+
name, version := StubsLibNameAndVersion(lib)
sharedLibNames = append(sharedLibNames, name)
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 1b126de..07b95e1 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -109,7 +109,7 @@
}, "-l")
muslCrtBeginStaticBinary, muslCrtEndStaticBinary = []string{"libc_musl_crtbegin_static"}, []string{"libc_musl_crtend"}
- muslCrtBeginSharedBinary, muslCrtEndSharedBinary = []string{"libc_musl_crtbegin_dynamic", "musl_linker_script"}, []string{"libc_musl_crtend"}
+ muslCrtBeginSharedBinary, muslCrtEndSharedBinary = []string{"libc_musl_crtbegin_dynamic"}, []string{"libc_musl_crtend"}
muslCrtBeginSharedLibrary, muslCrtEndSharedLibrary = []string{"libc_musl_crtbegin_so"}, []string{"libc_musl_crtend_so"}
muslDefaultSharedLibraries = []string{"libc_musl"}
diff --git a/cc/object.go b/cc/object.go
index 65a11e0..20eef30 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -256,13 +256,18 @@
builderFlags := flagsToBuilderFlags(flags)
if len(objs.objFiles) == 1 && String(object.Properties.Linker_script) == "" {
- outputFile = objs.objFiles[0]
+ output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
+ outputFile = output
if String(object.Properties.Prefix_symbols) != "" {
- output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
- transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), outputFile,
+ transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), objs.objFiles[0],
builderFlags, output)
- outputFile = output
+ } else {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: objs.objFiles[0],
+ Output: output,
+ })
}
} else {
output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
diff --git a/cc/object_test.go b/cc/object_test.go
index 259a892..00f83d4 100644
--- a/cc/object_test.go
+++ b/cc/object_test.go
@@ -15,6 +15,7 @@
package cc
import (
+ "fmt"
"testing"
"android/soong/android"
@@ -107,3 +108,53 @@
expectedOutputFiles := []string{"outputbase/execroot/__main__/bazel_out.o"}
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
}
+
+func TestCcObjectOutputFile(t *testing.T) {
+ testcases := []struct {
+ name string
+ bp string
+ }{
+ {
+ name: "normal",
+ bp: `
+ srcs: ["bar.c"],
+ `,
+ },
+ {
+ name: "keep symbols",
+ bp: `
+ srcs: ["bar.c"],
+ prefix_symbols: "foo_",
+ `,
+ },
+ {
+ name: "partial linking",
+ bp: `
+ srcs: ["bar.c", "baz.c"],
+ `,
+ },
+ {
+ name: "partial linking and prefix symbols",
+ bp: `
+ srcs: ["bar.c", "baz.c"],
+ prefix_symbols: "foo_",
+ `,
+ },
+ }
+
+ for _, testcase := range testcases {
+ bp := fmt.Sprintf(`
+ cc_object {
+ name: "foo",
+ %s
+ }
+ `, testcase.bp)
+ t.Run(testcase.name, func(t *testing.T) {
+ ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp)
+ android.AssertPathRelativeToTopEquals(t, "expected output file foo.o",
+ "out/soong/.intermediates/foo/android_arm64_armv8-a/foo.o",
+ ctx.ModuleForTests("foo", "android_arm64_armv8-a").Output("foo.o").Output)
+ })
+ }
+
+}
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/cc/sysprop.go b/cc/sysprop.go
new file mode 100644
index 0000000..f578b50
--- /dev/null
+++ b/cc/sysprop.go
@@ -0,0 +1,69 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cc
+
+// This file contains a map to redirect dependencies towards sysprop_library.
+// As sysprop_library has to support both Java and C++, sysprop_library internally
+// generates cc_library and java_library. For example, the following sysprop_library
+//
+// sysprop_library {
+// name: "foo",
+// }
+//
+// will internally generate with prefix "lib"
+//
+// cc_library {
+// name: "libfoo",
+// }
+//
+// When a cc module links against "foo", build system will redirect the
+// dependency to "libfoo". To do that, SyspropMutator gathers all sysprop_library,
+// records their cc implementation library names to a map. The map will be used in
+// cc.Module.DepsMutator.
+
+import (
+ "sync"
+
+ "android/soong/android"
+)
+
+type syspropLibraryInterface interface {
+ BaseModuleName() string
+ CcImplementationModuleName() string
+}
+
+var (
+ syspropImplLibrariesKey = android.NewOnceKey("syspropImplLibirares")
+ syspropImplLibrariesLock sync.Mutex
+)
+
+func syspropImplLibraries(config android.Config) map[string]string {
+ return config.Once(syspropImplLibrariesKey, func() interface{} {
+ return make(map[string]string)
+ }).(map[string]string)
+}
+
+// gather list of sysprop libraries
+func SyspropMutator(mctx android.BottomUpMutatorContext) {
+ if m, ok := mctx.Module().(syspropLibraryInterface); ok {
+ syspropImplLibraries := syspropImplLibraries(mctx.Config())
+ syspropImplLibrariesLock.Lock()
+ defer syspropImplLibrariesLock.Unlock()
+
+ // BaseModuleName is the name of sysprop_library
+ // CcImplementationModuleName is the name of cc_library generated by sysprop_library
+ syspropImplLibraries[m.BaseModuleName()] = m.CcImplementationModuleName()
+ }
+}
diff --git a/java/config/config.go b/java/config/config.go
index b026d73..03288fe 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -78,7 +78,7 @@
func init() {
pctx.Import("github.com/google/blueprint/bootstrap")
- exportedVars.ExportStringStaticVariable("JavacHeapSize", "2048M")
+ exportedVars.ExportStringStaticVariable("JavacHeapSize", "4096M")
exportedVars.ExportStringStaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}")
// ErrorProne can use significantly more memory than javac alone, give it a higher heap
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 578dc2b..0785f89 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -365,10 +365,7 @@
// sysprop_library creates schematized APIs from sysprop description files (.sysprop).
// Both Java and C++ modules can link against sysprop_library, and API stability check
// against latest APIs (see build/soong/scripts/freeze-sysprop-api-files.sh)
-// is performed. Note that the generated C++ module has its name prefixed with
-// `lib`, and it is this module that should be depended on from other C++
-// modules; i.e., if the sysprop_library module is named `foo`, C++ modules
-// should depend on `libfoo`.
+// is performed.
func syspropLibraryFactory() android.Module {
m := &syspropLibrary{}
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index 80b86e0..88ef615 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -209,32 +209,32 @@
cc_library {
name: "cc-client-platform",
srcs: ["d.cpp"],
- static_libs: ["libsysprop-platform"],
+ static_libs: ["sysprop-platform"],
}
cc_library_static {
name: "cc-client-platform-static",
srcs: ["d.cpp"],
- whole_static_libs: ["libsysprop-platform"],
+ whole_static_libs: ["sysprop-platform"],
}
cc_library {
name: "cc-client-product",
srcs: ["d.cpp"],
product_specific: true,
- static_libs: ["libsysprop-platform-on-product", "libsysprop-vendor-on-product"],
+ static_libs: ["sysprop-platform-on-product", "sysprop-vendor-on-product"],
}
cc_library {
name: "cc-client-vendor",
srcs: ["d.cpp"],
soc_specific: true,
- static_libs: ["libsysprop-platform", "libsysprop-vendor"],
+ static_libs: ["sysprop-platform", "sysprop-vendor"],
}
cc_binary_host {
name: "hostbin",
- static_libs: ["libsysprop-platform"],
+ static_libs: ["sysprop-platform"],
}
`)