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
This commit is contained in:
Joe Onorato 2023-06-21 13:49:37 -07:00
parent 8f55732317
commit 81b25ed02b
8 changed files with 37 additions and 37 deletions

View file

@ -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,
})
}

View file

@ -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())
}
}

View file

@ -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,
})
}

View file

@ -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())
}

View file

@ -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,14 +57,14 @@ 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,
Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
Package: module.properties.Package,
Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
}
ctx.SetProvider(valuesProviderKey, providerData)
}

View file

@ -25,7 +25,7 @@ func TestDeviceConfigValues(t *testing.T) {
device_config_values {
name: "module_name",
srcs: [ "blah.aconfig_values" ],
namespace: "foo.namespace"
package: "foo.package"
}
`
result := runTest(t, android.FixtureExpectsNoErrors, bp)
@ -34,6 +34,6 @@ func TestDeviceConfigValues(t *testing.T) {
// Check that the provider has the right contents
depData := result.ModuleProvider(module, valuesProviderKey).(valuesProviderData)
android.AssertStringEquals(t, "namespace", "foo.namespace", depData.Namespace)
android.AssertStringEquals(t, "package", "foo.package", depData.Package)
android.AssertPathsEndWith(t, "srcs", []string{"blah.aconfig_values"}, depData.Values)
}

View file

@ -26,7 +26,7 @@ var (
aconfigRule = pctx.AndroidStaticRule("aconfig",
blueprint.RuleParams{
Command: `${aconfig} create-cache` +
` --package ${namespace}` +
` --package ${package}` +
` --declarations ${in}` +
` ${values}` +
` --cache ${out}.tmp` +
@ -36,7 +36,7 @@ var (
"${aconfig}",
},
Restat: true,
}, "release_version", "namespace", "values")
}, "release_version", "package", "values")
// For java_device_config_definitions_library: Generate java file
srcJarRule = pctx.AndroidStaticRule("aconfig_srcjar",

View file

@ -62,7 +62,7 @@ func (callbacks *JavaDeviceConfigDefinitionsLibraryCallbacks) GenerateSourceJarB
srcJarPath := android.PathForModuleGen(ctx, ctx.ModuleName()+".srcjar")
ctx.Build(pctx, android.BuildParams{
Rule: srcJarRule,
Input: definitions.intermediatePath,
Input: definitions.IntermediatePath,
Output: srcJarPath,
Description: "device_config.srcjar",
})