Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 455dc608 authored by Dennis Shen's avatar Dennis Shen
Browse files

aconfig: move create flag info file api to aconfig_storage_write_api

rust_ffi_static right now will export excessive symbols, this lead to a
duplication of symbols when aconfig links against both
libaconfig_storage_file_cc and libaconfig_storage_read_api_cc. This is
because aconfig_storage_read_api crate depends on aconfig_storage_file
crate. To solve this problem, move create flag info file api to
aconfig_storage_write_api crate which is parallel to
aconfig_storage_read_api crate.

Bug: b/321077378
Test: atest aconfig_storage_file.test; atest
aconfig_storage_read_api.test; atest aconfig_storage_write_api.test

Change-Id: Ibbb50193a2da82d52ccbb4087c8e3fb9f320805f
parent 2922ca90
Loading
Loading
Loading
Loading
+0 −44
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ rust_defaults {
        "libtempfile",
        "libprotobuf",
        "libclap",
        "libcxx",
        "libaconfig_storage_protos",
    ],
}
@@ -70,46 +69,3 @@ 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",
    ],
}
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ 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]]
+0 −20
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
+0 −3
Original line number Diff line number Diff line
@@ -14,7 +14,4 @@ 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");
}
+0 −16
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