Merge "java_sdk_library_import: Copy all prebuilt properties to child modules"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index f2b05dd..19bf001 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -45,6 +45,9 @@
"art/runtime": Bp2BuildDefaultTrueRecursively,
"art/tools": Bp2BuildDefaultTrue,
"bionic": Bp2BuildDefaultTrueRecursively,
+ "bootable/recovery/minadbd": Bp2BuildDefaultTrue,
+ "bootable/recovery/minui": Bp2BuildDefaultTrue,
+ "bootable/recovery/recovery_utils": Bp2BuildDefaultTrue,
"bootable/recovery/tools/recovery_l10n": Bp2BuildDefaultTrue,
"build/bazel": Bp2BuildDefaultTrueRecursively,
@@ -124,9 +127,9 @@
"external/icu/icu4j": Bp2BuildDefaultFalse, // java rules incomplete
"external/jacoco": Bp2BuildDefaultTrueRecursively,
"external/jarjar": Bp2BuildDefaultTrueRecursively,
- "external/javassist": Bp2BuildDefaultTrueRecursively,
"external/javaparser": Bp2BuildDefaultTrueRecursively,
"external/javapoet": Bp2BuildDefaultTrueRecursively,
+ "external/javassist": Bp2BuildDefaultTrueRecursively,
"external/jemalloc_new": Bp2BuildDefaultTrueRecursively,
"external/jsoncpp": Bp2BuildDefaultTrueRecursively,
"external/junit": Bp2BuildDefaultTrueRecursively,
@@ -134,6 +137,7 @@
"external/libcap": Bp2BuildDefaultTrueRecursively,
"external/libcxx": Bp2BuildDefaultTrueRecursively,
"external/libcxxabi": Bp2BuildDefaultTrueRecursively,
+ "external/libdrm": Bp2BuildDefaultTrue,
"external/libevent": Bp2BuildDefaultTrueRecursively,
"external/libgav1": Bp2BuildDefaultTrueRecursively,
"external/libhevc": Bp2BuildDefaultTrueRecursively,
@@ -146,8 +150,8 @@
"external/lzma/C": Bp2BuildDefaultTrueRecursively,
"external/mdnsresponder": Bp2BuildDefaultTrueRecursively,
"external/minijail": Bp2BuildDefaultTrueRecursively,
- "external/openscreen": Bp2BuildDefaultTrueRecursively,
"external/objenesis": Bp2BuildDefaultTrueRecursively,
+ "external/openscreen": Bp2BuildDefaultTrueRecursively,
"external/pcre": Bp2BuildDefaultTrueRecursively,
"external/protobuf": Bp2BuildDefaultTrueRecursively,
"external/python/six": Bp2BuildDefaultTrueRecursively,
@@ -181,6 +185,7 @@
"frameworks/native/opengl/tests/testLatency": Bp2BuildDefaultTrue,
"frameworks/native/opengl/tests/testPauseResume": Bp2BuildDefaultTrue,
"frameworks/native/opengl/tests/testViewport": Bp2BuildDefaultTrue,
+ "frameworks/native/services/batteryservice": Bp2BuildDefaultTrue,
"frameworks/proto_logging/stats/stats_log_api_gen": Bp2BuildDefaultTrueRecursively,
"hardware/interfaces": Bp2BuildDefaultTrue,
@@ -202,6 +207,14 @@
"hardware/interfaces/graphics/mapper/2.1": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/mapper/3.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/mapper/4.0": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/1.0": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/1.0/default": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/2.0": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/2.0/default": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/2.0/utils": Bp2BuildDefaultTrueRecursively,
+ "hardware/interfaces/health/2.1": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/aidl": Bp2BuildDefaultTrue,
+ "hardware/interfaces/health/utils": Bp2BuildDefaultTrueRecursively,
"hardware/interfaces/media/1.0": Bp2BuildDefaultTrue,
"hardware/interfaces/media/bufferpool/2.0": Bp2BuildDefaultTrue,
"hardware/interfaces/media/c2/1.0": Bp2BuildDefaultTrue,
@@ -251,6 +264,8 @@
"system/apex/tools": Bp2BuildDefaultTrueRecursively,
"system/core/debuggerd": Bp2BuildDefaultTrueRecursively,
"system/core/diagnose_usb": Bp2BuildDefaultTrueRecursively,
+ "system/core/healthd": Bp2BuildDefaultTrue,
+ "system/core/healthd/testdata": Bp2BuildDefaultTrue,
"system/core/libasyncio": Bp2BuildDefaultTrue,
"system/core/libcrypto_utils": Bp2BuildDefaultTrueRecursively,
"system/core/libcutils": Bp2BuildDefaultTrueRecursively,
@@ -258,6 +273,7 @@
"system/core/libprocessgroup": Bp2BuildDefaultTrue,
"system/core/libprocessgroup/cgrouprc": Bp2BuildDefaultTrue,
"system/core/libprocessgroup/cgrouprc_format": Bp2BuildDefaultTrue,
+ "system/core/libsuspend": Bp2BuildDefaultTrue,
"system/core/libsystem": Bp2BuildDefaultTrueRecursively,
"system/core/libsysutils": Bp2BuildDefaultTrueRecursively,
"system/core/libutils": Bp2BuildDefaultTrueRecursively,
@@ -537,9 +553,6 @@
//system/core/libkeyutils
"libkeyutils",
- //bootable/recovery/minadbd
- "libminadbd_headers",
-
//bootable/recovery/otautil
"libotautil",
@@ -577,6 +590,42 @@
"libEGL_blobCache",
"protoc-gen-cppstream",
+
+ "mediaswcodec",
+ "libmedia_headers",
+ "libmedia_codecserviceregistrant",
+ "libsfplugin_ccodec_utils",
+ "libcodec2_soft_aacenc",
+ "libcodec2_soft_amrnbdec",
+ "libcodec2_soft_amrnbenc",
+ "libcodec2_soft_amrwbdec",
+ "libcodec2_soft_amrwbenc",
+ "libcodec2_soft_hevcdec",
+ "libcodec2_soft_hevcenc",
+ "libcodec2_soft_g711alawdec",
+ "libcodec2_soft_g711mlawdec",
+ "libcodec2_soft_mpeg2dec",
+ "libcodec2_soft_h263dec",
+ "libcodec2_soft_h263enc",
+ "libcodec2_soft_mpeg4dec",
+ "libcodec2_soft_mpeg4enc",
+ "libcodec2_soft_mp3dec",
+ "libcodec2_soft_vorbisdec",
+ "libcodec2_soft_opusdec",
+ "libcodec2_soft_opusenc",
+ "libcodec2_soft_vp8dec",
+ "libcodec2_soft_vp9dec",
+ "libcodec2_soft_av1dec_gav1",
+ "libcodec2_soft_vp8enc",
+ "libcodec2_soft_vp9enc",
+ "libcodec2_soft_rawdec",
+ "libcodec2_soft_flacdec",
+ "libcodec2_soft_flacenc",
+ "libcodec2_soft_gsmdec",
+ "libcodec2_soft_avcdec",
+ "libcodec2_soft_avcenc",
+ "libcodec2_soft_aacdec",
+ "libcodec2_soft_common",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -589,6 +638,7 @@
"ndk_headers",
"ndk_library",
"sysprop_library",
+ "bpf",
}
// Add the names of modules that bp2build should never convert, if it is
@@ -713,6 +763,12 @@
// depends on //external/okio:okio-lib, which uses kotlin
"wire-runtime",
+ // depends on adbd_system_api_recovery, which is a unconverted `phony` module type
+ "minadbd",
+
+ // depends on android.hardware.health-V2.0-java
+ "android.hardware.health-translate-java",
+
// cc_test related.
// Failing host cc_tests
"memunreachable_unit_test",
diff --git a/android/module.go b/android/module.go
index 1617259..f63a06d 100644
--- a/android/module.go
+++ b/android/module.go
@@ -919,6 +919,8 @@
Data bazel.LabelListAttribute
Tags bazel.StringListAttribute
+
+ Applicable_licenses bazel.LabelListAttribute
}
// constraintAttributes represents Bazel attributes pertaining to build constraints,
@@ -1231,6 +1233,8 @@
}
}
+ attrs.Applicable_licenses = bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, mod.commonProperties.Licenses))
+
// The required property can contain the module itself. This causes a cycle
// when generated as the 'data' label list attribute in Bazel. Remove it if
// it exists. See b/247985196.
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a69faeb..7ae9ed7 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -7276,6 +7276,28 @@
android.AssertStringEquals(t, "myapex input", extractorOutput, copiedApex.Input.String())
}
+func TestApexSetApksModuleAssignment(t *testing.T) {
+ ctx := testApex(t, `
+ apex_set {
+ name: "myapex",
+ set: ":myapex_apks_file",
+ }
+
+ filegroup {
+ name: "myapex_apks_file",
+ srcs: ["myapex.apks"],
+ }
+ `)
+
+ m := ctx.ModuleForTests("myapex.apex.extractor", "android_common")
+
+ // Check that the extractor produces the correct apks file from the input module
+ extractorOutput := "out/soong/.intermediates/myapex.apex.extractor/android_common/extracted/myapex.apks"
+ extractedApex := m.Output(extractorOutput)
+
+ android.AssertArrayString(t, "extractor input", []string{"myapex.apks"}, extractedApex.Inputs.Strings())
+}
+
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer android.FixturePreparer, fragments ...java.ApexVariantReference) {
t.Helper()
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 172a201..25ae5bf 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -840,17 +840,17 @@
type ApexExtractorProperties struct {
// the .apks file path that contains prebuilt apex files to be extracted.
- Set *string
+ Set *string `android:"path"`
Sanitized struct {
None struct {
- Set *string
+ Set *string `android:"path"`
}
Address struct {
- Set *string
+ Set *string `android:"path"`
}
Hwaddress struct {
- Set *string
+ Set *string `android:"path"`
}
}
diff --git a/bp2build/bpf_conversion_test.go b/bp2build/bpf_conversion_test.go
new file mode 100644
index 0000000..1259f9e
--- /dev/null
+++ b/bp2build/bpf_conversion_test.go
@@ -0,0 +1,65 @@
+// Copyright 2022 Google Inc. All rights reserved.
+//
+// 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 bp2build
+
+import (
+ "android/soong/android"
+ "android/soong/bpf"
+
+ "testing"
+)
+
+func runBpfTestCase(t *testing.T, tc Bp2buildTestCase) {
+ t.Helper()
+ (&tc).ModuleTypeUnderTest = "bpf"
+ (&tc).ModuleTypeUnderTestFactory = bpf.BpfFactory
+ RunBp2BuildTestCase(t, registerBpfModuleTypes, tc)
+}
+
+func registerBpfModuleTypes(ctx android.RegistrationContext) {}
+
+func TestBpfSupportedAttrs(t *testing.T) {
+ runBpfTestCase(t, Bp2buildTestCase{
+ Description: "Bpf module only converts supported attributes",
+ Filesystem: map[string]string{},
+ Blueprint: `
+bpf {
+ name: "bpfTestOut.o",
+ srcs: ["bpfTestSrcOne.c",
+ "bpfTestSrcTwo.c"],
+ btf: true,
+ cflags: ["-bpfCflagOne",
+ "-bpfCflagTwo"],
+ include_dirs: ["ia/ib/ic"],
+ sub_dir: "sa/ab",
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("bpf", "bpfTestOut.o", AttrNameToString{
+ "absolute_includes": `["ia/ib/ic"]`,
+ "btf": `True`,
+ "copts": `[
+ "-bpfCflagOne",
+ "-bpfCflagTwo",
+ ]`,
+ "srcs": `[
+ "bpfTestSrcOne.c",
+ "bpfTestSrcTwo.c",
+ ]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index d29eb9c..d513d04 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -1821,3 +1821,30 @@
})
}
}
+
+func TestLicensesAttrConversion(t *testing.T) {
+ RunBp2BuildTestCase(t,
+ func(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("license", android.LicenseFactory)
+ },
+ Bp2buildTestCase{
+ Description: "Test that licenses: attribute is converted",
+ ModuleTypeUnderTest: "filegroup",
+ ModuleTypeUnderTestFactory: android.FileGroupFactory,
+ Blueprint: `
+license {
+ name: "my_license",
+}
+filegroup {
+ name: "my_filegroup",
+ licenses: ["my_license"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("filegroup", "my_filegroup", AttrNameToString{
+ "applicable_licenses": `[":my_license"]`,
+ }),
+ MakeBazelTargetNoRestrictions("android_license", "my_license", AttrNameToString{}),
+ },
+ })
+}
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index b1a9240..6253de6 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -338,22 +338,30 @@
})
}
-func TestCcLibrarySharedVersionScript(t *testing.T) {
+func TestCcLibrarySharedVersionScriptAndDynamicList(t *testing.T) {
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
- Description: "cc_library_shared version script",
+ Description: "cc_library_shared version script and dynamic list",
Filesystem: map[string]string{
"version_script": "",
+ "dynamic.list": "",
},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "foo_shared",
version_script: "version_script",
+ dynamic_list: "dynamic.list",
include_build_directory: false,
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
- "additional_linker_inputs": `["version_script"]`,
- "linkopts": `["-Wl,--version-script,$(location version_script)"]`,
+ "additional_linker_inputs": `[
+ "version_script",
+ "dynamic.list",
+ ]`,
+ "linkopts": `[
+ "-Wl,--version-script,$(location version_script)",
+ "-Wl,--dynamic-list,$(location dynamic.list)",
+ ]`,
}),
},
})
diff --git a/bpf/bpf.go b/bpf/bpf.go
index e89cc4e..dbbce50 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -21,6 +21,7 @@
"strings"
"android/soong/android"
+ "android/soong/bazel"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -93,6 +94,7 @@
type bpf struct {
android.ModuleBase
+ android.BazelModuleBase
properties BpfProperties
@@ -260,5 +262,39 @@
module.AddProperties(&module.properties)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitBazelModule(module)
return module
}
+
+type bazelBpfAttributes struct {
+ Srcs bazel.LabelListAttribute
+ Copts bazel.StringListAttribute
+ Absolute_includes bazel.StringListAttribute
+ Btf *bool
+ // TODO(b/249528391): Add support for sub_dir
+}
+
+// bpf bp2build converter
+func (b *bpf) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+ if ctx.ModuleType() != "bpf" {
+ return
+ }
+
+ srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, b.properties.Srcs))
+ copts := bazel.MakeStringListAttribute(b.properties.Cflags)
+ absolute_includes := bazel.MakeStringListAttribute(b.properties.Include_dirs)
+ btf := b.properties.Btf
+
+ attrs := bazelBpfAttributes{
+ Srcs: srcs,
+ Copts: copts,
+ Absolute_includes: absolute_includes,
+ Btf: btf,
+ }
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "bpf",
+ Bzl_load_location: "//build/bazel/rules/bpf:bpf.bzl",
+ }
+
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: b.Name()}, &attrs)
+}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 9b85ec4..83368a3 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -1031,18 +1031,20 @@
axisFeatures = append(axisFeatures, "-static_flag")
}
}
+ additionalLinkerInputs := bazel.LabelList{}
if props.Version_script != nil {
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Version_script)
- la.additionalLinkerInputs.SetSelectValue(axis, config, bazel.LabelList{Includes: []bazel.Label{label}})
+ additionalLinkerInputs.Add(&label)
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
}
if props.Dynamic_list != nil {
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Dynamic_list)
- la.additionalLinkerInputs.SetSelectValue(axis, config, bazel.LabelList{Includes: []bazel.Label{label}})
+ additionalLinkerInputs.Add(&label)
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--dynamic-list,$(location %s)", label.Label))
}
+ la.additionalLinkerInputs.SetSelectValue(axis, config, additionalLinkerInputs)
la.linkopts.SetSelectValue(axis, config, parseCommandLineFlags(linkerFlags, false, filterOutClangUnknownCflags))
la.useLibcrt.SetSelectValue(axis, config, props.libCrt())
diff --git a/java/lint_defaults.txt b/java/lint_defaults.txt
index bff7221..519a702 100644
--- a/java/lint_defaults.txt
+++ b/java/lint_defaults.txt
@@ -39,6 +39,7 @@
# Downgrade existing errors to warnings
--warning_check AppCompatResource # 55 occurences in 10 modules
--warning_check AppLinkUrlError # 111 occurences in 53 modules
+--warning_check BinderGetCallingInMainThread
--warning_check ByteOrderMark # 2 occurences in 2 modules
--warning_check DuplicateActivity # 3 occurences in 3 modules
--warning_check DuplicateDefinition # 3623 occurences in 48 modules
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
index 78af54d..3cb6c8c 100755
--- a/tests/bp2build_bazel_test.sh
+++ b/tests/bp2build_bazel_test.sh
@@ -114,7 +114,10 @@
fi
}
+_save_trap=$(trap -p EXIT)
+trap '[[ $? -ne 0 ]] && echo Are you running this locally? Try changing --sandbox_tmpfs_path to something other than /tmp/ in build/bazel/linux.bazelrc.' EXIT
test_bp2build_generates_all_buildfiles
+eval ${_save_trap}
function test_cc_correctness {
setup