[PECOFF][Driver] Interpret "LIB" environment variable.

llvm-svn: 186648
This commit is contained in:
Rui Ueyama 2013-07-19 03:27:03 +00:00
parent 5ec3eb11fc
commit 5a7bbce587
2 changed files with 23 additions and 0 deletions

View File

@ -175,12 +175,32 @@ StringRef getDefaultOutputFileName(PECOFFTargetInfo &info, StringRef path) {
return info.allocateString(smallStr.str());
}
// Split the given string with the path separator.
std::vector<StringRef> splitPathList(StringRef str) {
std::vector<StringRef> ret;
while (!str.empty()) {
StringRef path;
llvm::tie(path, str) = str.split(';');
ret.push_back(path);
}
return std::move(ret);
}
// Process "LIB" environment variable. The variable contains a list of
// search paths separated by semicolons.
void processLibEnvVar(PECOFFTargetInfo &info) {
if (char *envp = ::getenv("LIB"))
for (StringRef path : splitPathList(envp))
info.appendInputSearchPath(info.allocateString(path));
}
} // namespace
bool WinLinkDriver::linkPECOFF(int argc, const char *argv[],
raw_ostream &diagnostics) {
PECOFFTargetInfo info;
processLibEnvVar(info);
if (parse(argc, argv, info, diagnostics))
return true;
return link(info, diagnostics);

View File

@ -8,6 +8,9 @@
#
# RUN: lld -flavor link -out %t1 -subsystem console -libpath %p/Inputs \
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
#
# RUN: LIB=%p/Inputs lld -flavor link -out %t1 -subsystem console \
# RUN: -- %t.obj vars.lib && llvm-objdump -d %t1 | FileCheck %s
CHECK: Disassembly of section .text:
CHECK: .text: