Loading tools/aapt2/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ testSources := \ proto/TableProtoSerializer_test.cpp \ split/TableSplitter_test.cpp \ util/BigBuffer_test.cpp \ util/Files_test.cpp \ util/Maybe_test.cpp \ util/StringPiece_test.cpp \ util/Util_test.cpp \ Loading tools/aapt2/Resource.h +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ struct ResourceName { ResourceType type; std::u16string entry; ResourceName() = default; ResourceName() : type(ResourceType::kRaw) {} ResourceName(const StringPiece16& p, ResourceType t, const StringPiece16& e); bool isValid() const; Loading tools/aapt2/link/Link.cpp +29 −8 Original line number Diff line number Diff line Loading @@ -729,12 +729,18 @@ public: std::string outPath = mOptions.generateJavaClassPath.value(); file::appendPath(&outPath, file::packageToPath(util::utf16ToUtf8(outPackage))); file::mkdirs(outPath); if (!file::mkdirs(outPath)) { mContext->getDiagnostics()->error( DiagMessage() << "failed to create directory '" << outPath << "'"); return false; } file::appendPath(&outPath, "R.java"); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } Loading @@ -743,6 +749,11 @@ public: mContext->getDiagnostics()->error(DiagMessage(outPath) << generator.getError()); return false; } if (!fout) { mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); } return true; } Loading @@ -754,12 +765,18 @@ public: std::string outPath = mOptions.generateJavaClassPath.value(); file::appendPath(&outPath, file::packageToPath(util::utf16ToUtf8(mContext->getCompilationPackage()))); file::mkdirs(outPath); if (!file::mkdirs(outPath)) { mContext->getDiagnostics()->error( DiagMessage() << "failed to create directory '" << outPath << "'"); return false; } file::appendPath(&outPath, "Manifest.java"); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } Loading @@ -770,7 +787,8 @@ public: } if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } return true; Loading @@ -781,15 +799,18 @@ public: return true; } std::ofstream fout(mOptions.generateProguardRulesPath.value(), std::ofstream::binary); const std::string& outPath = mOptions.generateProguardRulesPath.value(); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed to open '" << outPath << "': " << strerror(errno)); return false; } proguard::writeKeepSet(&fout, keepSet); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } return true; Loading tools/aapt2/util/Files.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ bool mkdirs(const StringPiece& path) { const char* start = path.begin(); const char* end = path.end(); for (const char* current = start; current != end; ++current) { if (*current == sDirSep) { if (*current == sDirSep && current != start) { StringPiece parentPath(start, current - start); int result = mkdirImpl(parentPath); if (result < 0 && errno != EEXIST) { Loading Loading @@ -139,6 +139,20 @@ StringPiece getExtension(const StringPiece& path) { return {}; } void appendPath(std::string* base, StringPiece part) { assert(base); const bool baseHasTrailingSep = (!base->empty() && *(base->end() - 1) == sDirSep); const bool partHasLeadingSep = (!part.empty() && *(part.begin()) == sDirSep); if (baseHasTrailingSep && partHasLeadingSep) { // Remove the part's leading sep part = part.substr(1, part.size() - 1); } else if (!baseHasTrailingSep && !partHasLeadingSep) { // None of the pieces has a separator. *base += sDirSep; } base->append(part.data(), part.size()); } std::string packageToPath(const StringPiece& package) { std::string outPath; for (StringPiece part : util::tokenize<char>(package, '.')) { Loading tools/aapt2/util/Files.h +1 −22 Original line number Diff line number Diff line Loading @@ -61,14 +61,7 @@ std::vector<std::string> listFiles(const StringPiece& root); /* * Appends a path to `base`, separated by the directory separator. */ void appendPath(std::string* base, const StringPiece& part); /* * Appends a series of paths to `base`, separated by the * system directory separator. */ template <typename... Ts > void appendPath(std::string* base, const StringPiece& part, const Ts&... parts); void appendPath(std::string* base, StringPiece part); /* * Makes all the directories in `path`. The last element in the path Loading Loading @@ -139,20 +132,6 @@ private: std::vector<std::string> mPatternTokens; }; inline void appendPath(std::string* base, const StringPiece& part) { assert(base); *base += sDirSep; base->append(part.data(), part.size()); } template <typename... Ts > void appendPath(std::string* base, const StringPiece& part, const Ts&... parts) { assert(base); *base += sDirSep; base->append(part.data(), part.size()); appendPath(base, parts...); } } // namespace file } // namespace aapt Loading Loading
tools/aapt2/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ testSources := \ proto/TableProtoSerializer_test.cpp \ split/TableSplitter_test.cpp \ util/BigBuffer_test.cpp \ util/Files_test.cpp \ util/Maybe_test.cpp \ util/StringPiece_test.cpp \ util/Util_test.cpp \ Loading
tools/aapt2/Resource.h +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ struct ResourceName { ResourceType type; std::u16string entry; ResourceName() = default; ResourceName() : type(ResourceType::kRaw) {} ResourceName(const StringPiece16& p, ResourceType t, const StringPiece16& e); bool isValid() const; Loading
tools/aapt2/link/Link.cpp +29 −8 Original line number Diff line number Diff line Loading @@ -729,12 +729,18 @@ public: std::string outPath = mOptions.generateJavaClassPath.value(); file::appendPath(&outPath, file::packageToPath(util::utf16ToUtf8(outPackage))); file::mkdirs(outPath); if (!file::mkdirs(outPath)) { mContext->getDiagnostics()->error( DiagMessage() << "failed to create directory '" << outPath << "'"); return false; } file::appendPath(&outPath, "R.java"); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } Loading @@ -743,6 +749,11 @@ public: mContext->getDiagnostics()->error(DiagMessage(outPath) << generator.getError()); return false; } if (!fout) { mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); } return true; } Loading @@ -754,12 +765,18 @@ public: std::string outPath = mOptions.generateJavaClassPath.value(); file::appendPath(&outPath, file::packageToPath(util::utf16ToUtf8(mContext->getCompilationPackage()))); file::mkdirs(outPath); if (!file::mkdirs(outPath)) { mContext->getDiagnostics()->error( DiagMessage() << "failed to create directory '" << outPath << "'"); return false; } file::appendPath(&outPath, "Manifest.java"); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } Loading @@ -770,7 +787,8 @@ public: } if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } return true; Loading @@ -781,15 +799,18 @@ public: return true; } std::ofstream fout(mOptions.generateProguardRulesPath.value(), std::ofstream::binary); const std::string& outPath = mOptions.generateProguardRulesPath.value(); std::ofstream fout(outPath, std::ofstream::binary); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed to open '" << outPath << "': " << strerror(errno)); return false; } proguard::writeKeepSet(&fout, keepSet); if (!fout) { mContext->getDiagnostics()->error(DiagMessage() << strerror(errno)); mContext->getDiagnostics()->error( DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno)); return false; } return true; Loading
tools/aapt2/util/Files.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ bool mkdirs(const StringPiece& path) { const char* start = path.begin(); const char* end = path.end(); for (const char* current = start; current != end; ++current) { if (*current == sDirSep) { if (*current == sDirSep && current != start) { StringPiece parentPath(start, current - start); int result = mkdirImpl(parentPath); if (result < 0 && errno != EEXIST) { Loading Loading @@ -139,6 +139,20 @@ StringPiece getExtension(const StringPiece& path) { return {}; } void appendPath(std::string* base, StringPiece part) { assert(base); const bool baseHasTrailingSep = (!base->empty() && *(base->end() - 1) == sDirSep); const bool partHasLeadingSep = (!part.empty() && *(part.begin()) == sDirSep); if (baseHasTrailingSep && partHasLeadingSep) { // Remove the part's leading sep part = part.substr(1, part.size() - 1); } else if (!baseHasTrailingSep && !partHasLeadingSep) { // None of the pieces has a separator. *base += sDirSep; } base->append(part.data(), part.size()); } std::string packageToPath(const StringPiece& package) { std::string outPath; for (StringPiece part : util::tokenize<char>(package, '.')) { Loading
tools/aapt2/util/Files.h +1 −22 Original line number Diff line number Diff line Loading @@ -61,14 +61,7 @@ std::vector<std::string> listFiles(const StringPiece& root); /* * Appends a path to `base`, separated by the directory separator. */ void appendPath(std::string* base, const StringPiece& part); /* * Appends a series of paths to `base`, separated by the * system directory separator. */ template <typename... Ts > void appendPath(std::string* base, const StringPiece& part, const Ts&... parts); void appendPath(std::string* base, StringPiece part); /* * Makes all the directories in `path`. The last element in the path Loading Loading @@ -139,20 +132,6 @@ private: std::vector<std::string> mPatternTokens; }; inline void appendPath(std::string* base, const StringPiece& part) { assert(base); *base += sDirSep; base->append(part.data(), part.size()); } template <typename... Ts > void appendPath(std::string* base, const StringPiece& part, const Ts&... parts) { assert(base); *base += sDirSep; base->append(part.data(), part.size()); appendPath(base, parts...); } } // namespace file } // namespace aapt Loading