Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01243368 authored by Cole Faust's avatar Cole Faust
Browse files

Allowlist apexer for bp2build

This also introduces a workaround for the fact that
apexer depends on aapt2, but aapt2 doesn't build
with bp2build yet. Aapt2 is removed from apexer's
requirements during bp2build.

Bug: 204244290
Test: ./build/bazel/ci/bp2build.sh
Change-Id: I837597ce035c7d5c06e1a3957166583a7a94b5c7
parent 2320e27e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -329,6 +329,7 @@ var (

		//system/extras/ext4_utils
		"libext4_utils",
		"mke2fs_conf",

		//system/extras/libfec
		"libfec",
@@ -362,7 +363,7 @@ var (
		"linker",       // TODO(b/228316882): cc_binary uses link_crt
		"libdebuggerd", // TODO(b/228314770): support product variable-specific header_libs
		"versioner",    // TODO(b/228313961):  depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library
		"apexer", "apexer_test", // Requires aapt2
		"apexer_test",  // Requires aapt2
		"apexer_test_host_tools",
		"host_apex_verifier",

+12 −2
Original line number Diff line number Diff line
@@ -1177,7 +1177,6 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator

	data := &attrs.Data

	required := depsToLabelList(props.Required)
	archVariantProps := mod.GetArchVariantProperties(ctx, &commonProperties{})

	var enabledProperty bazel.BoolAttribute
@@ -1231,10 +1230,21 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator
		}
	}

	required := depsToLabelList(props.Required)
	for axis, configToProps := range archVariantProps {
		for config, _props := range configToProps {
			if archProps, ok := _props.(*commonProperties); ok {
				required.SetSelectValue(axis, config, depsToLabelList(archProps.Required).Value)
				// TODO(b/234748998) Remove this requiredFiltered workaround when aapt2 converts successfully
				requiredFiltered := archProps.Required
				if name == "apexer" {
					requiredFiltered = make([]string, 0, len(archProps.Required))
					for _, req := range archProps.Required {
						if req != "aapt2" && req != "apexer" {
							requiredFiltered = append(requiredFiltered, req)
						}
					}
				}
				required.SetSelectValue(axis, config, depsToLabelList(requiredFiltered).Value)
				if !neitherHostNorDevice {
					if archProps.Enabled != nil {
						if axis != bazel.OsConfigurationAxis || osSupport[config] {
+8 −4
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ func TestPythonBinaryHostSimple(t *testing.T) {
				"data":    `["files/data.txt"]`,
				"deps":    `[":bar"]`,
				"main":    `"a.py"`,
				"imports": `["."]`,
				"srcs": `[
        "a.py",
        "b/c.py",
@@ -83,6 +84,7 @@ func TestPythonBinaryHostPy2(t *testing.T) {
		expectedBazelTargets: []string{
			makeBazelTarget("py_binary", "foo", attrNameToString{
				"python_version": `"PY2"`,
				"imports":        `["."]`,
				"srcs":           `["a.py"]`,
				"target_compatible_with": `select({
        "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
@@ -116,6 +118,7 @@ func TestPythonBinaryHostPy3(t *testing.T) {
		expectedBazelTargets: []string{
			// python_version is PY3 by default.
			makeBazelTarget("py_binary", "foo", attrNameToString{
				"imports": `["."]`,
				"srcs":    `["a.py"]`,
				"target_compatible_with": `select({
        "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
@@ -148,6 +151,7 @@ func TestPythonBinaryHostArchVariance(t *testing.T) {
				 }`,
		expectedBazelTargets: []string{
			makeBazelTarget("py_binary", "foo-arm", attrNameToString{
				"imports": `["."]`,
				"srcs": `select({
        "//build/bazel/platforms/arch:arm": ["arm.py"],
        "//build/bazel/platforms/arch:x86": ["x86.py"],
+1 −1
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ func (g *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
	var bazelOutputFiles android.Paths
	exportIncludeDirs := map[string]bool{}
	for _, bazelOutputFile := range filePaths {
		bazelOutputFiles = append(bazelOutputFiles, android.PathForBazelOut(ctx, bazelOutputFile))
		bazelOutputFiles = append(bazelOutputFiles, android.PathForBazelOutRelative(ctx, ctx.ModuleDir(), bazelOutputFile))
		exportIncludeDirs[filepath.Dir(bazelOutputFile)] = true
	}
	g.outputFiles = bazelOutputFiles
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ type bazelPythonBinaryAttributes struct {
	Srcs           bazel.LabelListAttribute
	Deps           bazel.LabelListAttribute
	Python_version *string
	Imports        bazel.StringListAttribute
}

func pythonBinaryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
@@ -75,6 +76,7 @@ func pythonBinaryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
		Srcs:           baseAttrs.Srcs,
		Deps:           baseAttrs.Deps,
		Python_version: python_version,
		Imports:        baseAttrs.Imports,
	}

	props := bazel.BazelTargetModuleProperties{
Loading