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

Commit 81b25ed0 authored by Joe Onorato's avatar Joe Onorato
Browse files

Rename aconfig namespace to package.

Bug: 285303012
Test: for x in next trunk trunk_food trunk_staging ; do lunch aosp_panther-$x-eng ; m nothing ; done
Change-Id: I9ee3b1f0207b828557d339d7f50cad77ff16310f
parent 8f557323
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ type DefinitionsModule 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 []string `blueprint:"mutated"`
@@ -64,13 +64,13 @@ func (module *DefinitionsModule) DepsMutator(ctx android.BottomUpMutatorContext)
		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.
	// match our package.
	valuesFromConfig := ctx.Config().ReleaseDeviceConfigValueSets()
	ctx.AddDependency(ctx.Module(), implicitValuesTag, valuesFromConfig...)
}
@@ -98,8 +98,8 @@ func joinAndPrefix(prefix string, values []string) string {

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

var definitionsProviderKey = blueprint.NewProvider(definitionsProviderData{})
@@ -112,7 +112,7 @@ func (module *DefinitionsModule) GenerateAndroidBuildActions(ctx android.ModuleC
			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())
@@ -130,14 +130,14 @@ func (module *DefinitionsModule) GenerateAndroidBuildActions(ctx android.ModuleC
		Description: "device_config_definitions",
		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,
		Package:          module.properties.Package,
		IntermediatePath: intermediatePath,
	})

}
+4 −4
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ func TestDeviceConfigDefinitions(t *testing.T) {
	bp := `
		device_config_definitions {
			name: "module_name",
			namespace: "com.example.package",
			package: "com.example.package",
			srcs: ["foo.aconfig"],
		}
	`
@@ -35,8 +35,8 @@ func TestDeviceConfigDefinitions(t *testing.T) {

	// 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())
	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())
	}
}
+7 −7
Original line number Diff line number Diff line
@@ -51,9 +51,9 @@ var valueSetTag = valueSetType{}

// Provider published by device_config_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 --> device_config_module)
	AvailablePackages map[string]android.Paths
}

var valueSetProviderKey = blueprint.NewProvider(valueSetProviderData{})
@@ -70,10 +70,10 @@ func (module *ValueSetModule) DepsMutator(ctx android.BottomUpMutatorContext) {
}

func (module *ValueSetModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Accumulate the namespaces of the values modules listed, and set that as an
	// Accumulate the packages of the values modules listed, and set that as an
	// valueSetProviderKey provider that device_config 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,
	})
}
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ func TestDeviceConfigValueSet(t *testing.T) {
				device_config_values {
					name: "one",
					srcs: [ "blah.aconfig_values" ],
					namespace: "foo.namespace"
					package: "foo.package"
				}

				device_config_value_set {
@@ -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())
}
+8 −8
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ type ValuesModule 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
	}
}

@@ -47,8 +47,8 @@ func ValuesFactory() android.Module {

// Provider published by device_config_value_set
type valuesProviderData struct {
	// The namespace that this values module values
	Namespace string
	// The package that this values module values
	Package string

	// The values aconfig files, relative to the root of the tree
	Values android.Paths
@@ -57,13 +57,13 @@ type valuesProviderData struct {
var valuesProviderKey = blueprint.NewProvider(valuesProviderData{})

func (module *ValuesModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	if len(module.properties.Namespace) == 0 {
		ctx.PropertyErrorf("namespace", "missing namespace property")
	if len(module.properties.Package) == 0 {
		ctx.PropertyErrorf("package", "missing package property")
	}

	// Provide the our source files list to the device_config_value_set as a list of files
	providerData := valuesProviderData{
		Namespace: module.properties.Namespace,
		Package: module.properties.Package,
		Values:  android.PathsForModuleSrc(ctx, module.properties.Srcs),
	}
	ctx.SetProvider(valuesProviderKey, providerData)
Loading