1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#![allow(dead_code)]

/// Android Asset Packaging Tool 2.0 (AAPT2).
/// https://developer.android.com/studio/command-line/aapt2
/// https://android.googlesource.com/platform/frameworks/base/+/master/tools/aapt2
///
/// The main idea behind AAPT2, apart from new features, is that it divides
/// the 'package' step into two: 'compile' and 'link'. It improves performance,
/// since if only one file changes, you only need to recompile that one file and
/// link all the intermediate files with the 'link' command.
mod compile;
mod convert;
mod dump;
mod link;
mod optimize;

pub use compile::*;
pub use convert::*;
pub use dump::*;
pub use link::*;
pub use optimize::*;

pub struct Aapt2;

impl Aapt2 {
    /// Compiles resources to be linked into an apk.
    pub fn compile(self) -> Aapt2Compile {
        Aapt2Compile
    }

    /// Links resources into an apk.
    pub fn link(self) -> Aapt2Link {
        Aapt2Link
    }

    /// Used for printing information about the APK you generated using the link command.
    pub fn dump(self) -> Aapt2Dump {
        Aapt2Dump
    }

    /// Prints the differences in resources of two apks.
    /// https://gerrit.pixelexperience.org/plugins/gitiles/frameworks_base/+/refs/tags/android-10.0.0_r2/tools/aapt2/cmd/Diff.cpp
    pub fn diff(self) {
        todo!();
    }

    /// Preforms resource optimizations on an apk.
    pub fn optimize(self) -> Aapt2Optimize {
        Aapt2Optimize
    }

    /// Converts an apk between binary and proto formats.
    pub fn convert(self) -> Aapt2Convert {
        Aapt2Convert
    }

    /// Prints the version of aapt.
    pub fn version(self) -> String {
        todo!();
    }

    /// Runs aapt in daemon mode. Each subsequent line is a single parameter to the
    /// command. The end of an invocation is signaled by providing an empty line.
    pub fn daemon(self) {
        // probably stream ...
        todo!();
    }
}