parent
58fcf6df65
commit
5a899e332b
|
|
@ -306,11 +306,12 @@ static bool convertResourceFiles(PECOFFLinkingContext &ctx,
|
||||||
|
|
||||||
// Construct CVTRES.EXE command line and execute it.
|
// Construct CVTRES.EXE command line and execute it.
|
||||||
std::string program = "cvtres.exe";
|
std::string program = "cvtres.exe";
|
||||||
std::string programPath = llvm::sys::FindProgramByName(program);
|
ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
|
||||||
if (programPath.empty()) {
|
if (!programPathOrErr) {
|
||||||
llvm::errs() << "Unable to find " << program << " in PATH\n";
|
llvm::errs() << "Unable to find " << program << " in PATH\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const std::string &programPath = *programPathOrErr;
|
||||||
|
|
||||||
std::vector<const char *> args;
|
std::vector<const char *> args;
|
||||||
args.push_back(programPath.c_str());
|
args.push_back(programPath.c_str());
|
||||||
|
|
@ -562,11 +563,12 @@ static bool createManifestResourceFile(PECOFFLinkingContext &ctx,
|
||||||
|
|
||||||
// Run RC.EXE /fo tmp.res tmp.rc
|
// Run RC.EXE /fo tmp.res tmp.rc
|
||||||
std::string program = "rc.exe";
|
std::string program = "rc.exe";
|
||||||
std::string programPath = llvm::sys::FindProgramByName(program);
|
ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
|
||||||
if (programPath.empty()) {
|
if (!programPathOrErr) {
|
||||||
diag << "Unable to find " << program << " in PATH\n";
|
diag << "Unable to find " << program << " in PATH\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const std::string &programPath = *programPathOrErr;
|
||||||
std::vector<const char *> args;
|
std::vector<const char *> args;
|
||||||
args.push_back(programPath.c_str());
|
args.push_back(programPath.c_str());
|
||||||
args.push_back("/fo");
|
args.push_back("/fo");
|
||||||
|
|
@ -794,11 +796,12 @@ static bool maybeRunLibCommand(int argc, const char **argv, raw_ostream &diag) {
|
||||||
return false;
|
return false;
|
||||||
if (!StringRef(argv[1]).equals_lower("/lib"))
|
if (!StringRef(argv[1]).equals_lower("/lib"))
|
||||||
return false;
|
return false;
|
||||||
std::string path = llvm::sys::FindProgramByName("lib.exe");
|
ErrorOr<std::string> pathOrErr = llvm::sys::findProgramByName("lib.exe");
|
||||||
if (path.empty()) {
|
if (!pathOrErr) {
|
||||||
diag << "Unable to find lib.exe in PATH\n";
|
diag << "Unable to find lib.exe in PATH\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
const std::string &path = *pathOrErr;
|
||||||
|
|
||||||
// Run lib.exe
|
// Run lib.exe
|
||||||
std::vector<const char *> vec;
|
std::vector<const char *> vec;
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,15 @@ static void writeTo(StringRef path, StringRef contents) {
|
||||||
|
|
||||||
/// Creates a .def file and runs lib.exe on it to create an import library.
|
/// Creates a .def file and runs lib.exe on it to create an import library.
|
||||||
void writeImportLibrary(const PECOFFLinkingContext &ctx) {
|
void writeImportLibrary(const PECOFFLinkingContext &ctx) {
|
||||||
std::string program = "lib.exe";
|
|
||||||
std::string programPath = llvm::sys::FindProgramByName(program);
|
|
||||||
|
|
||||||
std::string fileContents = createModuleDefinitionFile(ctx);
|
std::string fileContents = createModuleDefinitionFile(ctx);
|
||||||
|
|
||||||
|
std::string program = "lib.exe";
|
||||||
|
ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
|
||||||
|
if (!programPathOrErr) {
|
||||||
|
llvm::errs() << "Unable to find " << program << " in PATH\n";
|
||||||
|
} else {
|
||||||
|
const std::string &programPath = *programPathOrErr;
|
||||||
|
|
||||||
std::string defPath = writeToTempFile(fileContents);
|
std::string defPath = writeToTempFile(fileContents);
|
||||||
llvm::FileRemover tmpFile(defPath);
|
llvm::FileRemover tmpFile(defPath);
|
||||||
|
|
||||||
|
|
@ -89,9 +94,7 @@ void writeImportLibrary(const PECOFFLinkingContext &ctx) {
|
||||||
args.push_back(outputArg.c_str());
|
args.push_back(outputArg.c_str());
|
||||||
args.push_back(nullptr);
|
args.push_back(nullptr);
|
||||||
|
|
||||||
if (programPath.empty()) {
|
if (llvm::sys::ExecuteAndWait(programPath.c_str(), &args[0]) != 0)
|
||||||
llvm::errs() << "Unable to find " << program << " in PATH\n";
|
|
||||||
} else if (llvm::sys::ExecuteAndWait(programPath.c_str(), &args[0]) != 0) {
|
|
||||||
llvm::errs() << program << " failed\n";
|
llvm::errs() << program << " failed\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue