5 unstable releases

0.3.1 Dec 1, 2025
0.3.0 Jun 9, 2024
0.2.1 Jun 8, 2024
0.2.0 Dec 29, 2023
0.1.0 Dec 29, 2023

#801 in Parser implementations

Download history 332/week @ 2026-01-18 400/week @ 2026-01-25 469/week @ 2026-02-01 535/week @ 2026-02-08 817/week @ 2026-02-15 771/week @ 2026-02-22 585/week @ 2026-03-01 842/week @ 2026-03-08 531/week @ 2026-03-15 340/week @ 2026-03-22 473/week @ 2026-03-29 440/week @ 2026-04-05 533/week @ 2026-04-12 441/week @ 2026-04-19 430/week @ 2026-04-26 268/week @ 2026-05-03

1,698 downloads per month

MIT license

44KB
1K SLoC

android-bp

a rust crate to parse Android.bp files

Usage

    use android_bp::BluePrint;

    let bp = BluePrint::from_file("fixtures/example.bp").unwrap();
    println!("{:#?}", bp);

    // variables are accessible as a rust HashMap
    println!("{:#?}", bp.variables);
    for m in &bp.modules {
        if m.typ == "rust_binary" {
            println!("{:?}", m.get("name").unwrap());
        }
    }
    // or iter them by type
    for m in bp.modules_by_type("rust_host_test") {
        // m.get return an sometime inconvenient Option<&Value>
        // so some helper methods are provided
        let name = m.get_string("name").unwrap();
        let srcs = m.get_array("srcs").unwrap();
        println!("{:?} {:?}", name, srcs);
    }

Status

  • The project parses successfully all the Android.bp files in the AOSP tree. Test files are present in the src/test_db.tar.xz archive.

  • different possible values are abstracted in the Value enum

    • strings
    • arrays
    • integers
    • booleans
    • expressions
    • functions
    • identifiers
  • modules (module { ... })

  • variables (var = "value")

  • variables extend (var += [ "new value" ])

    • arrays
    • strings
    • integers
    • expressions with other variables
  • expressions (var : "value" + \n"value"), used for strings long enough to be split in multiple lines

    • arrays (automatically merged)
    • strings (automatically merged)
    • with identifiers (kept as an expression)

Dependencies

~1MB
~18K SLoC