• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// ==========================================================
18// Build the host executable: stats-log-api-gen
19// ==========================================================
20package {
21    default_applicable_licenses: ["Android-Apache-2.0"],
22}
23
24cc_binary_host {
25    name: "stats-log-api-gen",
26    srcs: [
27        "Collation.cpp",
28        "java_writer.cpp",
29        "java_writer_q.cpp",
30        "main.cpp",
31        "native_writer.cpp",
32        "rust_writer.cpp",
33        "utils.cpp",
34    ],
35    cflags: [
36        "-Wall",
37        "-Werror",
38    ],
39
40    shared_libs: [
41        "libstats_proto_host",
42        "libprotobuf-cpp-full",
43        "libbase",
44    ],
45
46    proto: {
47        type: "full",
48    },
49}
50
51// ==========================================================
52// Build the host test executable: stats-log-api-gen
53// ==========================================================
54cc_test_host {
55    name: "stats-log-api-gen-test",
56    cflags: [
57        "-Wall",
58        "-Wextra",
59        "-Werror",
60        "-g",
61        "-DUNIT_TEST",
62    ],
63    srcs: [
64        "Collation.cpp",
65        "test_collation.cpp",
66        "test.proto",
67        "test_feature_atoms.proto",
68        "utils.cpp",
69    ],
70
71    static_libs: [
72        "libgmock_host",
73    ],
74
75    shared_libs: [
76        "libstats_proto_host",
77        "libprotobuf-cpp-full",
78    ],
79
80    proto: {
81        type: "full",
82        include_dirs: [
83            "external/protobuf/src",
84        ],
85    },
86}
87
88// ==========================================================
89// Native library
90// ==========================================================
91genrule {
92    name: "statslog.h",
93    tools: ["stats-log-api-gen"],
94    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog.h",
95    out: [
96        "statslog.h",
97    ],
98}
99
100genrule {
101    name: "statslog.cpp",
102    tools: ["stats-log-api-gen"],
103    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog.cpp",
104    out: [
105        "statslog.cpp",
106    ],
107}
108
109cc_library {
110    name: "libstatslog",
111    host_supported: true,
112    generated_sources: [
113        "statslog.cpp",
114    ],
115    generated_headers: [
116        "statslog.h"
117    ],
118    cflags: [
119        "-Wall",
120        "-Werror",
121    ],
122    export_generated_headers: [
123        "statslog.h"
124    ],
125    shared_libs: [
126        "liblog",
127        "libcutils",
128    ],
129    target: {
130        android: {
131            shared_libs: [
132                "libstatssocket",
133                "libstatspull",
134            ],
135            export_shared_lib_headers: [
136                 "libstatssocket",
137                 "libstatspull",
138            ],
139        },
140        host: {
141            static_libs: [
142                "libstatssocket",
143                "libstatspull",
144                "statsd-aidl-ndk",
145            ],
146            shared_libs: ["libbinder_ndk"],
147            export_static_lib_headers: [
148                "libstatssocket",
149                "libstatspull",
150            ],
151        },
152        darwin: {
153            enabled: false,
154        },
155    },
156}
157
158// ==========================================================
159// Rust library
160// ==========================================================
161
162genrule {
163    name: "statslog_header.rs",
164    tools: ["stats-log-api-gen"],
165    cmd: "$(location stats-log-api-gen) --rustHeader $(genDir)/statslog_header.rs --rustHeaderCrate statslog_rust_header",
166    out: [
167        "statslog_header.rs",
168    ],
169}
170
171rust_library {
172    name: "libstatslog_rust_header",
173    crate_name: "statslog_rust_header",
174    srcs: [
175        "rust_header_wrapper.rs",
176        ":statslog_header.rs",
177    ],
178    rustlibs: [
179        "libstatspull_bindgen",
180        "libthiserror",
181    ],
182    apex_available: [
183        "com.android.virt",
184    ],
185}
186
187genrule {
188    name: "statslog.rs",
189    tools: ["stats-log-api-gen"],
190    cmd: "$(location stats-log-api-gen) --rust $(genDir)/statslog.rs --rustHeaderCrate statslog_rust_header",
191    out: [
192        "statslog.rs",
193    ],
194}
195
196rust_library {
197    name: "libstatslog_rust",
198    crate_name: "statslog_rust",
199    srcs: [
200        "rust_wrapper.rs",
201        ":statslog.rs",
202    ],
203    rustlibs: [
204        "libstatslog_rust_header",
205        "libstatspull_bindgen",
206    ],
207    apex_available: [
208        "com.android.virt",
209    ],
210}
211