Loading tools/aapt2/link/Link.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -1459,6 +1459,21 @@ int link(const std::vector<StringPiece>& args) { return 1; } // Expand all argument-files passed into the command line. These start with '@'. std::vector<std::string> argList; for (const std::string& arg : flags.getArgs()) { if (util::stringStartsWith<char>(arg, "@")) { const std::string path = arg.substr(1, arg.size() - 1); std::string error; if (!file::appendArgsFromFile(path, &argList, &error)) { context.getDiagnostics()->error(DiagMessage(path) << error); return 1; } } else { argList.push_back(arg); } } if (verbose) { context.setVerbose(verbose); } Loading Loading @@ -1568,7 +1583,7 @@ int link(const std::vector<StringPiece>& args) { } LinkCommand cmd(&context, options); return cmd.run(flags.getArgs()); return cmd.run(argList); } } // namespace aapt tools/aapt2/util/Files.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "util/Util.h" #include <algorithm> #include <android-base/file.h> #include <cerrno> #include <cstdio> #include <dirent.h> Loading Loading @@ -190,6 +191,23 @@ Maybe<android::FileMap> mmapPath(const StringPiece& path, std::string* outError) return std::move(fileMap); } bool appendArgsFromFile(const StringPiece& path, std::vector<std::string>* outArgList, std::string* outError) { std::string contents; if (!android::base::ReadFileToString(path.toString(), &contents)) { if (outError) *outError = "failed to read argument-list file"; return false; } for (StringPiece line : util::tokenize<char>(contents, ' ')) { line = util::trimWhitespace(line); if (!line.empty()) { outArgList->push_back(line.toString()); } } return true; } bool FileFilter::setPattern(const StringPiece& pattern) { mPatternTokens = util::splitAndLowercase(pattern, ':'); return true; Loading tools/aapt2/util/Files.h +6 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,12 @@ std::string packageToPath(const StringPiece& package); */ Maybe<android::FileMap> mmapPath(const StringPiece& path, std::string* outError); /** * Reads the file at path and appends each line to the outArgList vector. */ bool appendArgsFromFile(const StringPiece& path, std::vector<std::string>* outArgList, std::string* outError); /* * Filter that determines which resource files/directories are * processed by AAPT. Takes a pattern string supplied by the user. Loading Loading
tools/aapt2/link/Link.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -1459,6 +1459,21 @@ int link(const std::vector<StringPiece>& args) { return 1; } // Expand all argument-files passed into the command line. These start with '@'. std::vector<std::string> argList; for (const std::string& arg : flags.getArgs()) { if (util::stringStartsWith<char>(arg, "@")) { const std::string path = arg.substr(1, arg.size() - 1); std::string error; if (!file::appendArgsFromFile(path, &argList, &error)) { context.getDiagnostics()->error(DiagMessage(path) << error); return 1; } } else { argList.push_back(arg); } } if (verbose) { context.setVerbose(verbose); } Loading Loading @@ -1568,7 +1583,7 @@ int link(const std::vector<StringPiece>& args) { } LinkCommand cmd(&context, options); return cmd.run(flags.getArgs()); return cmd.run(argList); } } // namespace aapt
tools/aapt2/util/Files.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "util/Util.h" #include <algorithm> #include <android-base/file.h> #include <cerrno> #include <cstdio> #include <dirent.h> Loading Loading @@ -190,6 +191,23 @@ Maybe<android::FileMap> mmapPath(const StringPiece& path, std::string* outError) return std::move(fileMap); } bool appendArgsFromFile(const StringPiece& path, std::vector<std::string>* outArgList, std::string* outError) { std::string contents; if (!android::base::ReadFileToString(path.toString(), &contents)) { if (outError) *outError = "failed to read argument-list file"; return false; } for (StringPiece line : util::tokenize<char>(contents, ' ')) { line = util::trimWhitespace(line); if (!line.empty()) { outArgList->push_back(line.toString()); } } return true; } bool FileFilter::setPattern(const StringPiece& pattern) { mPatternTokens = util::splitAndLowercase(pattern, ':'); return true; Loading
tools/aapt2/util/Files.h +6 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,12 @@ std::string packageToPath(const StringPiece& package); */ Maybe<android::FileMap> mmapPath(const StringPiece& path, std::string* outError); /** * Reads the file at path and appends each line to the outArgList vector. */ bool appendArgsFromFile(const StringPiece& path, std::vector<std::string>* outArgList, std::string* outError); /* * Filter that determines which resource files/directories are * processed by AAPT. Takes a pattern string supplied by the user. Loading