blob: 2cf921a9b58216a99e344d5a90671084f8c23d4b [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
Joe Onorato81b25ed2023-06-21 13:49:37 -070031 // Release config flag package
32 Package string
Joe Onoratofee845a2023-05-09 08:14:14 -070033 }
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 {
Joe Onorato81b25ed2023-06-21 13:49:37 -070050 // The package that this values module values
51 Package string
Joe Onoratofee845a2023-05-09 08:14:14 -070052
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) {
Joe Onorato81b25ed2023-06-21 13:49:37 -070060 if len(module.properties.Package) == 0 {
61 ctx.PropertyErrorf("package", "missing package property")
Joe Onoratofee845a2023-05-09 08:14:14 -070062 }
63
64 // Provide the our source files list to the device_config_value_set as a list of files
65 providerData := valuesProviderData{
Joe Onorato81b25ed2023-06-21 13:49:37 -070066 Package: module.properties.Package,
67 Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
Joe Onoratofee845a2023-05-09 08:14:14 -070068 }
69 ctx.SetProvider(valuesProviderKey, providerData)
70}