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

Commit 8bd9ee78 authored by Zhi Dou's avatar Zhi Dou Committed by Gerrit Code Review
Browse files

Merge "create java library accepts new_exported parameter" into main

parents 2634dbe8 63b3d8e8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ pub fn generate_java_code<I>(
    flag_ids: HashMap<String, u16>,
    allow_instrumentation: bool,
    package_fingerprint: u64,
    new_exported: bool,
) -> Result<Vec<OutputFile>>
where
    I: Iterator<Item = ProtoParsedFlag>,
@@ -60,6 +61,7 @@ where
        container,
        is_platform_container,
        package_fingerprint: format!("0x{:X}L", package_fingerprint),
        new_exported,
    };
    let mut template = TinyTemplate::new();
    template.add_template("Flags.java", include_str!("../../templates/Flags.java.template"))?;
@@ -129,6 +131,7 @@ struct Context {
    pub container: String,
    pub is_platform_container: bool,
    pub package_fingerprint: String,
    pub new_exported: bool,
}

#[derive(Serialize, Debug)]
@@ -530,6 +533,7 @@ mod tests {
            flag_ids,
            true,
            5801144784618221668,
            false,
        )
        .unwrap();
        let expect_flags_content = EXPECTED_FLAG_COMMON_CONTENT.to_string()
@@ -685,6 +689,7 @@ mod tests {
            flag_ids,
            true,
            5801144784618221668,
            false,
        )
        .unwrap();

@@ -884,6 +889,7 @@ mod tests {
            flag_ids,
            true,
            5801144784618221668,
            false,
        )
        .unwrap();

@@ -1006,6 +1012,7 @@ mod tests {
            flag_ids,
            true,
            5801144784618221668,
            false,
        )
        .unwrap();
        let expect_featureflags_content = r#"
+2 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ pub fn create_java_lib(
    mut input: Input,
    codegen_mode: CodegenMode,
    allow_instrumentation: bool,
    new_exported: bool,
) -> Result<Vec<OutputFile>> {
    let parsed_flags = input.try_parse_flags()?;
    let modified_parsed_flags = modify_parsed_flags_based_on_mode(parsed_flags, codegen_mode)?;
@@ -236,6 +237,7 @@ pub fn create_java_lib(
        flag_ids,
        allow_instrumentation,
        package_fingerprint,
        new_exported,
    )
}

+10 −2
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ fn cli() -> Command {
                        .long("allow-instrumentation")
                        .value_parser(clap::value_parser!(bool))
                        .default_value("false"),
                )
                .arg(
                    Arg::new("new-exported")
                        .long("new-exported")
                        .value_parser(clap::value_parser!(bool))
                        .default_value("false"),
                ),
        )
        .subcommand(
@@ -267,7 +273,9 @@ fn main() -> Result<()> {
            let mode = get_required_arg::<CodegenMode>(sub_matches, "mode")?;
            let allow_instrumentation =
                get_required_arg::<bool>(sub_matches, "allow-instrumentation")?;
            let generated_files = commands::create_java_lib(cache, *mode, *allow_instrumentation)
            let new_exported = get_required_arg::<bool>(sub_matches, "new-exported")?;
            let generated_files =
                commands::create_java_lib(cache, *mode, *allow_instrumentation, *new_exported)
                    .context("failed to create java lib")?;
            let dir = PathBuf::from(get_required_arg::<String>(sub_matches, "out")?);
            generated_files