aconfig: follow Java conventions for Java file paths
Update codegen_java to write the generated Java file(s) to
"java/package/File.java" instead of just "File.java".
Also generalize codegen_java::GeneratedFile to commands::OutputFile in
preparation for the upcoming C++ and Rust codegen.
Also change Java package name to 'com.android.internal.aconfig'.
Bug: 279485059
Test: atest aconfig.test
Change-Id: I13978697e35010fe6be8637aa495d4b852dbed7e
diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs
index c02fe07..475d9b8 100644
--- a/tools/aconfig/src/commands.rs
+++ b/tools/aconfig/src/commands.rs
@@ -20,10 +20,11 @@
use serde::{Deserialize, Serialize};
use std::fmt;
use std::io::Read;
+use std::path::PathBuf;
use crate::aconfig::{FlagDeclarations, FlagValue};
use crate::cache::Cache;
-use crate::codegen_java::{generate_java_code, GeneratedFile};
+use crate::codegen_java::generate_java_code;
use crate::protos::ProtoParsedFlags;
#[derive(Serialize, Deserialize, Clone, Debug)]
@@ -47,6 +48,11 @@
pub reader: Box<dyn Read>,
}
+pub struct OutputFile {
+ pub path: PathBuf, // relative to some root directory only main knows about
+ pub contents: Vec<u8>,
+}
+
pub fn create_cache(
namespace: &str,
declarations: Vec<Input>,
@@ -85,7 +91,7 @@
Ok(cache)
}
-pub fn generate_code(cache: &Cache) -> Result<GeneratedFile> {
+pub fn generate_code(cache: &Cache) -> Result<OutputFile> {
generate_java_code(cache)
}