blob: 110f12a1ccec29b01af73db9426fac9690b98bca [file] [log] [blame]
Joe Onoratofee845a2023-05-09 08:14:14 -07001// Copyright 2023 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package device_config
16
17import (
18 "android/soong/android"
19 "github.com/google/blueprint"
20)
21
22// Properties for "device_config_value"
23type ValuesModule struct {
24 android.ModuleBase
25 android.DefaultableModuleBase
26
27 properties struct {
28 // aconfig files, relative to this Android.bp file
29 Srcs []string `android:"path"`
30
31 // Release config flag namespace
32 Namespace string
33 }
34}
35
36func ValuesFactory() android.Module {
37 module := &ValuesModule{}
38
39 android.InitAndroidModule(module)
40 android.InitDefaultableModule(module)
41 module.AddProperties(&module.properties)
42 // TODO: bp2build
43 //android.InitBazelModule(module)
44
45 return module
46}
47
48// Provider published by device_config_value_set
49type valuesProviderData struct {
50 // The namespace that this values module values
51 Namespace string
52
53 // The values aconfig files, relative to the root of the tree
54 Values android.Paths
55}
56
57var valuesProviderKey = blueprint.NewProvider(valuesProviderData{})
58
59func (module *ValuesModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
60 if len(module.properties.Namespace) == 0 {
61 ctx.PropertyErrorf("namespace", "missing namespace property")
62 }
63
64 // Provide the our source files list to the device_config_value_set as a list of files
65 providerData := valuesProviderData{
66 Namespace: module.properties.Namespace,
67 Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
68 }
69 ctx.SetProvider(valuesProviderKey, providerData)
70}