Merge "Suffix the build ID to the dirname of APK-in-APEX files."
diff --git a/OWNERS b/OWNERS
index 0cfb241..0662016 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,12 +2,13 @@
# approving build related projects.
# AMER
-ahumesky@google.com
+agespino@google.com
alexmarquez@google.com
asmundak@google.com
ccross@android.com
colefaust@google.com
cparsons@google.com
+dacek@google.com
delmerico@google.com
dwillemsen@google.com
eakammer@google.com
@@ -17,13 +18,12 @@
spandandas@google.com
tradical@google.com
usta@google.com
+vinhdaitran@google.com
weiwli@google.com
yudiliu@google.com
-yuntaoxu@google.com
# APAC
jingwen@google.com
-ruperts@google.com
# EMEA
hansson@google.com
diff --git a/android/androidmk.go b/android/androidmk.go
index e9c63fb..5c715b4 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -578,7 +578,7 @@
}
}
- if !base.InRamdisk() && !base.InVendorRamdisk() {
+ if !base.InVendorRamdisk() {
a.AddPaths("LOCAL_FULL_INIT_RC", base.initRcPaths)
}
if len(base.vintfFragmentsPaths) > 0 {
diff --git a/apex/builder.go b/apex/builder.go
index 293f388..abbf8ad 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -388,7 +388,7 @@
imageDir := android.PathForModuleOut(ctx, "image"+suffix)
- installSymbolFiles := !ctx.Config().KatiEnabled() || a.ExportedToMake()
+ installSymbolFiles := (!ctx.Config().KatiEnabled() || a.ExportedToMake()) && a.installable()
// b/140136207. When there are overriding APEXes for a VNDK APEX, the symbols file for the overridden
// APEX and the overriding APEX will have the same installation paths at /apex/com.android.vndk.v<ver>
diff --git a/bp2build/Android.bp b/bp2build/Android.bp
index 8f78968..e0ce194 100644
--- a/bp2build/Android.bp
+++ b/bp2build/Android.bp
@@ -45,7 +45,9 @@
"cc_library_shared_conversion_test.go",
"cc_library_static_conversion_test.go",
"cc_object_conversion_test.go",
+ "cc_prebuilt_library_conversion_test.go",
"cc_prebuilt_library_shared_test.go",
+ "cc_prebuilt_library_static_test.go",
"conversion_test.go",
"filegroup_conversion_test.go",
"genrule_conversion_test.go",
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 17337f0..037564b 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -130,6 +130,7 @@
},
sdk_version: "current",
min_sdk_version: "29",
+ use_version_lib: true,
}
`,
targets: []testBazelTarget{
@@ -153,8 +154,9 @@
"keep_symbols_list": ["symbol"],
"none": True,
}`,
- "sdk_version": `"current"`,
- "min_sdk_version": `"29"`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
+ "use_version_lib": `True`,
},
},
},
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 5767861..2775a10 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -117,6 +117,7 @@
include_build_directory: false,
sdk_version: "current",
min_sdk_version: "29",
+ use_version_lib: true,
}
`,
expectedBazelTargets: makeCcLibraryTargets("foo-lib", attrNameToString{
@@ -142,8 +143,9 @@
"//build/bazel/platforms/os:linux_bionic": ["bionic.cpp"],
"//conditions:default": [],
})`,
- "sdk_version": `"current"`,
- "min_sdk_version": `"29"`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
+ "use_version_lib": `True`,
}),
})
}
diff --git a/bp2build/cc_prebuilt_library_conversion_test.go b/bp2build/cc_prebuilt_library_conversion_test.go
new file mode 100644
index 0000000..3cf8969
--- /dev/null
+++ b/bp2build/cc_prebuilt_library_conversion_test.go
@@ -0,0 +1,250 @@
+// 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 (
+ "fmt"
+ "testing"
+
+ "android/soong/cc"
+)
+
+func TestPrebuiltLibraryStaticAndSharedSimple(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library static and shared simple",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ srcs: ["libf.so"],
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
+ "static_library": `"libf.so"`,
+ }),
+ makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
+ "shared_library": `"libf.so"`,
+ }),
+ },
+ })
+}
+
+func TestPrebuiltLibraryWithArchVariance(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library with arch variance",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ arch: {
+ arm64: { srcs: ["libf.so"], },
+ arm: { srcs: ["libg.so"], },
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
+ "static_library": `select({
+ "//build/bazel/platforms/arch:arm": "libg.so",
+ "//build/bazel/platforms/arch:arm64": "libf.so",
+ "//conditions:default": None,
+ })`,
+ }),
+ makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
+ "shared_library": `select({
+ "//build/bazel/platforms/arch:arm": "libg.so",
+ "//build/bazel/platforms/arch:arm64": "libf.so",
+ "//conditions:default": None,
+ })`,
+ }),
+ },
+ })
+}
+
+func TestPrebuiltLibraryAdditionalAttrs(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library additional attributes",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "testdir/1/": "",
+ "testdir/2/": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ srcs: ["libf.so"],
+ export_include_dirs: ["testdir/1/"],
+ export_system_include_dirs: ["testdir/2/"],
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
+ "static_library": `"libf.so"`,
+ "export_includes": `["testdir/1/"]`,
+ "export_system_includes": `["testdir/2/"]`,
+ }),
+ // TODO(b/229374533): When fixed, update this test
+ makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
+ "shared_library": `"libf.so"`,
+ }),
+ },
+ })
+}
+
+func TestPrebuiltLibrarySharedStanzaFails(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library with shared stanza fails because multiple sources",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ srcs: ["libf.so"],
+ shared: {
+ srcs: ["libg.so"],
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedErr: fmt.Errorf("Expected at most one source file"),
+ })
+}
+
+func TestPrebuiltLibraryStaticStanzaFails(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library with static stanza fails because multiple sources",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ srcs: ["libf.so"],
+ static: {
+ srcs: ["libg.so"],
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedErr: fmt.Errorf("Expected at most one source file"),
+ })
+}
+
+func TestPrebuiltLibrarySharedAndStaticStanzas(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library with both shared and static stanzas",
+ moduleTypeUnderTest: "cc_prebuilt_library",
+ moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library {
+ name: "libtest",
+ static: {
+ srcs: ["libf.so"],
+ },
+ shared: {
+ srcs: ["libg.so"],
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
+ "static_library": `"libf.so"`,
+ }),
+ makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
+ "shared_library": `"libg.so"`,
+ }),
+ },
+ })
+}
+
+// TODO(b/228623543): When this bug is fixed, enable this test
+//func TestPrebuiltLibraryOnlyShared(t *testing.T) {
+// runBp2BuildTestCaseSimple(t,
+// bp2buildTestCase{
+// description: "prebuilt library shared only",
+// moduleTypeUnderTest: "cc_prebuilt_library",
+// moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+// filesystem: map[string]string{
+// "libf.so": "",
+// },
+// blueprint: `
+//cc_prebuilt_library {
+// name: "libtest",
+// srcs: ["libf.so"],
+// static: {
+// enabled: false,
+// },
+// bazel_module: { bp2build_available: true },
+//}`,
+// expectedBazelTargets: []string{
+// makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
+// "shared_library": `"libf.so"`,
+// }),
+// },
+// })
+//}
+
+// TODO(b/228623543): When this bug is fixed, enable this test
+//func TestPrebuiltLibraryOnlyStatic(t *testing.T) {
+// runBp2BuildTestCaseSimple(t,
+// bp2buildTestCase{
+// description: "prebuilt library static only",
+// moduleTypeUnderTest: "cc_prebuilt_library",
+// moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
+// filesystem: map[string]string{
+// "libf.so": "",
+// },
+// blueprint: `
+//cc_prebuilt_library {
+// name: "libtest",
+// srcs: ["libf.so"],
+// shared: {
+// enabled: false,
+// },
+// bazel_module: { bp2build_available: true },
+//}`,
+// expectedBazelTargets: []string{
+// makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
+// "static_library": `"libf.so"`,
+// }),
+// },
+// })
+//}
diff --git a/bp2build/cc_prebuilt_library_shared_test.go b/bp2build/cc_prebuilt_library_shared_test.go
index ef2fddc..57905e5 100644
--- a/bp2build/cc_prebuilt_library_shared_test.go
+++ b/bp2build/cc_prebuilt_library_shared_test.go
@@ -1,6 +1,7 @@
package bp2build
import (
+ "fmt"
"testing"
"android/soong/cc"
@@ -59,3 +60,26 @@
},
})
}
+
+func TestSharedPrebuiltLibrarySharedStanzaFails(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library shared with shared stanza fails because multiple sources",
+ moduleTypeUnderTest: "cc_prebuilt_library_shared",
+ moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library_shared {
+ name: "libtest",
+ srcs: ["libf.so"],
+ shared: {
+ srcs: ["libg.so"],
+ },
+ bazel_module: { bp2build_available: true},
+}`,
+ expectedErr: fmt.Errorf("Expected at most one source file"),
+ })
+}
diff --git a/bp2build/cc_prebuilt_library_static_test.go b/bp2build/cc_prebuilt_library_static_test.go
new file mode 100644
index 0000000..3feb1f1
--- /dev/null
+++ b/bp2build/cc_prebuilt_library_static_test.go
@@ -0,0 +1,98 @@
+// 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 (
+ "fmt"
+ "testing"
+
+ "android/soong/cc"
+)
+
+func TestStaticPrebuiltLibrary(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library static simple",
+ moduleTypeUnderTest: "cc_prebuilt_library_static",
+ moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library_static {
+ name: "libtest",
+ srcs: ["libf.so"],
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest", attrNameToString{
+ "static_library": `"libf.so"`,
+ }),
+ },
+ })
+}
+
+func TestStaticPrebuiltLibraryWithArchVariance(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library static with arch variance",
+ moduleTypeUnderTest: "cc_prebuilt_library_static",
+ moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library_static {
+ name: "libtest",
+ arch: {
+ arm64: { srcs: ["libf.so"], },
+ arm: { srcs: ["libg.so"], },
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("prebuilt_library_static", "libtest", attrNameToString{
+ "static_library": `select({
+ "//build/bazel/platforms/arch:arm": "libg.so",
+ "//build/bazel/platforms/arch:arm64": "libf.so",
+ "//conditions:default": None,
+ })`,
+ }),
+ },
+ })
+}
+
+func TestStaticPrebuiltLibraryStaticStanzaFails(t *testing.T) {
+ runBp2BuildTestCaseSimple(t,
+ bp2buildTestCase{
+ description: "prebuilt library with static stanza fails because multiple sources",
+ moduleTypeUnderTest: "cc_prebuilt_library_static",
+ moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
+ filesystem: map[string]string{
+ "libf.so": "",
+ "libg.so": "",
+ },
+ blueprint: `
+cc_prebuilt_library_static {
+ name: "libtest",
+ srcs: ["libf.so"],
+ static: {
+ srcs: ["libg.so"],
+ },
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedErr: fmt.Errorf("Expected at most one source file"),
+ })
+}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 156e082..029ba49 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -84,8 +84,9 @@
expectedBazelTargets []string
filesystem map[string]string
dir string
- expectedErr error
- unconvertedDepsMode unconvertedDepsMode
+ // An error with a string contained within the string of the expected error
+ expectedErr error
+ unconvertedDepsMode unconvertedDepsMode
}
func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc bp2buildTestCase) {
diff --git a/cc/binary.go b/cc/binary.go
index 89e7262..c5017c1 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -615,6 +615,7 @@
Linkopts: baseAttrs.linkopts,
Link_crt: baseAttrs.linkCrt,
Use_libcrt: baseAttrs.useLibcrt,
+ Use_version_lib: baseAttrs.useVersionLib,
Rtti: baseAttrs.rtti,
Stl: baseAttrs.stl,
Cpp_std: baseAttrs.cppStd,
@@ -665,8 +666,9 @@
Linkopts bazel.StringListAttribute
Additional_linker_inputs bazel.LabelListAttribute
- Link_crt bazel.BoolAttribute
- Use_libcrt bazel.BoolAttribute
+ Link_crt bazel.BoolAttribute
+ Use_libcrt bazel.BoolAttribute
+ Use_version_lib bazel.BoolAttribute
Rtti bazel.BoolAttribute
Stl *string
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 811e228..cc378b3 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -141,6 +141,7 @@
}
}
+// Parses properties common to static and shared libraries. Also used for prebuilt libraries.
func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
attrs := staticOrSharedAttributes{}
@@ -198,30 +199,72 @@
// Convenience struct to hold all attributes parsed from prebuilt properties.
type prebuiltAttributes struct {
- Src bazel.LabelAttribute
+ Src bazel.LabelAttribute
+ Enabled bazel.BoolAttribute
}
// NOTE: Used outside of Soong repo project, in the clangprebuilts.go bootstrap_go_package
-func Bp2BuildParsePrebuiltLibraryProps(ctx android.BazelConversionPathContext, module *Module) prebuiltAttributes {
+func Bp2BuildParsePrebuiltLibraryProps(ctx android.BazelConversionPathContext, module *Module, isStatic bool) prebuiltAttributes {
+ manySourceFileError := func(axis bazel.ConfigurationAxis, config string) {
+ ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most one source file for %s %s\n", axis, config)
+ }
var srcLabelAttribute bazel.LabelAttribute
- for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltLinkerProperties{}) {
- for config, props := range configToProps {
- if prebuiltLinkerProperties, ok := props.(*prebuiltLinkerProperties); ok {
- if len(prebuiltLinkerProperties.Srcs) > 1 {
- ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file for %s %s\n", axis, config)
- continue
- } else if len(prebuiltLinkerProperties.Srcs) == 0 {
- continue
- }
- src := android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinkerProperties.Srcs[0])
- srcLabelAttribute.SetSelectValue(axis, config, src)
- }
+ parseSrcs := func(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis, config string, srcs []string) {
+ if len(srcs) > 1 {
+ manySourceFileError(axis, config)
+ return
+ } else if len(srcs) == 0 {
+ return
}
+ if srcLabelAttribute.SelectValue(axis, config) != nil {
+ manySourceFileError(axis, config)
+ return
+ }
+
+ src := android.BazelLabelForModuleSrcSingle(ctx, srcs[0])
+ srcLabelAttribute.SetSelectValue(axis, config, src)
+ }
+
+ bp2BuildPropParseHelper(ctx, module, &prebuiltLinkerProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
+ if prebuiltLinkerProperties, ok := props.(*prebuiltLinkerProperties); ok {
+ parseSrcs(ctx, axis, config, prebuiltLinkerProperties.Srcs)
+ }
+ })
+
+ var enabledLabelAttribute bazel.BoolAttribute
+ parseAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
+ if props.Enabled != nil {
+ enabledLabelAttribute.SetSelectValue(axis, config, props.Enabled)
+ }
+ parseSrcs(ctx, axis, config, props.Srcs)
+ }
+
+ if isStatic {
+ bp2BuildPropParseHelper(ctx, module, &StaticProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
+ if staticProperties, ok := props.(*StaticProperties); ok {
+ parseAttrs(axis, config, staticProperties.Static)
+ }
+ })
+ } else {
+ bp2BuildPropParseHelper(ctx, module, &SharedProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
+ if sharedProperties, ok := props.(*SharedProperties); ok {
+ parseAttrs(axis, config, sharedProperties.Shared)
+ }
+ })
}
return prebuiltAttributes{
- Src: srcLabelAttribute,
+ Src: srcLabelAttribute,
+ Enabled: enabledLabelAttribute,
+ }
+}
+
+func bp2BuildPropParseHelper(ctx android.ArchVariantContext, module *Module, propsType interface{}, parseFunc func(axis bazel.ConfigurationAxis, config string, props interface{})) {
+ for axis, configToProps := range module.GetArchVariantProperties(ctx, propsType) {
+ for config, props := range configToProps {
+ parseFunc(axis, config, props)
+ }
}
}
@@ -542,8 +585,8 @@
}
func bp2BuildParseSdkAttributes(module *Module) sdkAttributes {
- return sdkAttributes {
- Sdk_version: module.Properties.Sdk_version,
+ return sdkAttributes{
+ Sdk_version: module.Properties.Sdk_version,
Min_sdk_version: module.Properties.Min_sdk_version,
}
}
diff --git a/cc/cc.go b/cc/cc.go
index 00b82d5..456b736 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3556,13 +3556,14 @@
case fullLibrary:
if !prebuilt {
libraryBp2Build(ctx, c)
+ } else {
+ prebuiltLibraryBp2Build(ctx, c)
}
case headerLibrary:
libraryHeadersBp2Build(ctx, c)
case staticLibrary:
-
if prebuilt {
- prebuiltLibraryStaticBp2Build(ctx, c)
+ prebuiltLibraryStaticBp2Build(ctx, c, false)
} else {
sharedOrStaticLibraryBp2Build(ctx, c, true)
}
diff --git a/cc/library.go b/cc/library.go
index 035a90e..0abcb6f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -352,6 +352,7 @@
Stl: compilerAttrs.stl,
Cpp_std: compilerAttrs.cppStd,
C_std: compilerAttrs.cStd,
+ Use_version_lib: linkerAttrs.useVersionLib,
Features: linkerAttrs.features,
}
@@ -374,6 +375,7 @@
Stl: compilerAttrs.stl,
Cpp_std: compilerAttrs.cppStd,
C_std: compilerAttrs.cStd,
+ Use_version_lib: linkerAttrs.useVersionLib,
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go
index 927fa2e..3456c32 100644
--- a/cc/ndk_abi.go
+++ b/cc/ndk_abi.go
@@ -46,7 +46,7 @@
if m, ok := module.(*Module); ok {
if installer, ok := m.installer.(*stubDecorator); ok {
- if canDumpAbi() {
+ if canDumpAbi(ctx.Config()) {
depPaths = append(depPaths, installer.abiDumpPath)
}
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index fc682ff..5ef41ea 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -53,9 +53,9 @@
abitidy = pctx.AndroidStaticRule("abitidy",
blueprint.RuleParams{
- Command: "$abitidy --all -i $in -o $out",
+ Command: "$abitidy --all $flags -i $in -o $out",
CommandDeps: []string{"$abitidy"},
- })
+ }, "flags")
abidiff = pctx.AndroidStaticRule("abidiff",
blueprint.RuleParams{
@@ -104,6 +104,12 @@
// used. This is only needed to work around platform bugs like
// https://github.com/android-ndk/ndk/issues/265.
Unversioned_until *string
+
+ // If true, does not emit errors when APIs lacking type information are
+ // found. This is false by default and should not be enabled outside bionic,
+ // where it is enabled pending a fix for http://b/190554910 (no debug info
+ // for asm implemented symbols).
+ Allow_untyped_symbols *bool
}
type stubDecorator struct {
@@ -315,8 +321,18 @@
}
// Feature flag.
-func canDumpAbi() bool {
- return runtime.GOOS != "darwin"
+func canDumpAbi(config android.Config) bool {
+ if runtime.GOOS == "darwin" {
+ return false
+ }
+ // abidw doesn't currently handle top-byte-ignore correctly. Disable ABI
+ // dumping for those configs while we wait for a fix. We'll still have ABI
+ // checking coverage from non-hwasan builds.
+ // http://b/190554910
+ if android.InList("hwaddress", config.SanitizeDevice()) {
+ return false
+ }
+ return true
}
// Feature flag to disable diffing against prebuilts.
@@ -339,14 +355,22 @@
"symbolList": symbolList.String(),
},
})
+
this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx,
this.apiLevel.String(), ctx.Arch().ArchType.String(),
this.libraryName(ctx), "abi.xml")
+ untypedFlag := "--abort-on-untyped-symbols"
+ if proptools.BoolDefault(this.properties.Allow_untyped_symbols, false) {
+ untypedFlag = ""
+ }
ctx.Build(pctx, android.BuildParams{
Rule: abitidy,
Description: fmt.Sprintf("abitidy %s", implementationLibrary),
Input: abiRawPath,
Output: this.abiDumpPath,
+ Args: map[string]string{
+ "flags": untypedFlag,
+ },
})
}
@@ -444,7 +468,7 @@
nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile, c.apiLevel, "")
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
c.versionScriptPath = nativeAbiResult.versionScript
- if canDumpAbi() {
+ if canDumpAbi(ctx.Config()) {
c.dumpAbi(ctx, nativeAbiResult.symbolList)
if canDiffAbi() {
c.diffAbi(ctx)
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 5980319..f54c6f8 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -253,6 +253,7 @@
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported, srcsProperty string) (*Module, *libraryDecorator) {
module, library := NewLibrary(hod)
module.compiler = nil
+ module.bazelable = true
prebuilt := &prebuiltLibraryLinker{
libraryDecorator: library,
@@ -338,8 +339,21 @@
Export_system_includes bazel.StringListAttribute
}
-func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Module) {
- prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module)
+// TODO(b/228623543): The below is not entirely true until the bug is fixed. For now, both targets are always generated
+// Implements bp2build for cc_prebuilt_library modules. This will generate:
+// * Only a prebuilt_library_static if the shared.enabled property is set to false across all variants.
+// * Only a prebuilt_library_shared if the static.enabled property is set to false across all variants
+// * Both a prebuilt_library_static and prebuilt_library_shared if the aforementioned properties are not false across
+// all variants
+//
+// In all cases, prebuilt_library_static target names will be appended with "_bp2build_cc_library_static".
+func prebuiltLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module) {
+ prebuiltLibraryStaticBp2Build(ctx, module, true)
+ prebuiltLibrarySharedBp2Build(ctx, module)
+}
+
+func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Module, fullBuild bool) {
+ prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, true)
exportedIncludes := Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx, module)
attrs := &bazelPrebuiltLibraryStaticAttributes{
@@ -354,7 +368,10 @@
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
+ if fullBuild {
+ name += "_bp2build_cc_library_static"
+ }
+ ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
}
type bazelPrebuiltLibrarySharedAttributes struct {
@@ -362,7 +379,7 @@
}
func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Module) {
- prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module)
+ prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, false)
attrs := &bazelPrebuiltLibrarySharedAttributes{
Shared_library: prebuiltAttrs.Src,
@@ -374,7 +391,7 @@
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
+ ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
}
type prebuiltObjectProperties struct {
@@ -510,7 +527,16 @@
func (p *prebuiltObjectLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
if len(p.properties.Srcs) > 0 {
- return p.Prebuilt.SingleSourcePath(ctx)
+ // Copy objects to a name matching the final installed name
+ in := p.Prebuilt.SingleSourcePath(ctx)
+ outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".o")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.CpExecutable,
+ Description: "prebuilt",
+ Output: outputFile,
+ Input: in,
+ })
+ return outputFile
}
return nil
}
diff --git a/cmd/go2bp/go2bp.go b/cmd/go2bp/go2bp.go
index 07cb5df..fb5a746 100644
--- a/cmd/go2bp/go2bp.go
+++ b/cmd/go2bp/go2bp.go
@@ -335,12 +335,15 @@
}
cmd := exec.Command("go", "list", "-json", "./...")
- output, err := cmd.Output()
- if err != nil {
- fmt.Fprintf(os.Stderr, "Failed to dump the go packages: %v\n", err)
+ var stdoutb, stderrb bytes.Buffer
+ cmd.Stdout = &stdoutb
+ cmd.Stderr = &stderrb
+ if err := cmd.Run(); err != nil {
+ fmt.Fprintf(os.Stderr, "Running %q to dump the Go packages failed: %v, stderr:\n%s\n",
+ cmd.String(), err, stderrb.Bytes())
os.Exit(1)
}
- decoder := json.NewDecoder(bytes.NewReader(output))
+ decoder := json.NewDecoder(bytes.NewReader(stdoutb.Bytes()))
pkgs := []*GoPackage{}
pkgMap := map[string]*GoPackage{}
diff --git a/java/base.go b/java/base.go
index 6f12f6c..b925350 100644
--- a/java/base.go
+++ b/java/base.go
@@ -207,7 +207,7 @@
// Whether to compile against the platform APIs instead of an SDK.
// If true, then sdk_version must be empty. The value of this field
- // is ignored when module's type isn't android_app.
+ // is ignored when module's type isn't android_app, android_test, or android_test_helper_app.
Platform_apis *bool
Aidl struct {
diff --git a/provenance/provenance_singleton.go b/provenance/provenance_singleton.go
index ae96e1f..e49f3d4 100644
--- a/provenance/provenance_singleton.go
+++ b/provenance/provenance_singleton.go
@@ -60,29 +60,32 @@
}
type provenanceInfoSingleton struct {
+ mergedMetaDataFile android.OutputPath
}
-func (b *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) {
+func (p *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) {
allMetaDataFiles := make([]android.Path, 0)
context.VisitAllModulesIf(moduleFilter, func(module android.Module) {
if p, ok := module.(ProvenanceMetadata); ok {
allMetaDataFiles = append(allMetaDataFiles, p.ProvenanceMetaDataFile())
}
})
- mergedMetaDataFile := android.PathForOutput(context, "provenance_metadata.textproto")
+ p.mergedMetaDataFile = android.PathForOutput(context, "provenance_metadata.textproto")
context.Build(pctx, android.BuildParams{
Rule: mergeProvenanceMetaData,
Description: "merge provenance metadata",
Inputs: allMetaDataFiles,
- Output: mergedMetaDataFile,
+ Output: p.mergedMetaDataFile,
})
context.Build(pctx, android.BuildParams{
Rule: blueprint.Phony,
Description: "phony rule of merge provenance metadata",
- Inputs: []android.Path{mergedMetaDataFile},
+ Inputs: []android.Path{p.mergedMetaDataFile},
Output: android.PathForPhony(context, "provenance_metadata"),
})
+
+ context.Phony("droidcore", android.PathForPhony(context, "provenance_metadata"))
}
func moduleFilter(module android.Module) bool {
@@ -110,3 +113,9 @@
return artifactMetaDataFile
}
+
+func (p *provenanceInfoSingleton) MakeVars(ctx android.MakeVarsContext) {
+ ctx.DistForGoal("droidcore", p.mergedMetaDataFile)
+}
+
+var _ android.SingletonMakeVarsProvider = (*provenanceInfoSingleton)(nil)
diff --git a/rust/library_test.go b/rust/library_test.go
index d78dcdd..4633cc7 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -200,23 +200,34 @@
func TestAutoDeps(t *testing.T) {
ctx := testRust(t, `
- rust_library_host {
- name: "libbar",
- srcs: ["bar.rs"],
- crate_name: "bar",
- }
+ rust_library_host {
+ name: "libbar",
+ srcs: ["bar.rs"],
+ crate_name: "bar",
+ }
+ rust_library_host_rlib {
+ name: "librlib_only",
+ srcs: ["bar.rs"],
+ crate_name: "rlib_only",
+ }
rust_library_host {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
- rustlibs: ["libbar"],
+ rustlibs: [
+ "libbar",
+ "librlib_only",
+ ],
}
- rust_ffi_host {
- name: "libfoo.ffi",
- srcs: ["foo.rs"],
- crate_name: "foo",
- rustlibs: ["libbar"],
- }`)
+ rust_ffi_host {
+ name: "libfoo.ffi",
+ srcs: ["foo.rs"],
+ crate_name: "foo",
+ rustlibs: [
+ "libbar",
+ "librlib_only",
+ ],
+ }`)
libfooRlib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_rlib_rlib-std")
libfooDylib := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_dylib")
@@ -239,7 +250,9 @@
if android.InList("libbar.dylib-std", dyn.Module().(*Module).Properties.AndroidMkRlibs) {
t.Errorf("libbar present as rlib dependency in dynamic lib")
}
-
+ if !android.InList("librlib_only.dylib-std", dyn.Module().(*Module).Properties.AndroidMkRlibs) {
+ t.Errorf("librlib_only should be selected by rustlibs as an rlib.")
+ }
}
}
diff --git a/rust/rust.go b/rust/rust.go
index 2a7bdcf..c4fd148 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1368,13 +1368,12 @@
}
// rlibs
+ rlibDepVariations = append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: rlibVariation})
for _, lib := range deps.Rlibs {
depTag := rlibDepTag
lib = cc.RewriteSnapshotLib(lib, cc.GetSnapshot(mod, &snapshotInfo, actx).Rlibs)
- actx.AddVariationDependencies(append(rlibDepVariations, []blueprint.Variation{
- {Mutator: "rust_libraries", Variation: rlibVariation},
- }...), depTag, lib)
+ actx.AddVariationDependencies(rlibDepVariations, depTag, lib)
}
// dylibs
@@ -1386,21 +1385,25 @@
// rustlibs
if deps.Rustlibs != nil && !mod.compiler.Disabled() {
autoDep := mod.compiler.(autoDeppable).autoDep(ctx)
- if autoDep.depTag == rlibDepTag {
- for _, lib := range deps.Rustlibs {
- depTag := autoDep.depTag
- lib = cc.RewriteSnapshotLib(lib, cc.GetSnapshot(mod, &snapshotInfo, actx).Rlibs)
- actx.AddVariationDependencies(append(rlibDepVariations, []blueprint.Variation{
- {Mutator: "rust_libraries", Variation: autoDep.variation},
- }...), depTag, lib)
+ for _, lib := range deps.Rustlibs {
+ if autoDep.depTag == rlibDepTag {
+ // Handle the rlib deptag case
+ addRlibDependency(actx, lib, mod, snapshotInfo, rlibDepVariations)
+ } else {
+ // autoDep.depTag is a dylib depTag. Not all rustlibs may be available as a dylib however.
+ // Check for the existence of the dylib deptag variant. Select it if available,
+ // otherwise select the rlib variant.
+ autoDepVariations := append(commonDepVariations,
+ blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation})
+ if actx.OtherModuleDependencyVariantExists(autoDepVariations, lib) {
+ actx.AddVariationDependencies(autoDepVariations, autoDep.depTag, lib)
+ } else {
+ // If there's no dylib dependency available, try to add the rlib dependency instead.
+ addRlibDependency(actx, lib, mod, snapshotInfo, rlibDepVariations)
+ }
}
- } else {
- actx.AddVariationDependencies(
- append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation}),
- autoDep.depTag, deps.Rustlibs...)
}
}
-
// stdlibs
if deps.Stdlibs != nil {
if mod.compiler.stdLinkage(ctx) == RlibLinkage {
@@ -1476,6 +1479,12 @@
actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), procMacroDepTag, deps.ProcMacros...)
}
+// addRlibDependency will add an rlib dependency, rewriting to the snapshot library if available.
+func addRlibDependency(actx android.BottomUpMutatorContext, lib string, mod *Module, snapshotInfo *cc.SnapshotInfo, variations []blueprint.Variation) {
+ lib = cc.RewriteSnapshotLib(lib, cc.GetSnapshot(mod, &snapshotInfo, actx).Rlibs)
+ actx.AddVariationDependencies(variations, rlibDepTag, lib)
+}
+
func BeginMutator(ctx android.BottomUpMutatorContext) {
if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() {
mod.beginMutator(ctx)
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 4c847a1..4773579 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -188,3 +188,8 @@
"get_clang_version.py",
],
}
+
+sh_binary_host {
+ name: "list_image",
+ src: "list_image.sh",
+}
diff --git a/scripts/list_image.sh b/scripts/list_image.sh
new file mode 100755
index 0000000..0542fa6
--- /dev/null
+++ b/scripts/list_image.sh
@@ -0,0 +1,51 @@
+#! /bin/bash
+
+# Recursively list Android image directory.
+set -eu
+set -o pipefail
+
+function die() { format=$1; shift; printf "$format\n" "$@"; exit 1; }
+
+# Figure out the filer utility.
+declare filer=
+[[ -z "${ANDROID_HOST_OUT:-}" ]] || filer=${ANDROID_HOST_OUT}/bin/debugfs_static
+if [[ "${1:-}" =~ --debugfs_path=(.*) ]]; then
+ filer=${BASH_REMATCH[1]}
+ shift
+fi
+if [[ -z "${filer:-}" ]]; then
+ maybefiler="$(dirname $0)/debugfs_static"
+ [[ ! -x "$maybefiler" ]] || filer="$maybefiler"
+fi
+
+(( $# >0 )) || die "%s [--debugfs_path=<path>] IMAGE" "$0"
+
+[[ -n "${filer:-}" ]] || die "cannot locate 'debugfs' executable: \
+--debugfs_path= is missing, ANDROID_HOST_OUT is not set, \
+and 'debugfs_static' is not colocated with this script"
+declare -r image="$1"
+
+function dolevel() {
+ printf "%s/\n" "$1"
+ # Each line of the file output consists of 6 fields separated with '/'.
+ # The second one contains the file's attributes, and the fifth its name.
+ $filer -R "ls -l -p $1" "$image" 2>/dev/null |\
+ sed -nr 's|^/.*/(.*)/.*/.*/(.+)/.*/$|\2 \1|p' | LANG=C sort | \
+ while read name attr; do
+ [[ "$name" != '.' && "$name" != '..' ]] || continue
+ path="$1/$name"
+ # If the second char of the attributes is '4', it is a directory.
+ if [[ $attr =~ ^.4 ]]; then
+ dolevel "$path"
+ else
+ printf "%s\n" "$path"
+ fi
+ done
+}
+
+# The filer always prints its version on stderr, so we are going
+# to redirect it to the bit bucket. On the other hand, the filer's
+# return code on error is still 0. Let's run it once to without
+# redirecting stderr to see that there is at least one entry.
+$filer -R "ls -l -p" "$image" | grep -q -m1 -P '^/.*/.*/.*/.*/.+/.*/$'
+dolevel .
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index 11311f9..285f156 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -205,6 +205,9 @@
"CCACHE_SLOPPINESS",
"CCACHE_BASEDIR",
"CCACHE_CPP2",
+
+ // LLVM compiler wrapper options
+ "TOOLCHAIN_RUSAGE_OUTPUT",
}
allVars := append(append([]string{
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index 41de6bd..dab1a9b 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -169,6 +169,9 @@
"CCACHE_BASEDIR",
"CCACHE_CPP2",
"CCACHE_DIR",
+
+ // LLVM compiler wrapper options
+ "TOOLCHAIN_RUSAGE_OUTPUT",
}, config.BuildBrokenNinjaUsesEnvVars()...)...)
}