AAPT2: Error reporting through JNI.
Rather than relying on stderr being wired correctly.
Test: Tests for JNI integration in studio-master-dev.
Change-Id: I1c7e7130bc4e56d61de259a9596bee3a6b3520fb
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index b93c6ec..5413b33 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -598,6 +598,9 @@
class CompileContext : public IAaptContext {
public:
+ CompileContext(IDiagnostics* diagnostics) : diagnostics_(diagnostics) {
+ }
+
PackageType GetPackageType() override {
// Every compilation unit starts as an app and then gets linked as potentially something else.
return PackageType::kApp;
@@ -612,7 +615,7 @@
}
IDiagnostics* GetDiagnostics() override {
- return &diagnostics_;
+ return diagnostics_;
}
NameMangler* GetNameMangler() override {
@@ -639,7 +642,7 @@
}
private:
- StdErrDiagnostics diagnostics_;
+ IDiagnostics* diagnostics_;
bool verbose_ = false;
};
@@ -647,8 +650,8 @@
* Entry point for compilation phase. Parses arguments and dispatches to the
* correct steps.
*/
-int Compile(const std::vector<StringPiece>& args) {
- CompileContext context;
+int Compile(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) {
+ CompileContext context(diagnostics);
CompileOptions options;
bool verbose = false;