From 467f171315f9c2037fcd3eb5edcfabc40671bf7b Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Mon, 16 Nov 2015 17:35:44 -0800 Subject: AAPT2: Fail compiling when private symbols are referenced Also moved some XML specific stuff into its own directory, and refactored ReferenceLinker a bit. Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c --- tools/aapt2/java/AnnotationProcessor_test.cpp | 6 ++---- tools/aapt2/java/ClassDefinitionWriter.h | 1 + tools/aapt2/java/ManifestClassGenerator.cpp | 5 ++--- tools/aapt2/java/ManifestClassGenerator.h | 4 ++-- tools/aapt2/java/ManifestClassGenerator_test.cpp | 5 ++--- tools/aapt2/java/ProguardRules.cpp | 12 ++++++------ tools/aapt2/java/ProguardRules.h | 7 +++---- 7 files changed, 18 insertions(+), 22 deletions(-) (limited to 'tools/aapt2/java') diff --git a/tools/aapt2/java/AnnotationProcessor_test.cpp b/tools/aapt2/java/AnnotationProcessor_test.cpp index d5a2b38bcbc4..da96b84fd4ea 100644 --- a/tools/aapt2/java/AnnotationProcessor_test.cpp +++ b/tools/aapt2/java/AnnotationProcessor_test.cpp @@ -17,12 +17,10 @@ #include "ResourceParser.h" #include "ResourceTable.h" #include "ResourceValues.h" -#include "XmlPullParser.h" - #include "java/AnnotationProcessor.h" - #include "test/Builders.h" #include "test/Context.h" +#include "xml/XmlPullParser.h" #include @@ -42,7 +40,7 @@ struct AnnotationProcessorTest : public ::testing::Test { options); std::stringstream in; in << "\n" << str; - XmlPullParser xmlParser(in); + xml::XmlPullParser xmlParser(in); if (parser.parse(&xmlParser)) { return ::testing::AssertionSuccess(); } diff --git a/tools/aapt2/java/ClassDefinitionWriter.h b/tools/aapt2/java/ClassDefinitionWriter.h index b8886f90c6c5..04e1274c3a97 100644 --- a/tools/aapt2/java/ClassDefinitionWriter.h +++ b/tools/aapt2/java/ClassDefinitionWriter.h @@ -17,6 +17,7 @@ #ifndef AAPT_JAVA_CLASSDEFINITION_H #define AAPT_JAVA_CLASSDEFINITION_H +#include "Resource.h" #include "java/AnnotationProcessor.h" #include "util/StringPiece.h" #include "util/Util.h" diff --git a/tools/aapt2/java/ManifestClassGenerator.cpp b/tools/aapt2/java/ManifestClassGenerator.cpp index d963d8948f8d..a9b4c14337fe 100644 --- a/tools/aapt2/java/ManifestClassGenerator.cpp +++ b/tools/aapt2/java/ManifestClassGenerator.cpp @@ -15,12 +15,11 @@ */ #include "Source.h" -#include "XmlDom.h" - #include "java/AnnotationProcessor.h" #include "java/ClassDefinitionWriter.h" #include "java/ManifestClassGenerator.h" #include "util/Maybe.h" +#include "xml/XmlDom.h" #include @@ -80,7 +79,7 @@ static bool writeSymbol(IDiagnostics* diag, ClassDefinitionWriter* outClassDef, } bool ManifestClassGenerator::generate(IDiagnostics* diag, const StringPiece16& package, - XmlResource* res, std::ostream* out) { + xml::XmlResource* res, std::ostream* out) { xml::Element* el = xml::findRootElement(res->root.get()); if (!el) { return false; diff --git a/tools/aapt2/java/ManifestClassGenerator.h b/tools/aapt2/java/ManifestClassGenerator.h index 0f0998f8e2ba..226ed23b85f8 100644 --- a/tools/aapt2/java/ManifestClassGenerator.h +++ b/tools/aapt2/java/ManifestClassGenerator.h @@ -18,15 +18,15 @@ #define AAPT_JAVA_MANIFESTCLASSGENERATOR_H #include "Diagnostics.h" -#include "process/IResourceTableConsumer.h" #include "util/StringPiece.h" +#include "xml/XmlDom.h" #include namespace aapt { struct ManifestClassGenerator { - bool generate(IDiagnostics* diag, const StringPiece16& package, XmlResource* res, + bool generate(IDiagnostics* diag, const StringPiece16& package, xml::XmlResource* res, std::ostream* out); }; diff --git a/tools/aapt2/java/ManifestClassGenerator_test.cpp b/tools/aapt2/java/ManifestClassGenerator_test.cpp index 4081287a1852..fc57ae6fd8ff 100644 --- a/tools/aapt2/java/ManifestClassGenerator_test.cpp +++ b/tools/aapt2/java/ManifestClassGenerator_test.cpp @@ -15,7 +15,6 @@ */ #include "java/ManifestClassGenerator.h" - #include "test/Builders.h" #include "test/Context.h" @@ -25,7 +24,7 @@ namespace aapt { TEST(ManifestClassGeneratorTest, NameIsProperlyGeneratedFromSymbol) { std::unique_ptr context = test::ContextBuilder().build(); - std::unique_ptr manifest = test::buildXmlDom(R"EOF( + std::unique_ptr manifest = test::buildXmlDom(R"EOF( @@ -75,7 +74,7 @@ TEST(ManifestClassGeneratorTest, NameIsProperlyGeneratedFromSymbol) { TEST(ManifestClassGeneratorTest, CommentsAndAnnotationsArePresent) { std::unique_ptr context = test::ContextBuilder().build(); - std::unique_ptr manifest = test::buildXmlDom(R"EOF( + std::unique_ptr manifest = test::buildXmlDom(R"EOF( diff --git a/tools/aapt2/java/ProguardRules.cpp b/tools/aapt2/java/ProguardRules.cpp index 44314772fbd4..c0968545ad81 100644 --- a/tools/aapt2/java/ProguardRules.cpp +++ b/tools/aapt2/java/ProguardRules.cpp @@ -14,10 +14,9 @@ * limitations under the License. */ -#include "XmlDom.h" - #include "java/ProguardRules.h" #include "util/Util.h" +#include "xml/XmlDom.h" #include #include @@ -40,11 +39,11 @@ public: virtual void visit(xml::Element* node) override { if (!node->namespaceUri.empty()) { - Maybe maybePackage = util::extractPackageFromNamespace( + Maybe maybePackage = xml::extractPackageFromNamespace( node->namespaceUri); if (maybePackage) { // This is a custom view, let's figure out the class name from this. - std::u16string package = maybePackage.value() + u"." + node->name; + std::u16string package = maybePackage.value().package + u"." + node->name; if (util::isJavaClassName(package)) { addClass(node->lineNumber, package); } @@ -185,7 +184,8 @@ struct ManifestVisitor : public BaseVisitor { std::u16string mPackage; }; -bool collectProguardRulesForManifest(const Source& source, XmlResource* res, KeepSet* keepSet) { +bool collectProguardRulesForManifest(const Source& source, xml::XmlResource* res, + KeepSet* keepSet) { ManifestVisitor visitor(source, keepSet); if (res->root) { res->root->accept(&visitor); @@ -194,7 +194,7 @@ bool collectProguardRulesForManifest(const Source& source, XmlResource* res, Kee return false; } -bool collectProguardRules(const Source& source, XmlResource* res, KeepSet* keepSet) { +bool collectProguardRules(const Source& source, xml::XmlResource* res, KeepSet* keepSet) { if (!res->root) { return false; } diff --git a/tools/aapt2/java/ProguardRules.h b/tools/aapt2/java/ProguardRules.h index be61eb9095c2..aafffd39d84e 100644 --- a/tools/aapt2/java/ProguardRules.h +++ b/tools/aapt2/java/ProguardRules.h @@ -19,8 +19,7 @@ #include "Resource.h" #include "Source.h" - -#include "process/IResourceTableConsumer.h" +#include "xml/XmlDom.h" #include #include @@ -47,8 +46,8 @@ private: std::map> mKeepMethodSet; }; -bool collectProguardRulesForManifest(const Source& source, XmlResource* res, KeepSet* keepSet); -bool collectProguardRules(const Source& source, XmlResource* res, KeepSet* keepSet); +bool collectProguardRulesForManifest(const Source& source, xml::XmlResource* res, KeepSet* keepSet); +bool collectProguardRules(const Source& source, xml::XmlResource* res, KeepSet* keepSet); bool writeKeepSet(std::ostream* out, const KeepSet& keepSet); -- cgit v1.2.3-59-g8ed1b