summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceFileWriter.h
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-10-11 20:12:09 +0000
committerZachary Turner <zturner@google.com>2017-10-11 20:12:09 +0000
commitfa0ca6cbd01c6289ef4073073a84200a883eb3c5 (patch)
tree2abc3114b64d579879e5787ea6a3e9cb9adbce79 /llvm/tools/llvm-rc/ResourceFileWriter.h
parent210d9f43a33e98bb60231972c618482de1fdc0d6 (diff)
downloadbcm5719-llvm-fa0ca6cbd01c6289ef4073073a84200a883eb3c5.tar.gz
bcm5719-llvm-fa0ca6cbd01c6289ef4073073a84200a883eb3c5.zip
[llvm-rc] Use proper search algorithm for finding resources.
Previously we would only look in the current directory for a resource, which might not be the same as the directory of the rc file. Furthermore, MSVC rc supports a /I option, and can also look in the system environment. This patch adds support for this search algorithm. Differential Revision: https://reviews.llvm.org/D38740 llvm-svn: 315499
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.h')
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h
index 8d193d6a948..b06b8cf8a6f 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.h
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.h
@@ -22,10 +22,17 @@
namespace llvm {
namespace rc {
+struct SearchParams {
+ std::vector<std::string> Include; // Additional folders to search for files.
+ std::vector<std::string> NoInclude; // Folders to exclude from file search.
+ StringRef InputFilePath; // The full path of the input file.
+};
+
class ResourceFileWriter : public Visitor {
public:
- ResourceFileWriter(std::unique_ptr<raw_fd_ostream> Stream)
- : FS(std::move(Stream)), IconCursorID(1) {
+ ResourceFileWriter(const SearchParams &Params,
+ std::unique_ptr<raw_fd_ostream> Stream)
+ : Params(Params), FS(std::move(Stream)), IconCursorID(1) {
assert(FS && "Output stream needs to be provided to the serializator");
}
@@ -136,6 +143,8 @@ private:
Error writeVersionInfoBlock(const VersionInfoBlock &);
Error writeVersionInfoValue(const VersionInfoValue &);
+ const SearchParams &Params;
+
// Output stream handling.
std::unique_ptr<raw_fd_ostream> FS;
@@ -170,6 +179,8 @@ private:
void padStream(uint64_t Length);
+ Expected<std::unique_ptr<MemoryBuffer>> loadFile(StringRef File) const;
+
// Icon and cursor IDs are allocated starting from 1 and increasing for
// each icon/cursor dumped. This maintains the current ID to be allocated.
uint16_t IconCursorID;
OpenPOWER on IntegriCloud