xref: /aosp_15_r20/external/pigweed/pw_bluetooth/Android.bp (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1// Copyright 2024 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7//     https://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, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15package {
16    default_applicable_licenses: ["external_pigweed_license"],
17}
18
19filegroup {
20    name: "pw_bluetooth_emboss_definitions",
21    srcs: [
22        "public/pw_bluetooth/att.emb",
23        "public/pw_bluetooth/hci_android.emb",
24        "public/pw_bluetooth/hci_commands.emb",
25        "public/pw_bluetooth/hci_common.emb",
26        "public/pw_bluetooth/hci_data.emb",
27        "public/pw_bluetooth/hci_events.emb",
28        "public/pw_bluetooth/hci_h4.emb",
29        "public/pw_bluetooth/l2cap_frames.emb",
30    ],
31}
32
33// Generates an emboss header file for a pw_bluetooth emboss definition. All
34// files imported by the emboss definition must have the pw_bluetooth prefix:
35//
36// import "pw_bluetooth/<import_file_name>.emb"
37//
38// Since the rule does not know the path of the import files, it copies all
39// input files into a temp $(genDir)/pw_bluetooth directory and uses $(genDir)
40// as the import-dir.
41//
42// $(in) Emboss definition source file for which to generate the header file
43// followed by any .emb imports of the source file.
44// $(out) The generated header file.
45genrule_defaults {
46    name: "pw_bluetooth_generate_emboss_header",
47    cmd: "in_files=($(in)) && prefix=pw_bluetooth && " +
48        "mkdir -p $${prefix} && cp -t $${prefix} $(in) && " +
49        "python3 $(location embossc_runner_py) " +
50        "$(location :embossc_script) " +
51        "--generate cc " +
52        "--no-cc-enum-traits " +
53        "--import-dir=$(genDir) " +
54        "--output-file=$(out) " +
55        "$${in_files[0]}",
56    tools: [
57        "embossc_runner_py",
58    ],
59    tool_files: [
60        ":embossc_script",
61    ],
62}
63
64genrule {
65    name: "pw_bluetooth_generate_emboss_att",
66    defaults: [
67        "pw_bluetooth_generate_emboss_header",
68    ],
69    srcs: [
70        "public/pw_bluetooth/att.emb",
71        "public/pw_bluetooth/hci_data.emb",
72        "public/pw_bluetooth/l2cap_frames.emb",
73    ],
74    out: [
75        "pw_bluetooth/att.emb.h",
76    ],
77}
78
79genrule {
80    name: "pw_bluetooth_generate_emboss_hci_android",
81    defaults: [
82        "pw_bluetooth_generate_emboss_header",
83    ],
84    srcs: [
85        "public/pw_bluetooth/hci_android.emb",
86        "public/pw_bluetooth/hci_common.emb",
87    ],
88    out: [
89        "pw_bluetooth/hci_android.emb.h",
90    ],
91}
92
93genrule {
94    name: "pw_bluetooth_generate_emboss_hci_commands",
95    defaults: [
96        "pw_bluetooth_generate_emboss_header",
97    ],
98    srcs: [
99        "public/pw_bluetooth/hci_commands.emb",
100        "public/pw_bluetooth/hci_common.emb",
101    ],
102    out: [
103        "pw_bluetooth/hci_commands.emb.h",
104    ],
105}
106
107genrule {
108    name: "pw_bluetooth_generate_emboss_hci_common",
109    defaults: [
110        "pw_bluetooth_generate_emboss_header",
111    ],
112    srcs: [
113        "public/pw_bluetooth/hci_common.emb",
114    ],
115    out: [
116        "pw_bluetooth/hci_common.emb.h",
117    ],
118}
119
120genrule {
121    name: "pw_bluetooth_generate_emboss_hci_data",
122    defaults: [
123        "pw_bluetooth_generate_emboss_header",
124    ],
125    srcs: [
126        "public/pw_bluetooth/hci_data.emb",
127    ],
128    out: [
129        "pw_bluetooth/hci_data.emb.h",
130    ],
131}
132
133genrule {
134    name: "pw_bluetooth_generate_emboss_hci_events",
135    defaults: [
136        "pw_bluetooth_generate_emboss_header",
137    ],
138    srcs: [
139        "public/pw_bluetooth/hci_events.emb",
140        "public/pw_bluetooth/hci_common.emb",
141    ],
142    out: [
143        "pw_bluetooth/hci_events.emb.h",
144    ],
145}
146
147genrule {
148    name: "pw_bluetooth_generate_emboss_hci_h4",
149    defaults: [
150        "pw_bluetooth_generate_emboss_header",
151    ],
152    srcs: [
153        "public/pw_bluetooth/hci_h4.emb",
154    ],
155    out: [
156        "pw_bluetooth/hci_h4.emb.h",
157    ],
158}
159
160genrule {
161    name: "pw_bluetooth_generate_emboss_l2cap_frames",
162    defaults: [
163        "pw_bluetooth_generate_emboss_header",
164    ],
165    srcs: [
166        "public/pw_bluetooth/l2cap_frames.emb",
167    ],
168    out: [
169        "pw_bluetooth/l2cap_frames.emb.h",
170    ],
171}
172
173genrule {
174    name: "pw_bluetooth_generate_emboss_rfcomm_frames",
175    defaults: [
176        "pw_bluetooth_generate_emboss_header",
177    ],
178    srcs: [
179        "public/pw_bluetooth/rfcomm_frames.emb",
180    ],
181    out: [
182        "pw_bluetooth/rfcomm_frames.emb.h",
183    ],
184}
185
186cc_library_headers {
187    name: "pw_bluetooth_emboss_group",
188    cpp_std: "c++20",
189    vendor_available: true,
190    export_generated_headers: [
191        "pw_bluetooth_generate_emboss_att",
192        "pw_bluetooth_generate_emboss_hci_android",
193        "pw_bluetooth_generate_emboss_hci_commands",
194        "pw_bluetooth_generate_emboss_hci_common",
195        "pw_bluetooth_generate_emboss_hci_data",
196        "pw_bluetooth_generate_emboss_hci_events",
197        "pw_bluetooth_generate_emboss_hci_h4",
198        "pw_bluetooth_generate_emboss_l2cap_frames",
199        "pw_bluetooth_generate_emboss_rfcomm_frames",
200    ],
201    generated_headers: [
202        "pw_bluetooth_generate_emboss_att",
203        "pw_bluetooth_generate_emboss_hci_android",
204        "pw_bluetooth_generate_emboss_hci_commands",
205        "pw_bluetooth_generate_emboss_hci_common",
206        "pw_bluetooth_generate_emboss_hci_data",
207        "pw_bluetooth_generate_emboss_hci_events",
208        "pw_bluetooth_generate_emboss_hci_h4",
209        "pw_bluetooth_generate_emboss_l2cap_frames",
210        "pw_bluetooth_generate_emboss_rfcomm_frames",
211    ],
212    host_supported: true,
213}
214
215cc_library_headers {
216    name: "pw_bluetooth_emboss_util_include_dirs",
217    cpp_std: "c++20",
218    vendor_available: true,
219    export_include_dirs: ["public"],
220    host_supported: true,
221}
222