summaryrefslogtreecommitdiffstats
path: root/Source/cmcldeps.cxx
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-13 17:20:01 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-13 17:20:01 (GMT)
commitab8a2a57f2a4f746a42c4b7a1d52f93c15216b68 (patch)
tree2f12085a6fdf85e51216b8f3bc51b91007eebffc /Source/cmcldeps.cxx
parent4b43999ca307894caaabe8857412f5f575e60583 (diff)
downloadCMake-ab8a2a57f2a4f746a42c4b7a1d52f93c15216b68.zip
CMake-ab8a2a57f2a4f746a42c4b7a1d52f93c15216b68.tar.gz
CMake-ab8a2a57f2a4f746a42c4b7a1d52f93c15216b68.tar.bz2
Ninja: onyl use pre processor for rc file parsing
Diffstat (limited to 'Source/cmcldeps.cxx')
-rw-r--r--Source/cmcldeps.cxx28
1 files changed, 12 insertions, 16 deletions
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index 542fb90..193a2e0 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -604,7 +604,8 @@ bool contains(const std::string& str, const std::string& what) {
return str.find(what) != std::string::npos;
}
-std::string replace(const std::string& str, const std::string& what, const std::string& replacement) {
+std::string replace(const std::string& str, const std::string& what,
+ const std::string& replacement) {
size_t pos = str.find(what);
if (pos == std::string::npos)
return str;
@@ -614,12 +615,12 @@ std::string replace(const std::string& str, const std::string& what, const std::
-static int process(bool ignoreErrors,
- const string& srcfile,
+static int process( const string& srcfile,
const string& dfile,
const string& objfile,
const string& prefix,
- const string& cmd) {
+ const string& cmd,
+ bool quiet = false) {
SubprocessSet subprocs;
Subprocess* subproc = subprocs.Add(cmd);
@@ -652,8 +653,7 @@ static int process(bool ignoreErrors,
}
} else {
if (!isFirstLine || !startsWith(line, srcfile)) {
- if (!ignoreErrors) {
- // suppress errors when cl is fed with a rc file
+ if (!quiet) {
fprintf(stdout, "%s\n", line.c_str());
}
} else {
@@ -663,10 +663,6 @@ static int process(bool ignoreErrors,
}
if (!success) {
- if (ignoreErrors) {
- //printf("\n-- RC file %i dependencies in %s\n\n", includes.size(), dfile.c_str());
- outputDepFile(dfile, objfile, includes);
- }
return exit_code;
}
@@ -699,19 +695,19 @@ int main() {
#endif
if (lang != "RC") {
- return process(false, srcfile, dfile, objfile, prefix, binpath + " /showIncludes " + rest);
+ return process(srcfile, dfile, objfile, prefix,
+ binpath + " /showIncludes " + rest);
} else {
// "misuse" cl.exe to get headers from .rc files
// rc: /fo x\CMakeFiles\x.dir\x.rc.res src\x\x.rc
// cl: /out:x\CMakeFiles\x.dir\x.rc.res.dep.obj /Tc src\x\x.rc
- cl = "\"" + cl + "\" /showIncludes ";
- string clRest = rest;
- clRest = replace(clRest, "/fo" + objfile, "/out:" + objfile + ".dep.obj /Tc ");
+ cl = "\"" + cl + "\" /P /DRC_INVOKED /showIncludes " +
+ replace(rest, "/fo" + objfile, "/out:" + objfile + ".dep.obj /Tc ");
int ret;
- ret = process(true, srcfile, dfile, objfile, prefix, cl + clRest);
- ret = process(false, srcfile, "" , objfile, prefix, binpath + " " + rest);
+ ret = process(srcfile, dfile, objfile, prefix, cl, true);
+ ret = process(srcfile, "" , objfile, prefix, binpath + " " + rest);
return ret;
}