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

Commit e6153b54 authored by Yu Liu's avatar Yu Liu Committed by Gerrit Code Review
Browse files

Merge "Support aconfig_declarations, aconfig_values and aconfig_value_set" into main

parents 3671c385 2cc802a4
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -15,16 +15,18 @@
package aconfig

import (
	"android/soong/android"
	"fmt"
	"strings"

	"android/soong/android"
	"android/soong/bazel"
	"github.com/google/blueprint"
)

type DeclarationsModule struct {
	android.ModuleBase
	android.DefaultableModuleBase
	android.BazelModuleBase

	// Properties for "aconfig_declarations"
	properties struct {
@@ -47,8 +49,7 @@ func DeclarationsFactory() android.Module {
	android.InitAndroidModule(module)
	android.InitDefaultableModule(module)
	module.AddProperties(&module.properties)
	// TODO: bp2build
	//android.InitBazelModule(module)
	android.InitBazelModule(module)

	return module
}
@@ -73,7 +74,9 @@ func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext
	// RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that
	// match our package.
	valuesFromConfig := ctx.Config().ReleaseAconfigValueSets()
	ctx.AddDependency(ctx.Module(), implicitValuesTag, valuesFromConfig...)
	if valuesFromConfig != "" {
		ctx.AddDependency(ctx.Module(), implicitValuesTag, valuesFromConfig)
	}
}

func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
@@ -159,3 +162,26 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
	})

}

type bazelAconfigDeclarationsAttributes struct {
	Srcs    bazel.LabelListAttribute
	Package string
}

func (module *DeclarationsModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
	if ctx.ModuleType() != "aconfig_declarations" {
		return
	}
	srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, module.properties.Srcs))

	attrs := bazelAconfigDeclarationsAttributes{
		Srcs:    srcs,
		Package: module.properties.Package,
	}
	props := bazel.BazelTargetModuleProperties{
		Rule_class:        "aconfig_declarations",
		Bzl_load_location: "//build/bazel/rules/aconfig:aconfig_declarations.bzl",
	}

	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, &attrs)
}
+23 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package aconfig

import (
	"android/soong/android"
	"android/soong/bazel"
	"github.com/google/blueprint"
)

@@ -23,6 +24,7 @@ import (
type ValueSetModule struct {
	android.ModuleBase
	android.DefaultableModuleBase
	android.BazelModuleBase

	properties struct {
		// aconfig_values modules
@@ -36,8 +38,7 @@ func ValueSetFactory() android.Module {
	android.InitAndroidModule(module)
	android.InitDefaultableModule(module)
	module.AddProperties(&module.properties)
	// TODO: bp2build
	//android.InitBazelModule(module)
	android.InitBazelModule(module)

	return module
}
@@ -90,3 +91,23 @@ func (module *ValueSetModule) GenerateAndroidBuildActions(ctx android.ModuleCont
		AvailablePackages: packages,
	})
}

type bazelAconfigValueSetAttributes struct {
	Values bazel.LabelListAttribute
}

func (module *ValueSetModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
	if ctx.ModuleType() != "aconfig_value_set" {
		return
	}

	attrs := bazelAconfigValueSetAttributes{
		Values: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, module.properties.Values)),
	}
	props := bazel.BazelTargetModuleProperties{
		Rule_class:        "aconfig_value_set",
		Bzl_load_location: "//build/bazel/rules/aconfig:aconfig_value_set.bzl",
	}

	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, &attrs)
}
+27 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package aconfig

import (
	"android/soong/android"
	"android/soong/bazel"
	"github.com/google/blueprint"
)

@@ -23,6 +24,7 @@ import (
type ValuesModule struct {
	android.ModuleBase
	android.DefaultableModuleBase
	android.BazelModuleBase

	properties struct {
		// aconfig files, relative to this Android.bp file
@@ -39,8 +41,7 @@ func ValuesFactory() android.Module {
	android.InitAndroidModule(module)
	android.InitDefaultableModule(module)
	module.AddProperties(&module.properties)
	// TODO: bp2build
	//android.InitBazelModule(module)
	android.InitBazelModule(module)

	return module
}
@@ -68,3 +69,27 @@ func (module *ValuesModule) GenerateAndroidBuildActions(ctx android.ModuleContex
	}
	ctx.SetProvider(valuesProviderKey, providerData)
}

type bazelAconfigValuesAttributes struct {
	Srcs    bazel.LabelListAttribute
	Package string
}

func (module *ValuesModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
	if ctx.ModuleType() != "aconfig_values" {
		return
	}

	srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, module.properties.Srcs))

	attrs := bazelAconfigValuesAttributes{
		Srcs:    srcs,
		Package: module.properties.Package,
	}
	props := bazel.BazelTargetModuleProperties{
		Rule_class:        "aconfig_values",
		Bzl_load_location: "//build/bazel/rules/aconfig:aconfig_values.bzl",
	}

	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, &attrs)
}
+2 −2
Original line number Diff line number Diff line
@@ -97,12 +97,12 @@ var (
)

func init() {
	registerBuildComponents(android.InitRegistrationContext)
	RegisterBuildComponents(android.InitRegistrationContext)
	pctx.HostBinToolVariable("aconfig", "aconfig")
	pctx.HostBinToolVariable("soong_zip", "soong_zip")
}

func registerBuildComponents(ctx android.RegistrationContext) {
func RegisterBuildComponents(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("aconfig_declarations", DeclarationsFactory)
	ctx.RegisterModuleType("aconfig_values", ValuesFactory)
	ctx.RegisterModuleType("aconfig_value_set", ValueSetFactory)
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import (
	"android/soong/android"
)

var PrepareForTestWithAconfigBuildComponents = android.FixtureRegisterWithContext(registerBuildComponents)
var PrepareForTestWithAconfigBuildComponents = android.FixtureRegisterWithContext(RegisterBuildComponents)

func runTest(t *testing.T, errorHandler android.FixtureErrorHandler, bp string) *android.TestResult {
	return android.GroupFixturePreparers(PrepareForTestWithAconfigBuildComponents).
Loading