fe753f5365
Officially, aconfig is build using the Android tool-chain. However, to speed up the local development cycle, add support for building with cargo. While it is possible to tell cargo to place the build artifacts outside the source tree, there is no way to tell it to not generate the cargo lock file in the same directory as Cargo.toml. Add a .gitignore to ignore Cargo.lock and the target directory. The way the Android build system and cargo generates code from the protobuf files is slightly different. Tell cargo to enable the "cargo" feature and introduce src/protos.rs to hide this difference from the rest of the aconfig source. Bug: 279485059 Test: m aconfig && aconfig Test: atest aconfig.test Test: cargo build Test: cargo test Change-Id: I85741f58cadae353ed95c124f566e4f4a7484186
17 lines
437 B
Rust
17 lines
437 B
Rust
use protobuf_codegen::Codegen;
|
|
|
|
fn main() {
|
|
let proto_files = vec!["protos/aconfig.proto"];
|
|
|
|
// tell cargo to only re-run the build script if any of the proto files has changed
|
|
for path in &proto_files {
|
|
println!("cargo:rerun-if-changed={}", path);
|
|
}
|
|
|
|
Codegen::new()
|
|
.pure()
|
|
.include("protos")
|
|
.inputs(proto_files)
|
|
.cargo_out_dir("aconfig_proto")
|
|
.run_from_script();
|
|
}
|