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