diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2126c7180..c50bf66ae 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1850,7 +1850,7 @@ int cmGlobalGenerator::Build( !makeCommand.empty() && cmSystemTools::LowerCase( cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe") { - outputflag = cmSystemTools::OUTPUT_NORMAL; + outputflag = cmSystemTools::OUTPUT_FORWARD; } // should we do a clean first? diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a89a6e0b6..3ba72876c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef __QNX__ # include /* for malloc/free on QNX */ #endif @@ -660,14 +661,6 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, argv.push_back(a->c_str()); } argv.push_back(0); - if ( captureStdOut ) - { - *captureStdOut = ""; - } - if (captureStdErr && captureStdErr != captureStdOut) - { - *captureStdErr = ""; - } cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); @@ -681,7 +674,16 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, { cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); + captureStdOut = 0; + captureStdErr = 0; } + else if (outputflag == OUTPUT_MERGE || + (captureStdErr && captureStdErr == captureStdOut)) + { + cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1); + captureStdErr = 0; + } + assert(!captureStdErr || captureStdErr != captureStdOut); cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp); @@ -696,65 +698,50 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, { while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0) { - if(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE) + // Translate NULL characters in the output into valid text. + // Visual Studio 7 puts these characters in the output of its + // build process. + for(int i=0; i < length; ++i) { - // Translate NULL characters in the output into valid text. - // Visual Studio 7 puts these characters in the output of its - // build process. - for(int i=0; i < length; ++i) + if(data[i] == '\0') { - if(data[i] == '\0') - { - data[i] = ' '; - } + data[i] = ' '; } } - if(pipe == cmsysProcess_Pipe_STDOUT || - (pipe == cmsysProcess_Pipe_STDERR && - captureStdOut == captureStdErr)) + + if (pipe == cmsysProcess_Pipe_STDOUT) { + if (outputflag != OUTPUT_NONE) + { + cmSystemTools::Stdout(data, length); + } if (captureStdOut) { tempStdOut.insert(tempStdOut.end(), data, data+length); } } - else if(pipe == cmsysProcess_Pipe_STDERR) + else if (pipe == cmsysProcess_Pipe_STDERR) { + if (outputflag != OUTPUT_NONE) + { + cmSystemTools::Stderr(data, length); + } if (captureStdErr) { tempStdErr.insert(tempStdErr.end(), data, data+length); } } - if(outputflag != OUTPUT_NONE) - { - if(outputflag == OUTPUT_MERGE) - { - cmSystemTools::Stdout(data, length); - } - else - { - if(pipe == cmsysProcess_Pipe_STDERR) - { - cmSystemTools::Stderr(data, length); - } - else if(pipe == cmsysProcess_Pipe_STDOUT) - { - cmSystemTools::Stdout(data, length); - } - } - } } } cmsysProcess_WaitForExit(cp, 0); - if ( captureStdOut && tempStdOut.begin() != tempStdOut.end()) + if (captureStdOut) { - captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size()); + captureStdOut->assign(tempStdOut.begin(), tempStdOut.end()); } - if ( captureStdErr && captureStdErr != captureStdOut && - tempStdErr.begin() != tempStdErr.end()) + if (captureStdErr) { - captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size()); + captureStdErr->assign(tempStdErr.begin(), tempStdErr.end()); } bool result = true; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9cafbecfd..f511ae43d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -203,7 +203,7 @@ public: * Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no * user-viewable output from the program being run will be generated. * OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged - * into stdout. OUTPUT_NORMAL passes through the output to stdout/stderr as + * into stdout. OUTPUT_FORWARD copies the output to stdout/stderr as * it was received. OUTPUT_PASSTHROUGH passes through the original handles. * * If timeout is specified, the command will be terminated after @@ -223,7 +223,7 @@ public: { OUTPUT_NONE = 0, OUTPUT_MERGE, - OUTPUT_NORMAL, + OUTPUT_FORWARD, OUTPUT_PASSTHROUGH }; static bool RunSingleCommand(const char* command, diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index fb7b1f5ff..8dd902bea 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -361,11 +361,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) } // Now run the real compiler command and return its result value. - if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, &stdErr, &ret, 0, + if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, 0, &ret, 0, cmSystemTools::OUTPUT_PASSTHROUGH)) { - std::cerr << "Error running '" << orig_cmd[0] << "': " - << stdErr << "\n"; + std::cerr << "Error running '" << orig_cmd[0] << "'\n"; return 1; } return ret; @@ -621,7 +620,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) int retval = 0; int timeout = 0; if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval, - directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) ) + directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout) ) { return retval; }