From 84a18cb5d659602235cc995497f5fb016560d553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Sun, 15 Jul 2012 14:47:02 +0200 Subject: [PATCH 1/3] Ninja: also stop when .rc's .d file couldn't be generated prevents silent disappearing of .d files for resource files. cmcldeps changes directory for cl call, so relativ include paths do not work. --- Source/cmNinjaTargetGenerator.cxx | 6 ++++-- Source/cmcldeps.cxx | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 475898956..7eb3d9e27 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -143,16 +143,18 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->LocalGenerator->AddCMP0018Flags(flags, this->Target, language.c_str()); - // TODO: Handle response file. // Add include directory flags. { std::vector includes; this->LocalGenerator->GetIncludeDirectories(includes, this->Target, language.c_str()); std::string includeFlags = - this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), false); + this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), + language == "RC" ? true : false); // full include paths for RC + // needed by cmcldeps if(cmGlobalNinjaGenerator::IsMinGW()) cmSystemTools::ReplaceString(includeFlags, "\\", "/"); + this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); } diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index ce64132bb..f04ff87e4 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -206,7 +206,7 @@ static int process( const std::string& srcfilename, includes.push_back(inc); } else { if (!isFirstLine || !startsWith(line, srcfilename)) { - if (!quiet) { + if (!quiet || exit_code != 0) { fprintf(stdout, "%s\n", line.c_str()); } } else { @@ -267,8 +267,11 @@ int main() { } // extract dependencies with cl.exe - process(srcfilename, dfile, objfile, - prefix, cl + nol + show + clrest, objdir, true); + int exit_code = process(srcfilename, dfile, objfile, + prefix, cl + nol + show + clrest, objdir, true); + + if (exit_code != 0) + return exit_code; // compile rc file with rc.exe return process(srcfilename, "" , objfile, prefix, binpath + " " + rest); From 1cdeef795a9765091027656e5b904059da8fc1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Mon, 16 Jul 2012 16:48:32 +0200 Subject: [PATCH 2/3] Ninja: readd quotes to src file path before patching it --- Source/cmcldeps.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index f04ff87e4..69df88d2a 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -254,7 +254,10 @@ int main() { // rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj clrest = replace(clrest, "/fo", "/out:"); clrest = replace(clrest, objfile, objfile + ".dep.obj "); + // rc: src\x\x.rc -> cl: /Tc src\x\x.rc + if (srcfile.find(" ") != std::string::npos) + srcfile = "\"" + srcfile + "\""; clrest = replace(clrest, srcfile, "/Tc " + srcfile); cl = "\"" + cl + "\" /P /DRC_INVOKED "; From 74d1c88529caa6d048418ea36e09a1d446472d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Tue, 17 Jul 2012 18:54:56 +0200 Subject: [PATCH 3/3] Ninja: cmcldeps needs absolute paths for RCs --- Source/cmNinjaTargetGenerator.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 7eb3d9e27..0d020398a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -469,7 +469,7 @@ cmNinjaTargetGenerator cmNinjaDeps emptyDeps; std::string comment; - const char* language = source->GetLanguage(); + const std::string language = source->GetLanguage(); std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; @@ -479,7 +479,11 @@ cmNinjaTargetGenerator this->Objects.push_back(objectFileName); cmNinjaDeps explicitDeps; - std::string sourceFileName = this->GetSourceFilePath(source); + std::string sourceFileName; + if (language == "RC") + sourceFileName = source->GetFullPath(); + else + sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); // Ensure that the target dependencies are built before any source file in