Move StringPool to libandroidfw
Test: verified affected tests pass
Bug: 232940948
Change-Id: I22089893d7e5013f759c39ce190bec07fa6435db
diff --git a/tools/aapt2/test/Builders.cpp b/tools/aapt2/test/Builders.cpp
index 23331de..30336e2 100644
--- a/tools/aapt2/test/Builders.cpp
+++ b/tools/aapt2/test/Builders.cpp
@@ -16,9 +16,9 @@
#include "test/Builders.h"
+#include "Diagnostics.h"
#include "android-base/logging.h"
#include "androidfw/StringPiece.h"
-
#include "io/StringStream.h"
#include "test/Common.h"
#include "util/Util.h"
@@ -151,7 +151,7 @@
return *this;
}
-StringPool* ResourceTableBuilder::string_pool() {
+android::StringPool* ResourceTableBuilder::string_pool() {
return &table_->string_pool;
}
@@ -235,7 +235,7 @@
input.append(str.data(), str.size());
StringInputStream in(input);
StdErrDiagnostics diag;
- std::unique_ptr<xml::XmlResource> doc = xml::Inflate(&in, &diag, Source("test.xml"));
+ std::unique_ptr<xml::XmlResource> doc = xml::Inflate(&in, &diag, android::Source("test.xml"));
CHECK(doc != nullptr && doc->root != nullptr) << "failed to parse inline XML string";
return doc;
}
diff --git a/tools/aapt2/test/Builders.h b/tools/aapt2/test/Builders.h
index 55778ae..780bd0d 100644
--- a/tools/aapt2/test/Builders.h
+++ b/tools/aapt2/test/Builders.h
@@ -75,7 +75,7 @@
const OverlayableItem& overlayable);
ResourceTableBuilder& Add(NewResource&& res);
- StringPool* string_pool();
+ android::StringPool* string_pool();
std::unique_ptr<ResourceTable> Build();
private:
@@ -97,7 +97,7 @@
template <typename... Args>
ValueBuilder& SetSource(Args&&... args) {
- value_->SetSource(Source{std::forward<Args>(args)...});
+ value_->SetSource(android::Source{std::forward<Args>(args)...});
return *this;
}
diff --git a/tools/aapt2/test/Common.cpp b/tools/aapt2/test/Common.cpp
index e029d02..eca0c1c 100644
--- a/tools/aapt2/test/Common.cpp
+++ b/tools/aapt2/test/Common.cpp
@@ -21,8 +21,8 @@
namespace aapt {
namespace test {
-struct TestDiagnosticsImpl : public IDiagnostics {
- void Log(Level level, DiagMessageActual& actual_msg) override {
+struct TestDiagnosticsImpl : public android::IDiagnostics {
+ void Log(Level level, android::DiagMessageActual& actual_msg) override {
switch (level) {
case Level::Note:
return;
@@ -38,7 +38,7 @@
}
};
-IDiagnostics* GetDiagnostics() {
+android::IDiagnostics* GetDiagnostics() {
static TestDiagnosticsImpl diag;
return &diag;
}
diff --git a/tools/aapt2/test/Common.h b/tools/aapt2/test/Common.h
index 7006964..3f28361 100644
--- a/tools/aapt2/test/Common.h
+++ b/tools/aapt2/test/Common.h
@@ -37,7 +37,7 @@
namespace aapt {
namespace test {
-IDiagnostics* GetDiagnostics();
+android::IDiagnostics* GetDiagnostics();
inline ResourceName ParseNameOrDie(const android::StringPiece& str) {
ResourceNameRef ref;
@@ -94,14 +94,14 @@
return OpenAsData();
}
- const Source& GetSource() const override {
+ const android::Source& GetSource() const override {
return source_;
}
private:
DISALLOW_COPY_AND_ASSIGN(TestFile);
- Source source_;
+ android::Source source_;
};
} // namespace test
diff --git a/tools/aapt2/test/Context.h b/tools/aapt2/test/Context.h
index e1b8dd5..4e4973e 100644
--- a/tools/aapt2/test/Context.h
+++ b/tools/aapt2/test/Context.h
@@ -19,10 +19,10 @@
#include <list>
+#include "Diagnostics.h"
+#include "NameMangler.h"
#include "android-base/logging.h"
#include "android-base/macros.h"
-
-#include "NameMangler.h"
#include "process/IResourceTableConsumer.h"
#include "process/SymbolTable.h"
#include "test/Common.h"
@@ -43,7 +43,7 @@
return &symbols_;
}
- IDiagnostics* GetDiagnostics() override {
+ android::IDiagnostics* GetDiagnostics() override {
return &diagnostics_;
}
diff --git a/tools/aapt2/test/Fixture.cpp b/tools/aapt2/test/Fixture.cpp
index ddc1853..ff8b368 100644
--- a/tools/aapt2/test/Fixture.cpp
+++ b/tools/aapt2/test/Fixture.cpp
@@ -16,16 +16,16 @@
#include "test/Fixture.h"
-#include <dirent.h>
-
#include <android-base/errors.h>
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/utf8.h>
#include <androidfw/StringPiece.h>
+#include <dirent.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include "Diagnostics.h"
#include "cmd/Compile.h"
#include "cmd/Link.h"
#include "io/FileStream.h"
@@ -42,7 +42,8 @@
const std::string root_dir = path.to_string();
std::unique_ptr<DIR, decltype(closedir)*> dir(opendir(root_dir.data()), closedir);
if (!dir) {
- StdErrDiagnostics().Error(DiagMessage() << android::base::SystemErrorCodeToString(errno));
+ StdErrDiagnostics().Error(android::DiagMessage()
+ << android::base::SystemErrorCodeToString(errno));
return;
}
@@ -90,13 +91,14 @@
}
bool CommandTestFixture::CompileFile(const std::string& path, const std::string& contents,
- const android::StringPiece& out_dir, IDiagnostics* diag) {
+ const android::StringPiece& out_dir,
+ android::IDiagnostics* diag) {
WriteFile(path, contents);
CHECK(file::mkdirs(out_dir.data()));
return CompileCommand(diag).Execute({path, "-o", out_dir, "-v"}, &std::cerr) == 0;
}
-bool CommandTestFixture::Link(const std::vector<std::string>& args, IDiagnostics* diag) {
+bool CommandTestFixture::Link(const std::vector<std::string>& args, android::IDiagnostics* diag) {
std::vector<android::StringPiece> link_args;
for(const std::string& arg : args) {
link_args.emplace_back(arg);
@@ -112,7 +114,7 @@
}
bool CommandTestFixture::Link(const std::vector<std::string>& args,
- const android::StringPiece& flat_dir, IDiagnostics* diag) {
+ const android::StringPiece& flat_dir, android::IDiagnostics* diag) {
std::vector<android::StringPiece> link_args;
for(const std::string& arg : args) {
link_args.emplace_back(arg);
@@ -210,7 +212,7 @@
}
LinkCommandBuilder& LinkCommandBuilder::AddCompiledResDir(const std::string& dir,
- IDiagnostics* diag) {
+ android::IDiagnostics* diag) {
if (auto files = file::FindFiles(dir, diag)) {
for (std::string& compile_file : files.value()) {
args_.emplace_back(file::BuildPath({dir, compile_file}));
diff --git a/tools/aapt2/test/Fixture.h b/tools/aapt2/test/Fixture.h
index f8c4889..61403b7 100644
--- a/tools/aapt2/test/Fixture.h
+++ b/tools/aapt2/test/Fixture.h
@@ -73,15 +73,15 @@
// Wries the contents of the file to the specified path. The file is compiled and the flattened
// file is written to the out directory.
bool CompileFile(const std::string& path, const std::string& contents,
- const android::StringPiece& flat_out_dir, IDiagnostics* diag);
+ const android::StringPiece& flat_out_dir, android::IDiagnostics* diag);
// Executes the link command with the specified arguments.
- bool Link(const std::vector<std::string>& args, IDiagnostics* diag);
+ bool Link(const std::vector<std::string>& args, android::IDiagnostics* diag);
// Executes the link command with the specified arguments. The flattened files residing in the
// flat directory will be added to the link command as file arguments.
bool Link(const std::vector<std::string>& args, const android::StringPiece& flat_dir,
- IDiagnostics* diag);
+ android::IDiagnostics* diag);
// Creates a minimal android manifest within the test directory and returns the file path.
std::string GetDefaultManifest(const char* package_name = kDefaultPackageName);
@@ -114,7 +114,7 @@
struct LinkCommandBuilder {
explicit LinkCommandBuilder(CommandTestFixture* fixture);
- LinkCommandBuilder& AddCompiledResDir(const std::string& dir, IDiagnostics* diag);
+ LinkCommandBuilder& AddCompiledResDir(const std::string& dir, android::IDiagnostics* diag);
LinkCommandBuilder& AddFlag(const std::string& flag);
LinkCommandBuilder& AddParameter(const std::string& param, const std::string& value);
LinkCommandBuilder& SetManifestFile(const std::string& manifest_path);