1package {
2    default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5rust_defaults {
6    name: "aconfig_storage_write_api.defaults",
7    edition: "2021",
8    lints: "none",
9    srcs: ["src/lib.rs"],
10    rustlibs: [
11        "libanyhow",
12        "libtempfile",
13        "libmemmap2",
14        "libcxx",
15        "libthiserror",
16        "libaconfig_storage_file",
17        "libaconfig_storage_read_api",
18    ],
19}
20
21rust_library {
22    name: "libaconfig_storage_write_api",
23    crate_name: "aconfig_storage_write_api",
24    host_supported: true,
25    defaults: ["aconfig_storage_write_api.defaults"],
26}
27
28rust_test_host {
29    name: "aconfig_storage_write_api.test",
30    test_suites: ["general-tests"],
31    defaults: ["aconfig_storage_write_api.defaults"],
32    data: [
33        "tests/flag.val",
34        "tests/flag.info",
35    ],
36    rustlibs: [
37        "libaconfig_storage_read_api",
38    ],
39}
40
41// cxx source codegen from rust api
42genrule {
43    name: "libcxx_aconfig_storage_write_api_bridge_code",
44    tools: ["cxxbridge"],
45    cmd: "$(location cxxbridge) $(in) > $(out)",
46    srcs: ["src/lib.rs"],
47    out: ["aconfig_storage/lib.rs.cc"],
48}
49
50// cxx header codegen from rust api
51genrule {
52    name: "libcxx_aconfig_storage_write_api_bridge_header",
53    tools: ["cxxbridge"],
54    cmd: "$(location cxxbridge) $(in) --header > $(out)",
55    srcs: ["src/lib.rs"],
56    out: ["aconfig_storage/lib.rs.h"],
57}
58
59// a static cc lib based on generated code
60rust_ffi_static {
61    name: "libaconfig_storage_write_api_cxx_bridge",
62    crate_name: "aconfig_storage_write_api_cxx_bridge",
63    host_supported: true,
64    defaults: ["aconfig_storage_write_api.defaults"],
65}
66
67// flag write api cc interface
68cc_library_static {
69    name: "libaconfig_storage_write_api_cc",
70    srcs: ["aconfig_storage_write_api.cpp"],
71    generated_headers: [
72        "cxx-bridge-header",
73        "libcxx_aconfig_storage_write_api_bridge_header",
74    ],
75    generated_sources: ["libcxx_aconfig_storage_write_api_bridge_code"],
76    whole_static_libs: ["libaconfig_storage_write_api_cxx_bridge"],
77    export_include_dirs: ["include"],
78    static_libs: [
79        "libaconfig_storage_read_api_cc",
80        "libprotobuf-cpp-lite",
81        "libbase",
82    ],
83}
84