summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmSystemTools.cxx22
-rw-r--r--Source/cmSystemTools.h9
-rw-r--r--Source/cmake.cxx6
-rw-r--r--Source/cmake.h3
-rw-r--r--Source/cmakemain.cxx8
5 files changed, 40 insertions, 8 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index ba620d1..1971610 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -247,6 +247,12 @@ void cmSystemTools::Stdout(const char* s)
}
}
+void cmSystemTools::Stderr(const char* s, int length)
+{
+ std::cerr.write(s, length);
+ std::cerr.flush();
+}
+
void cmSystemTools::Stdout(const char* s, int length)
{
if(s_StdoutCallback)
@@ -630,7 +636,21 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
}
if(outputflag != OUTPUT_NONE)
{
- cmSystemTools::Stdout(data, length);
+ 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);
+ }
+ }
}
}
}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index bf513ad..641c89f 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -75,6 +75,9 @@ public:
typedef void (*StdoutCallback)(const char*, int length, void*);
static void SetStdoutCallback(StdoutCallback, void* clientData=0);
+ ///! Send a string to stderr. Stdout callbacks will not be invoced.
+ static void Stderr(const char* s, int length);
+
///! Return true if there was an error at any point.
static bool GetErrorOccuredFlag()
{
@@ -196,7 +199,8 @@ 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.
+ * into stdout. OUTPUT_NORMAL passes through the output to stdout/stderr as
+ * it was received.
*
* If timeout is specified, the command will be terminated after
* timeout expires. Timeout is specified in seconds.
@@ -214,7 +218,8 @@ public:
enum OutputOption
{
OUTPUT_NONE = 0,
- OUTPUT_MERGE
+ OUTPUT_MERGE,
+ OUTPUT_NORMAL
};
static bool RunSingleCommand(const char* command, std::string* output = 0,
int* retVal = 0, const char* dir = 0,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 3473d91..137665d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -4296,7 +4296,8 @@ int cmake::Build(const std::string& dir,
const std::string& target,
const std::string& config,
const std::vector<std::string>& nativeOptions,
- bool clean)
+ bool clean,
+ cmSystemTools::OutputOption outputflag)
{
if(!cmSystemTools::FileIsDirectory(dir.c_str()))
{
@@ -4338,8 +4339,7 @@ int cmake::Build(const std::string& dir,
projName.c_str(), target.c_str(),
&output,
makeProgram.c_str(),
- config.c_str(), clean, false, 0,
- cmSystemTools::OUTPUT_MERGE,
+ config.c_str(), clean, false, 0, outputflag,
0, nativeOptions);
}
diff --git a/Source/cmake.h b/Source/cmake.h
index fac86c1..88847cf 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -364,7 +364,8 @@ class cmake
const std::string& target,
const std::string& config,
const std::vector<std::string>& nativeOptions,
- bool clean);
+ bool clean,
+ cmSystemTools::OutputOption outputflag);
void UnwatchUnusedCli(const char* var);
void WatchUnusedCli(const char* var);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 663ce8f..1fe9e82 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -62,6 +62,7 @@ static const char * cmDocumentationDescription[][3] =
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
" --clean-first = Build target 'clean' first, then build.\n" \
" (To clean only, use --target 'clean'.)\n" \
+ " --use-stderr = Don't merge stdout/stderr.\n" \
" -- = Pass remaining options to the native tool.\n"
//----------------------------------------------------------------------------
@@ -568,6 +569,7 @@ static int do_build(int ac, char** av)
std::string dir;
std::vector<std::string> nativeOptions;
bool clean = false;
+ cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_MERGE;
enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
Doing doing = DoingDir;
@@ -590,6 +592,10 @@ static int do_build(int ac, char** av)
clean = true;
doing = DoingNone;
}
+ else if(strcmp(av[i], "--use-stderr") == 0)
+ {
+ outputflag = cmSystemTools::OUTPUT_NORMAL;
+ }
else if(strcmp(av[i], "--") == 0)
{
doing = DoingNative;
@@ -635,6 +641,6 @@ static int do_build(int ac, char** av)
}
cmake cm;
- return cm.Build(dir, target, config, nativeOptions, clean);
+ return cm.Build(dir, target, config, nativeOptions, clean, outputflag);
#endif
}