blob: 6d235c4840cceb968894b7ebd3c049f394bf8040 [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
22var (
23 pctx = android.NewPackageContext("android/soong/device_config")
24
25 // For device_config_definitions: Generate cache file
26 // TODO: Restat
27 aconfigRule = pctx.AndroidStaticRule("aconfig",
28 blueprint.RuleParams{
29 Command: `${aconfig} create-cache` +
MÃ¥rten Kongstad9feb96d2023-05-31 12:55:40 +020030 ` --package ${namespace}` +
Joe Onoratofee845a2023-05-09 08:14:14 -070031 ` --declarations ${in}` +
32 ` ${values}` +
33 ` --cache ${out}.tmp` +
34 ` && ( if cmp -s ${out}.tmp ; then rm ${out}.tmp ; else mv ${out}.tmp ${out} ; fi )`,
35 // ` --build-id ${release_version}` +
36 CommandDeps: []string{
37 "${aconfig}",
38 },
39 Restat: true,
40 }, "release_version", "namespace", "values")
41
42 // For device_config_definitions: Generate java file
43 srcJarRule = pctx.AndroidStaticRule("aconfig_srcjar",
44 blueprint.RuleParams{
45 Command: `rm -rf ${out}.tmp` +
46 ` && mkdir -p ${out}.tmp` +
47 ` && ${aconfig} create-java-lib` +
48 ` --cache ${in}` +
49 ` --out ${out}.tmp` +
50 ` && $soong_zip -write_if_changed -jar -o ${out} -C ${out}.tmp -D ${out}.tmp` +
51 ` && rm -rf ${out}.tmp`,
52 CommandDeps: []string{
53 "$aconfig",
54 "$soong_zip",
55 },
56 Restat: true,
57 })
58)
59
60func init() {
61 registerBuildComponents(android.InitRegistrationContext)
62}
63
64func registerBuildComponents(ctx android.RegistrationContext) {
65 ctx.RegisterModuleType("device_config_definitions", DefinitionsFactory)
66 ctx.RegisterModuleType("device_config_values", ValuesFactory)
67 ctx.RegisterModuleType("device_config_value_set", ValueSetFactory)
68 pctx.HostBinToolVariable("aconfig", "aconfig")
69 pctx.HostBinToolVariable("soong_zip", "soong_zip")
70}