• 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    ],
68
69    static_libs: [
70        "libgmock_host",
71    ],
72
73    shared_libs: [
74        "libstats_proto_host",
75        "libprotobuf-cpp-full",
76    ],
77
78    proto: {
79        type: "full",
80        include_dirs: [
81            "external/protobuf/src",
82        ],
83    },
84}
85
86// ==========================================================
87// Native library
88// ==========================================================
89genrule {
90    name: "statslog.h",
91    tools: ["stats-log-api-gen"],
92    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog.h",
93    out: [
94        "statslog.h",
95    ],
96}
97
98genrule {
99    name: "statslog.cpp",
100    tools: ["stats-log-api-gen"],
101    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog.cpp",
102    out: [
103        "statslog.cpp",
104    ],
105}
106
107cc_library {
108    name: "libstatslog",
109    host_supported: true,
110    generated_sources: [
111        "statslog.cpp",
112    ],
113    generated_headers: [
114        "statslog.h"
115    ],
116    cflags: [
117        "-Wall",
118        "-Werror",
119    ],
120    export_generated_headers: [
121        "statslog.h"
122    ],
123    shared_libs: [
124        "liblog",
125        "libcutils",
126    ],
127    target: {
128        android: {
129            shared_libs: [
130                "libstatssocket",
131                "libstatspull",
132            ],
133            export_shared_lib_headers: [
134                 "libstatssocket",
135                 "libstatspull",
136            ],
137        },
138        host: {
139            static_libs: [
140                "libstatssocket",
141                "libstatspull",
142                "statsd-aidl-ndk_platform",
143            ],
144            shared_libs: ["libbinder_ndk"],
145            export_static_lib_headers: [
146                "libstatssocket",
147                "libstatspull",
148            ],
149        },
150        darwin: {
151            enabled: false,
152        },
153    },
154}
155
156// ==========================================================
157// Rust library
158// ==========================================================
159
160genrule {
161    name: "statslog_header.rs",
162    tools: ["stats-log-api-gen"],
163    cmd: "$(location stats-log-api-gen) --rustHeader $(genDir)/statslog_header.rs",
164    out: [
165        "statslog_header.rs",
166    ],
167}
168
169rust_library {
170    name: "libstatslog_rust_header",
171    crate_name: "statslog_rust_header",
172    srcs: [
173        "rust_header_wrapper.rs",
174        ":statslog_header.rs",
175    ],
176    rustlibs: [
177        "libstatspull_bindgen",
178        "libthiserror",
179    ],
180}
181
182genrule {
183    name: "statslog.rs",
184    tools: ["stats-log-api-gen"],
185    cmd: "$(location stats-log-api-gen) --rust $(genDir)/statslog.rs",
186    out: [
187        "statslog.rs",
188    ],
189}
190
191rust_library {
192    name: "libstatslog_rust",
193    crate_name: "statslog_rust",
194    srcs: [
195        "rust_wrapper.rs",
196        ":statslog.rs",
197    ],
198    rustlibs: [
199        "libstatslog_rust_header",
200        "libstatspull_bindgen",
201    ],
202}
203