• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_team: "trendy_team_android_rust",
3    default_applicable_licenses: ["Android-Apache-2.0"],
4}
5
6rust_defaults {
7    name: "librustutils_defaults",
8    srcs: ["lib.rs"],
9    host_supported: true,
10    target: {
11        android: {
12            rustlibs: [
13                "libcutils_bindgen",
14                "libsystem_properties_bindgen_sys",
15            ],
16        },
17    },
18    rustlibs: [
19        "libanyhow",
20        "liblibc",
21        "libnix",
22        "libthiserror",
23    ],
24}
25
26rust_library {
27    name: "librustutils",
28    crate_name: "rustutils",
29    defaults: ["librustutils_defaults"],
30    shared_libs: [
31        "libbase",
32        "libcutils",
33    ],
34    apex_available: [
35        "//apex_available:platform",
36        "//apex_available:anyapex",
37    ],
38    product_available: true,
39    vendor_available: true,
40    min_sdk_version: "29",
41}
42
43rust_test {
44    name: "librustutils_test",
45    crate_name: "librustutils_test_test",
46    defaults: ["librustutils_defaults"],
47    test_suites: ["general-tests"],
48    auto_gen_config: true,
49    rustlibs: [
50        "libtempfile",
51    ],
52    // Below flags are to run each test function in a separate process which is needed for
53    // the crate::inherited_fd::test. Note that tests still run in parallel.
54    flags: [
55        "-C panic=abort",
56        "-Z panic_abort_tests",
57    ],
58}
59
60// Build a separate rust_library rather than depending directly on libsystem_properties_bindgen,
61// to work around the fact that rust_bindgen targets only produce rlibs and not dylibs, which would
62// result in duplicate conflicting versions of liblibc. This will hopefully be fixed in the build
63// system, at which point we can delete this target and go back to using libsystem_properties_bindgen
64// directly.
65rust_library {
66    name: "libsystem_properties_bindgen_sys",
67    crate_name: "system_properties_bindgen",
68    srcs: [
69        ":libsystem_properties_bindgen",
70    ],
71    rustlibs: [
72        "liblibc",
73    ],
74    product_available: true,
75    vendor_available: true,
76    apex_available: [
77        "//apex_available:platform",
78        "//apex_available:anyapex",
79    ],
80    min_sdk_version: "29",
81    lints: "none",
82    clippy_lints: "none",
83}
84
85rust_bindgen {
86    name: "libsystem_properties_bindgen",
87    wrapper_src: "bindgen/system_properties.h",
88    crate_name: "system_properties_bindgen",
89    source_stem: "bindings",
90
91    bindgen_flags: [
92        "--allowlist-function=__system_property_find",
93        "--allowlist-function=__system_property_foreach",
94        "--allowlist-function=__system_property_read_callback",
95        "--allowlist-function=__system_property_set",
96        "--allowlist-function=__system_property_wait",
97        "--blocklist-type=timespec",
98        "--raw-line",
99        "use libc::timespec;",
100    ],
101    rustlibs: [
102        "liblibc",
103    ],
104    product_available: true,
105    vendor_available: true,
106    apex_available: [
107        "//apex_available:platform",
108        "//apex_available:anyapex",
109    ],
110    min_sdk_version: "29",
111}
112
113rust_bindgen {
114    name: "libcutils_bindgen",
115    wrapper_src: "bindgen/cutils.h",
116    crate_name: "cutils_bindgen",
117    source_stem: "bindings",
118    header_libs: ["libcutils_headers"],
119    bindgen_flags: [
120        "--allowlist-function",
121        "android_get_control_socket",
122        "--allowlist-var",
123        "AID_KEYSTORE",
124        "--allowlist-var",
125        "AID_ROOT",
126        "--allowlist-var",
127        "AID_SHELL",
128        "--allowlist-var",
129        "AID_SYSTEM",
130        "--allowlist-var",
131        "AID_USER_OFFSET",
132    ],
133    product_available: true,
134    vendor_available: true,
135    apex_available: [
136        "//apex_available:platform",
137        "//apex_available:anyapex",
138    ],
139    min_sdk_version: "29",
140}
141
142rust_test {
143    name: "libsystem_properties_bindgen_test",
144    srcs: [":libsystem_properties_bindgen"],
145    crate_name: "system_properties_bindgen_test",
146    test_suites: ["general-tests"],
147    rustlibs: [
148        "liblibc",
149    ],
150    auto_gen_config: true,
151    clippy_lints: "none",
152    lints: "none",
153}
154
155rust_test {
156    name: "libcutils_bindgen_test",
157    srcs: [":libcutils_bindgen"],
158    crate_name: "cutils_bindgen_test",
159    test_suites: ["general-tests"],
160    auto_gen_config: true,
161    clippy_lints: "none",
162    lints: "none",
163}
164
165rust_fuzz {
166    name: "system_properties_fuzzer",
167    srcs: ["system_properties_fuzzer.rs"],
168    rustlibs: [
169        "libarbitrary",
170        "librustutils",
171    ],
172    fuzz_config: {
173        fuzz_on_haiku_device: true,
174        fuzz_on_haiku_host: true,
175    },
176}
177