Loading tools/aconfig/aconfig_storage_file/Android.bp +44 −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 @@ -69,3 +70,46 @@ cc_library_static { ], host_supported: 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, srcs: ["src/lib.rs"], defaults: ["aconfig_storage_file.defaults"], } // flag storage file cc interface cc_library_static { 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"], static_libs: [ "libbase", ], } tools/aconfig/aconfig_storage_file/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ anyhow = "1.0.69" protobuf = "3.2.0" tempfile = "3.9.0" thiserror = "1.0.56" cxx = "1.0" clap = { version = "4.1.8", features = ["derive"] } [[bin]] Loading tools/aconfig/aconfig_storage_file/aconfig_storage_file.cpp 0 → 100644 +20 −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" namespace aconfig_storage { android::base::Result<void> create_flag_info( std::string const& package_map, std::string const& flag_map, std::string const& flag_info_out) { auto creation_cxx = create_flag_info_cxx( rust::Str(package_map.c_str()), rust::Str(flag_map.c_str()), rust::Str(flag_info_out.c_str())); if (creation_cxx.success) { return {}; } else { return android::base::Error() << creation_cxx.error_message; } } } // namespace aconfig_storage tools/aconfig/aconfig_storage_file/build.rs +3 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,7 @@ fn main() { .inputs(proto_files) .cargo_out_dir("aconfig_storage_protos") .run_from_script(); let _ = cxx_build::bridge("src/lib.rs"); println!("cargo:rerun-if-changed=src/lib.rs"); } tools/aconfig/aconfig_storage_file/include/aconfig_storage/aconfig_storage_file.hpp 0 → 100644 +16 −0 Original line number Diff line number Diff line #pragma once #include <stdint.h> #include <string> #include <android-base/result.h> namespace aconfig_storage { /// Create flag info file based on package and flag map /// \input package_map: package map file /// \input flag_map: flag map file /// \input flag_info_out: flag info file to be created android::base::Result<void> create_flag_info( std::string const& package_map, std::string const& flag_map, std::string const& flag_info_out); } // namespace aconfig_storage Loading
tools/aconfig/aconfig_storage_file/Android.bp +44 −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 @@ -69,3 +70,46 @@ cc_library_static { ], host_supported: 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, srcs: ["src/lib.rs"], defaults: ["aconfig_storage_file.defaults"], } // flag storage file cc interface cc_library_static { 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"], static_libs: [ "libbase", ], }
tools/aconfig/aconfig_storage_file/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ anyhow = "1.0.69" protobuf = "3.2.0" tempfile = "3.9.0" thiserror = "1.0.56" cxx = "1.0" clap = { version = "4.1.8", features = ["derive"] } [[bin]] Loading
tools/aconfig/aconfig_storage_file/aconfig_storage_file.cpp 0 → 100644 +20 −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" namespace aconfig_storage { android::base::Result<void> create_flag_info( std::string const& package_map, std::string const& flag_map, std::string const& flag_info_out) { auto creation_cxx = create_flag_info_cxx( rust::Str(package_map.c_str()), rust::Str(flag_map.c_str()), rust::Str(flag_info_out.c_str())); if (creation_cxx.success) { return {}; } else { return android::base::Error() << creation_cxx.error_message; } } } // namespace aconfig_storage
tools/aconfig/aconfig_storage_file/build.rs +3 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,7 @@ fn main() { .inputs(proto_files) .cargo_out_dir("aconfig_storage_protos") .run_from_script(); let _ = cxx_build::bridge("src/lib.rs"); println!("cargo:rerun-if-changed=src/lib.rs"); }
tools/aconfig/aconfig_storage_file/include/aconfig_storage/aconfig_storage_file.hpp 0 → 100644 +16 −0 Original line number Diff line number Diff line #pragma once #include <stdint.h> #include <string> #include <android-base/result.h> namespace aconfig_storage { /// Create flag info file based on package and flag map /// \input package_map: package map file /// \input flag_map: flag map file /// \input flag_info_out: flag info file to be created android::base::Result<void> create_flag_info( std::string const& package_map, std::string const& flag_map, std::string const& flag_info_out); } // namespace aconfig_storage