blob: 73a89514d63c3109e406875b0e96a95140597b23 [file] [log] [blame]
Yu Liueae7b362023-11-16 17:05:47 -08001// 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 codegen
16
17import (
18 "android/soong/android"
19
20 "github.com/google/blueprint"
21)
22
23var (
24 pctx = android.NewPackageContext("android/soong/aconfig/codegen")
25
26 // For java_aconfig_library: Generate java library
27 javaRule = pctx.AndroidStaticRule("java_aconfig_library",
28 blueprint.RuleParams{
29 Command: `rm -rf ${out}.tmp` +
30 ` && mkdir -p ${out}.tmp` +
31 ` && ${aconfig} create-java-lib` +
32 ` --mode ${mode}` +
33 ` --cache ${in}` +
34 ` --out ${out}.tmp` +
35 ` && $soong_zip -write_if_changed -jar -o ${out} -C ${out}.tmp -D ${out}.tmp` +
36 ` && rm -rf ${out}.tmp`,
37 CommandDeps: []string{
38 "$aconfig",
39 "$soong_zip",
40 },
41 Restat: true,
42 }, "mode")
43
44 // For cc_aconfig_library: Generate C++ library
45 cppRule = pctx.AndroidStaticRule("cc_aconfig_library",
46 blueprint.RuleParams{
47 Command: `rm -rf ${gendir}` +
48 ` && mkdir -p ${gendir}` +
49 ` && ${aconfig} create-cpp-lib` +
50 ` --mode ${mode}` +
51 ` --cache ${in}` +
52 ` --out ${gendir}`,
53 CommandDeps: []string{
54 "$aconfig",
55 },
56 }, "gendir", "mode")
57
58 // For rust_aconfig_library: Generate Rust library
59 rustRule = pctx.AndroidStaticRule("rust_aconfig_library",
60 blueprint.RuleParams{
61 Command: `rm -rf ${gendir}` +
62 ` && mkdir -p ${gendir}` +
63 ` && ${aconfig} create-rust-lib` +
64 ` --mode ${mode}` +
65 ` --cache ${in}` +
66 ` --out ${gendir}`,
67 CommandDeps: []string{
68 "$aconfig",
69 },
70 }, "gendir", "mode")
71)
72
73func init() {
74 RegisterBuildComponents(android.InitRegistrationContext)
75 pctx.HostBinToolVariable("aconfig", "aconfig")
76 pctx.HostBinToolVariable("soong_zip", "soong_zip")
77}
78
79func RegisterBuildComponents(ctx android.RegistrationContext) {
Jihoon Kang2a43e562024-02-12 19:05:12 +000080 ctx.RegisterModuleType("aconfig_declarations_group", AconfigDeclarationsGroupFactory)
Yu Liueae7b362023-11-16 17:05:47 -080081 ctx.RegisterModuleType("cc_aconfig_library", CcAconfigLibraryFactory)
82 ctx.RegisterModuleType("java_aconfig_library", JavaDeclarationsLibraryFactory)
83 ctx.RegisterModuleType("rust_aconfig_library", RustAconfigLibraryFactory)
84}