Loading tools/aconfig/TEST_MAPPING +4 −0 Original line number Diff line number Diff line Loading @@ -97,5 +97,9 @@ } ], "postsubmit": [ { // aconfig_storage file cpp integration tests "name": "aconfig_storage_file.test.cpp" } ] } tools/aconfig/aconfig_storage_file/Android.bp +60 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ rust_defaults { "libtempfile", "libprotobuf", "libclap", "libcxx", "libaconfig_storage_protos", ], } Loading Loading @@ -77,3 +78,62 @@ cc_library { product_available: true, double_loadable: true, } // cxx source codegen from rust api genrule { name: "libcxx_aconfig_storage_file_bridge_code", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) > $(out)", srcs: ["src/lib.rs"], out: ["aconfig_storage/lib.rs.cc"], } // cxx header codegen from rust api genrule { name: "libcxx_aconfig_storage_file_bridge_header", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) --header > $(out)", srcs: ["src/lib.rs"], out: ["aconfig_storage/lib.rs.h"], } // a static cc lib based on generated code rust_ffi_static { name: "libaconfig_storage_file_cxx_bridge", crate_name: "aconfig_storage_file_cxx_bridge", host_supported: true, vendor_available: true, product_available: true, srcs: ["src/lib.rs"], defaults: ["aconfig_storage_file.defaults"], apex_available: [ "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", } // storage file parse api cc interface cc_library { name: "libaconfig_storage_file_cc", srcs: ["aconfig_storage_file.cpp"], generated_headers: [ "cxx-bridge-header", "libcxx_aconfig_storage_file_bridge_header", ], generated_sources: ["libcxx_aconfig_storage_file_bridge_code"], whole_static_libs: ["libaconfig_storage_file_cxx_bridge"], export_include_dirs: ["include"], host_supported: true, vendor_available: true, product_available: true, shared_libs: [ "libbase", ], apex_available: [ "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", double_loadable: true, } tools/aconfig/aconfig_storage_file/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ protobuf = "3.2.0" tempfile = "3.9.0" thiserror = "1.0.56" clap = { version = "4.1.8", features = ["derive"] } cxx = "1.0" [[bin]] name = "aconfig-storage" Loading tools/aconfig/aconfig_storage_file/aconfig_storage_file.cpp 0 → 100644 +38 −0 Original line number Diff line number Diff line #include "rust/cxx.h" #include "aconfig_storage/lib.rs.h" #include "aconfig_storage/aconfig_storage_file.hpp" using namespace android::base; namespace aconfig_storage { Result<std::vector<FlagValueAndInfoSummary>> list_flags_with_info( const std::string& package_map, const std::string& flag_map, const std::string& flag_val, const std::string& flag_info) { auto flag_list_cxx = list_flags_with_info_cxx(rust::Str(package_map.c_str()), rust::Str(flag_map.c_str()), rust::Str(flag_val.c_str()), rust::Str(flag_info.c_str())); if (flag_list_cxx.query_success) { auto flag_list = std::vector<FlagValueAndInfoSummary>(); for (const auto& flag_cxx : flag_list_cxx.flags) { auto flag = FlagValueAndInfoSummary(); flag.package_name = std::string(flag_cxx.package_name); flag.flag_name = std::string(flag_cxx.flag_name); flag.flag_value = std::string(flag_cxx.flag_value); flag.value_type = std::string(flag_cxx.value_type); flag.is_readwrite = flag_cxx.is_readwrite; flag.has_server_override = flag_cxx.has_server_override; flag.has_local_override = flag_cxx.has_local_override; flag_list.push_back(flag); } return flag_list; } else { return Error() << flag_list_cxx.error_message; } } } // namespace aconfig_storage tools/aconfig/aconfig_storage_file/build.rs +2 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,6 @@ fn main() { .inputs(proto_files) .cargo_out_dir("aconfig_storage_protos") .run_from_script(); let _ = cxx_build::bridge("src/lib.rs"); } Loading
tools/aconfig/TEST_MAPPING +4 −0 Original line number Diff line number Diff line Loading @@ -97,5 +97,9 @@ } ], "postsubmit": [ { // aconfig_storage file cpp integration tests "name": "aconfig_storage_file.test.cpp" } ] }
tools/aconfig/aconfig_storage_file/Android.bp +60 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ rust_defaults { "libtempfile", "libprotobuf", "libclap", "libcxx", "libaconfig_storage_protos", ], } Loading Loading @@ -77,3 +78,62 @@ cc_library { product_available: true, double_loadable: true, } // cxx source codegen from rust api genrule { name: "libcxx_aconfig_storage_file_bridge_code", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) > $(out)", srcs: ["src/lib.rs"], out: ["aconfig_storage/lib.rs.cc"], } // cxx header codegen from rust api genrule { name: "libcxx_aconfig_storage_file_bridge_header", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) --header > $(out)", srcs: ["src/lib.rs"], out: ["aconfig_storage/lib.rs.h"], } // a static cc lib based on generated code rust_ffi_static { name: "libaconfig_storage_file_cxx_bridge", crate_name: "aconfig_storage_file_cxx_bridge", host_supported: true, vendor_available: true, product_available: true, srcs: ["src/lib.rs"], defaults: ["aconfig_storage_file.defaults"], apex_available: [ "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", } // storage file parse api cc interface cc_library { name: "libaconfig_storage_file_cc", srcs: ["aconfig_storage_file.cpp"], generated_headers: [ "cxx-bridge-header", "libcxx_aconfig_storage_file_bridge_header", ], generated_sources: ["libcxx_aconfig_storage_file_bridge_code"], whole_static_libs: ["libaconfig_storage_file_cxx_bridge"], export_include_dirs: ["include"], host_supported: true, vendor_available: true, product_available: true, shared_libs: [ "libbase", ], apex_available: [ "//apex_available:platform", "//apex_available:anyapex", ], min_sdk_version: "29", double_loadable: true, }
tools/aconfig/aconfig_storage_file/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ protobuf = "3.2.0" tempfile = "3.9.0" thiserror = "1.0.56" clap = { version = "4.1.8", features = ["derive"] } cxx = "1.0" [[bin]] name = "aconfig-storage" Loading
tools/aconfig/aconfig_storage_file/aconfig_storage_file.cpp 0 → 100644 +38 −0 Original line number Diff line number Diff line #include "rust/cxx.h" #include "aconfig_storage/lib.rs.h" #include "aconfig_storage/aconfig_storage_file.hpp" using namespace android::base; namespace aconfig_storage { Result<std::vector<FlagValueAndInfoSummary>> list_flags_with_info( const std::string& package_map, const std::string& flag_map, const std::string& flag_val, const std::string& flag_info) { auto flag_list_cxx = list_flags_with_info_cxx(rust::Str(package_map.c_str()), rust::Str(flag_map.c_str()), rust::Str(flag_val.c_str()), rust::Str(flag_info.c_str())); if (flag_list_cxx.query_success) { auto flag_list = std::vector<FlagValueAndInfoSummary>(); for (const auto& flag_cxx : flag_list_cxx.flags) { auto flag = FlagValueAndInfoSummary(); flag.package_name = std::string(flag_cxx.package_name); flag.flag_name = std::string(flag_cxx.flag_name); flag.flag_value = std::string(flag_cxx.flag_value); flag.value_type = std::string(flag_cxx.value_type); flag.is_readwrite = flag_cxx.is_readwrite; flag.has_server_override = flag_cxx.has_server_override; flag.has_local_override = flag_cxx.has_local_override; flag_list.push_back(flag); } return flag_list; } else { return Error() << flag_list_cxx.error_message; } } } // namespace aconfig_storage
tools/aconfig/aconfig_storage_file/build.rs +2 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,6 @@ fn main() { .inputs(proto_files) .cargo_out_dir("aconfig_storage_protos") .run_from_script(); let _ = cxx_build::bridge("src/lib.rs"); }