1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "system_bt_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["system_bt_license"],
8}
9
10bootstrap_go_package {
11    name: "soong-fluoride",
12    pkgPath: "android/soong/fluoride",
13    deps: [
14        "blueprint",
15        "blueprint-pathtools",
16        "soong",
17        "soong-android",
18        "soong-cc",
19    ],
20    srcs: [
21        "fluoride.go",
22    ],
23    pluginFor: ["soong_build"],
24}
25
26fluoride_defaults {
27    name: "libchrome_support_defaults",
28    shared_libs: ["libchrome"],
29    cflags: [
30        "-Wall",
31        "-Wextra",
32        "-Werror",
33    ],
34    target: {
35        darwin: {
36            enabled: false,
37        },
38    },
39}
40
41// Fuzzable defaults are the subset of defaults that are used in fuzzing, which
42// requires no shared libraries, and no explicit sanitization.
43fluoride_defaults {
44    name: "fluoride_types_defaults_fuzzable",
45    cflags: [
46        "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
47        "-fvisibility=hidden",
48        // struct BT_HDR is defined as a variable-size header in a struct.
49        "-Wno-gnu-variable-sized-type-not-at-end",
50        // there are too many unused parameters in all the code.
51        "-Wno-unused-parameter",
52        "-DLOG_NDEBUG=1",
53    ],
54    conlyflags: [
55        "-std=c99",
56    ],
57    product_variables: {
58        debuggable: {
59            cflags: [
60                "-DBLUEDROID_DEBUG",
61            ],
62        },
63    },
64}
65
66fluoride_defaults {
67    name: "fluoride_types_defaults",
68    defaults: [
69        "fluoride_types_defaults_fuzzable",
70        "libchrome_support_defaults"
71    ],
72}
73
74fluoride_defaults {
75    name: "fluoride_defaults_fuzzable",
76    target: {
77        android: {
78            test_config_template: ":BluetoothTestConfigTemplate",
79        },
80    },
81    defaults: ["fluoride_types_defaults_fuzzable"],
82    header_libs: ["libbluetooth_headers", "libbt_callbacks_cxx_headers"],
83    generated_headers: [
84        "libbt_shim_bridge_header",
85        "libbt_message_loop_thread_bridge_header",
86        "cxx-bridge-header"
87    ],
88    include_dirs: ["system/bt/gd/rust/shim"],
89    static_libs: [
90        "libbluetooth-types",
91        "libbt-platform-protos-lite",
92        "libbluetooth_rust_interop",
93        "liblog",
94        "libcutils",
95    ],
96    cpp_std: "c++17",
97    sanitize: {
98        misc_undefined: ["bounds"],
99    },
100}
101
102fluoride_defaults {
103    name: "fluoride_defaults",
104    defaults: ["fluoride_defaults_fuzzable", "fluoride_types_defaults"],
105    shared_libs: [
106        "libcutils",
107        "libgrpc++",
108        "libgrpc_wrap",
109        "libhidlbase",
110        "libstatslog",
111        "libutils",
112
113    ],
114    sanitize: {
115        misc_undefined: ["bounds"],
116    },
117    static_libs: [
118        "libbluetooth_gd",
119        "libbluetooth_rust_interop",
120        "libbt_shim_ffi",
121    ],
122    target: {
123        darwin: {
124            // libstatslog -> libbinder doesn't build on mac
125            enabled: false,
126        },
127        android: {
128            shared_libs: [
129                "android.hardware.bluetooth@1.0",
130                "android.hardware.bluetooth@1.1",
131            ],
132            cflags: [
133                "-DOS_ANDROID",
134            ],
135        },
136    },
137}
138
139// Enables code coverage for a set of source files. Must be combined with
140// "clang_coverage_bin" in order to work. See //test/gen_coverage.py for more information
141// on generating code coverage.
142cc_defaults {
143    name: "clang_file_coverage",
144    target: {
145        host: {
146            clang_cflags: [
147                "-fprofile-instr-generate",
148                "-fcoverage-mapping",
149            ],
150        },
151    },
152}
153
154// Enabled code coverage on a binary. These flags allow libraries that were
155// compiled with "clang_file_coverage" to be properly linked together in
156// order to create a binary that will create a profraw file when ran. Note
157// these flags themselves don't enable code coverage for the source files
158// compiled in the binary. See //test/gen_coverage.py for more information
159// on generating code coverage.
160cc_defaults {
161    name: "clang_coverage_bin",
162    target: {
163        host: {
164            ldflags: [
165                "-fprofile-instr-generate",
166                "-fcoverage-mapping",
167            ],
168        },
169    },
170}
171