Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Enterprise Quality Linker(LDC)

Name: Anonymous 2016-10-06 14:02

int executeMsvcToolAndWait(const std::string &tool,
const std::vector<std::string> &args, bool verbose) {
llvm::SmallString<1024> commandLine; // full command line incl. executable
// if the VSINSTALLDIR environment variable is NOT set,
// the MSVC environment needs to be set up
const bool needMsvcSetup = !getenv("VSINSTALLDIR");
if (needMsvcSetup) {
/* <command line> => %ComSpec% /s /c "<batch file> <command line>"
*
* cmd.exe /c treats the following string argument (the command)
* in a very peculiar way if it starts with a double-quote.
* By adding /s and enclosing the command in extra double-quotes
* (WITHOUT additionally escaping the command), the command will
* be parsed properly.
*/
auto comspecEnv = getenv("ComSpec");
if (!comspecEnv) {
warning(Loc(),
"'ComSpec' environment variable is not set, assuming 'cmd.exe'.");
comspecEnv = "cmd.exe";
}
std::string cmdExecutable = comspecEnv;
std::string batchFile = exe_path::prependBinDir(
global.params.targetTriple->isArch64Bit() ? "amd64.bat" : "x86.bat");
commandLine.append(windows::quoteArg(cmdExecutable));
commandLine.append(" /s /c \"");
commandLine.append(windows::quoteArg(batchFile));
commandLine.push_back(' ');
commandLine.append(windows::quoteArg(tool));
} else {
std::string toolPath = getProgram(tool.c_str());
commandLine.append(windows::quoteArg(toolPath));
}
const size_t commandLineLengthAfterTool = commandLine.size();
// append (quoted) args
for (size_t i = 0; i < args.size(); ++i) {
commandLine.push_back(' ');
commandLine.append(windows::quoteArg(args[i]));
}
const bool useResponseFile = (!args.empty() && commandLine.size() > 2000);
llvm::SmallString<128> responseFilePath;
if (useResponseFile) {
const size_t firstArgIndex = commandLineLengthAfterTool + 1;
llvm::StringRef content(commandLine.data() + firstArgIndex,
commandLine.size() - firstArgIndex);
if (llvm::sys::fs::createTemporaryFile("ldc_link", "rsp",
responseFilePath) ||
llvm::sys::writeFileWithEncoding(
responseFilePath,
content)) // keep encoding (LLVM assumes UTF-8 input)
{
error(Loc(), "cannot write temporary response file for %s", tool.c_str());
return -1;
}
// replace all args by @<responseFilePath>
std::string responseFileArg = ("@" + responseFilePath).str();
commandLine.resize(firstArgIndex);
commandLine.append(windows::quoteArg(responseFileArg));
}
if (needMsvcSetup)
commandLine.push_back('"');
const char *finalCommandLine = commandLine.c_str();
if (verbose) {
fprintf(global.stdmsg, finalCommandLine);
fprintf(global.stdmsg, "\n");
fflush(global.stdmsg);
}
const int exitCode = windows::executeAndWait(finalCommandLine);
if (exitCode != 0) {
commandLine.resize(commandLineLengthAfterTool);
if (needMsvcSetup)
commandLine.push_back('"');
error(Loc(), "`%s` failed with status: %d", commandLine.c_str(), exitCode);
}
if (useResponseFile)
llvm::sys::fs::remove(responseFilePath);
return exitCode;
}

Name: Anonymous 2016-10-06 14:07

Name: Anonymous 2016-10-06 15:22

who doesn't indent their code?

Name: Anonymous 2016-10-07 15:49

>>3
Indenting code is too pythonic for my tastes

Name: Anonymous 2016-10-08 1:19

Writing code is too pythonic for my tastes.

Name: suigin 2016-10-08 6:41

At least it's not cudder style indentation.

Name: Anonymous 2016-10-08 18:04

>>6
How does Cudder indent her code?

Name: Anonymous 2016-10-08 18:40

>>7
With a hammer.

Don't change these.
Name: Email:
Entire Thread Thread List