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

Commit 9cb6a722 authored by Joe Onorato's avatar Joe Onorato Committed by Gerrit Code Review
Browse files

Merge changes from topic "aconfig_renames"

* changes:
  Rename device_config --> aconfig and definitions --> declarations
  Rename aconfig namespace to package.
parents 4a241d08 981c9262
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ package {
}

bootstrap_go_package {
    name: "soong-device_config",
    pkgPath: "android/soong/device_config",
    name: "soong-aconfig",
    pkgPath: "android/soong/aconfig",
    deps: [
        "blueprint",
        "blueprint-pathtools",
@@ -16,17 +16,17 @@ bootstrap_go_package {
        "soong-java",
    ],
    srcs: [
        "device_config_definitions.go",
        "device_config_values.go",
        "device_config_value_set.go",
        "aconfig_declarations.go",
        "aconfig_values.go",
        "aconfig_value_set.go",
        "init.go",
        "java_device_config_definitions_library.go",
        "java_aconfig_library.go",
        "testing.go",
    ],
    testSrcs: [
        "device_config_definitions_test.go",
        "device_config_values_test.go",
        "device_config_value_set_test.go",
        "aconfig_declarations_test.go",
        "aconfig_values_test.go",
        "aconfig_value_set_test.go",
    ],
    pluginFor: ["soong_build"],
}
+30 −30
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package device_config
package aconfig

import (
	"android/soong/android"
@@ -21,27 +21,27 @@ import (
	"strings"
)

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

	// Properties for "device_config_definitions"
	// Properties for "aconfig_declarations"
	properties struct {
		// aconfig files, relative to this Android.bp file
		Srcs []string `android:"path"`

		// Release config flag namespace
		Namespace string
		// Release config flag package
		Package string

		// Values from TARGET_RELEASE / RELEASE_DEVICE_CONFIG_VALUE_SETS
		// Values from TARGET_RELEASE / RELEASE_ACONFIG_VALUE_SETS
		Values []string `blueprint:"mutated"`
	}

	intermediatePath android.WritablePath
}

func DefinitionsFactory() android.Module {
	module := &DefinitionsModule{}
func DeclarationsFactory() android.Module {
	module := &DeclarationsModule{}

	android.InitAndroidModule(module)
	android.InitDefaultableModule(module)
@@ -58,24 +58,24 @@ type implicitValuesTagType struct {

var implicitValuesTag = implicitValuesTagType{}

func (module *DefinitionsModule) DepsMutator(ctx android.BottomUpMutatorContext) {
func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext) {
	// Validate Properties
	if len(module.properties.Srcs) == 0 {
		ctx.PropertyErrorf("srcs", "missing source files")
		return
	}
	if len(module.properties.Namespace) == 0 {
		ctx.PropertyErrorf("namespace", "missing namespace property")
	if len(module.properties.Package) == 0 {
		ctx.PropertyErrorf("package", "missing package property")
	}

	// Add a dependency on the device_config_value_sets defined in
	// RELEASE_DEVICE_CONFIG_VALUE_SETS, and add any device_config_values that
	// match our namespace.
	valuesFromConfig := ctx.Config().ReleaseDeviceConfigValueSets()
	// Add a dependency on the aconfig_value_sets defined in
	// RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that
	// match our package.
	valuesFromConfig := ctx.Config().ReleaseAconfigValueSets()
	ctx.AddDependency(ctx.Module(), implicitValuesTag, valuesFromConfig...)
}

func (module *DefinitionsModule) OutputFiles(tag string) (android.Paths, error) {
func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
	switch tag {
	case "":
		// The default output of this module is the intermediates format, which is
@@ -83,7 +83,7 @@ func (module *DefinitionsModule) OutputFiles(tag string) (android.Paths, error)
		// correctly.
		return []android.Path{module.intermediatePath}, nil
	default:
		return nil, fmt.Errorf("unsupported device_config_definitions module reference tag %q", tag)
		return nil, fmt.Errorf("unsupported aconfig_declarations module reference tag %q", tag)
	}
}

@@ -96,23 +96,23 @@ func joinAndPrefix(prefix string, values []string) string {
	return sb.String()
}

// Provider published by device_config_value_set
type definitionsProviderData struct {
	namespace        string
	intermediatePath android.WritablePath
// Provider published by aconfig_value_set
type declarationsProviderData struct {
	Package          string
	IntermediatePath android.WritablePath
}

var definitionsProviderKey = blueprint.NewProvider(definitionsProviderData{})
var declarationsProviderKey = blueprint.NewProvider(declarationsProviderData{})

func (module *DefinitionsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Get the values that came from the global RELEASE_DEVICE_CONFIG_VALUE_SETS flag
func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
	ctx.VisitDirectDeps(func(dep android.Module) {
		if !ctx.OtherModuleHasProvider(dep, valueSetProviderKey) {
			// Other modules get injected as dependencies too, for example the license modules
			return
		}
		depData := ctx.OtherModuleProvider(dep, valueSetProviderKey).(valueSetProviderData)
		valuesFiles, ok := depData.AvailableNamespaces[module.properties.Namespace]
		valuesFiles, ok := depData.AvailablePackages[module.properties.Package]
		if ok {
			for _, path := range valuesFiles {
				module.properties.Values = append(module.properties.Values, path.String())
@@ -127,17 +127,17 @@ func (module *DefinitionsModule) GenerateAndroidBuildActions(ctx android.ModuleC
		Rule:        aconfigRule,
		Inputs:      inputFiles,
		Output:      intermediatePath,
		Description: "device_config_definitions",
		Description: "aconfig_declarations",
		Args: map[string]string{
			"release_version": ctx.Config().ReleaseVersion(),
			"namespace":       module.properties.Namespace,
			"package":         module.properties.Package,
			"values":          joinAndPrefix(" --values ", module.properties.Values),
		},
	})

	ctx.SetProvider(definitionsProviderKey, definitionsProviderData{
		namespace:        module.properties.Namespace,
		intermediatePath: intermediatePath,
	ctx.SetProvider(declarationsProviderKey, declarationsProviderData{
		Package:          module.properties.Package,
		IntermediatePath: intermediatePath,
	})

}
+9 −9
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package device_config
package aconfig

import (
	"strings"
@@ -21,22 +21,22 @@ import (
	"android/soong/android"
)

func TestDeviceConfigDefinitions(t *testing.T) {
func TestAconfigDeclarations(t *testing.T) {
	bp := `
		device_config_definitions {
		aconfig_declarations {
			name: "module_name",
			namespace: "com.example.package",
			package: "com.example.package",
			srcs: ["foo.aconfig"],
		}
	`
	result := runTest(t, android.FixtureExpectsNoErrors, bp)

	module := result.ModuleForTests("module_name", "").Module().(*DefinitionsModule)
	module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)

	// Check that the provider has the right contents
	depData := result.ModuleProvider(module, definitionsProviderKey).(definitionsProviderData)
	android.AssertStringEquals(t, "namespace", depData.namespace, "com.example.package")
	if !strings.HasSuffix(depData.intermediatePath.String(), "/intermediate.pb") {
		t.Errorf("Missing intermediates path in provider: %s", depData.intermediatePath.String())
	depData := result.ModuleProvider(module, declarationsProviderKey).(declarationsProviderData)
	android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
	if !strings.HasSuffix(depData.IntermediatePath.String(), "/intermediate.pb") {
		t.Errorf("Missing intermediates path in provider: %s", depData.IntermediatePath.String())
	}
}
+13 −13
Original line number Diff line number Diff line
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package device_config
package aconfig

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

// Properties for "device_config_value_set"
// Properties for "aconfig_value_set"
type ValueSetModule struct {
	android.ModuleBase
	android.DefaultableModuleBase

	properties struct {
		// device_config_values modules
		// aconfig_values modules
		Values []string
	}
}
@@ -49,11 +49,11 @@ type valueSetType struct {

var valueSetTag = valueSetType{}

// Provider published by device_config_value_set
// Provider published by aconfig_value_set
type valueSetProviderData struct {
	// The namespace of each of the
	// (map of namespace --> device_config_module)
	AvailableNamespaces map[string]android.Paths
	// The package of each of the
	// (map of package --> aconfig_module)
	AvailablePackages map[string]android.Paths
}

var valueSetProviderKey = blueprint.NewProvider(valueSetProviderData{})
@@ -63,17 +63,17 @@ func (module *ValueSetModule) DepsMutator(ctx android.BottomUpMutatorContext) {
	for _, dep := range deps {
		_, ok := dep.(*ValuesModule)
		if !ok {
			ctx.PropertyErrorf("values", "values must be a device_config_values module")
			ctx.PropertyErrorf("values", "values must be a aconfig_values module")
			return
		}
	}
}

func (module *ValueSetModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Accumulate the namespaces of the values modules listed, and set that as an
	// valueSetProviderKey provider that device_config modules can read and use
	// Accumulate the packages of the values modules listed, and set that as an
	// valueSetProviderKey provider that aconfig modules can read and use
	// to append values to their aconfig actions.
	namespaces := make(map[string]android.Paths)
	packages := make(map[string]android.Paths)
	ctx.VisitDirectDeps(func(dep android.Module) {
		if !ctx.OtherModuleHasProvider(dep, valuesProviderKey) {
			// Other modules get injected as dependencies too, for example the license modules
@@ -83,10 +83,10 @@ func (module *ValueSetModule) GenerateAndroidBuildActions(ctx android.ModuleCont

		srcs := make([]android.Path, len(depData.Values))
		copy(srcs, depData.Values)
		namespaces[depData.Namespace] = srcs
		packages[depData.Package] = srcs

	})
	ctx.SetProvider(valueSetProviderKey, valueSetProviderData{
		AvailableNamespaces: namespaces,
		AvailablePackages: packages,
	})
}
+6 −6
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package device_config
package aconfig

import (
	"testing"
@@ -20,15 +20,15 @@ import (
	"android/soong/android"
)

func TestDeviceConfigValueSet(t *testing.T) {
func TestAconfigValueSet(t *testing.T) {
	bp := `
				device_config_values {
				aconfig_values {
					name: "one",
					srcs: [ "blah.aconfig_values" ],
					namespace: "foo.namespace"
					package: "foo.package"
				}

				device_config_value_set {
				aconfig_value_set {
					name: "module_name",
          values: [ "one" ],
				}
@@ -39,5 +39,5 @@ func TestDeviceConfigValueSet(t *testing.T) {

	// Check that the provider has the right contents
	depData := result.ModuleProvider(module, valueSetProviderKey).(valueSetProviderData)
	android.AssertStringEquals(t, "AvailableNamespaces", "blah.aconfig_values", depData.AvailableNamespaces["foo.namespace"][0].String())
	android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String())
}
Loading