diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmArchiveWrite.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 48 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 21 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 3 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 51 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 6 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 37 | ||||
-rw-r--r-- | Source/cmQtAutomoc.cxx | 5 | ||||
-rw-r--r-- | Source/kwsys/hashtable.hxx.in | 2 |
16 files changed, 163 insertions, 50 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2e95a19..345a56f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 8) -SET(CMake_VERSION_TWEAK 20120604) +SET(CMake_VERSION_TWEAK 20120612) #SET(CMake_VERSION_RC 1) diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index dc6b749..b410e44 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -240,6 +240,7 @@ bool cmArchiveWrite::AddFile(const char* file, // Clear acl and xattr fields not useful for distribution. archive_entry_acl_clear(e); archive_entry_xattr_clear(e); + archive_entry_set_fflags(e, 0, 0); if(archive_write_header(this->Archive, e) != ARCHIVE_OK) { this->Error = "archive_write_header: "; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f3a7090..a47ca36 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2495,3 +2495,16 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) cmSystemTools::RemoveFile(file.c_str()); } } + +//---------------------------------------------------------------------------- +// static +std::string cmGlobalGenerator::EscapeJSON(const std::string& s) { + std::string result; + for (std::string::size_type i = 0; i < s.size(); ++i) { + if (s[i] == '"' || s[i] == '\\') { + result += '\\'; + } + result += s[i]; + } + return result; +} diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0ac38a0..ce91793 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -282,6 +282,8 @@ public: /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; + static std::string EscapeJSON(const std::string& s); + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 328706c..40348e6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -66,7 +66,7 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident, if (std::find_if(ident.begin(), ident.end(), std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) { static unsigned VarNum = 0; - std::ostringstream names; + cmOStringStream names; names << "ident" << VarNum++; vars << names.str() << " = " << ident << "\n"; return "$" + names.str(); @@ -123,7 +123,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, cmGlobalNinjaGenerator::WriteComment(os, comment); - std::ostringstream builds; + cmOStringStream builds; // TODO: Better formatting for when there are multiple input/output files. @@ -341,6 +341,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() : cmGlobalGenerator() , BuildFileStream(0) , RulesFileStream(0) + , CompileCommandsStream(0) , Rules() , AllDependencies() { @@ -390,6 +391,7 @@ void cmGlobalNinjaGenerator::Generate() this->BuildFileStream->setstate(std::ios_base::failbit); } + this->CloseCompileCommandsStream(); this->CloseRulesFileStream(); this->CloseBuildFileStream(); } @@ -623,6 +625,46 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream() } } +void cmGlobalNinjaGenerator::AddCXXCompileCommand( + const std::string &commandLine, + const std::string &sourceFile) +{ + // Compute Ninja's build file path. + std::string buildFileDir = + this->GetCMakeInstance()->GetHomeOutputDirectory(); + if (!this->CompileCommandsStream) + { + std::string buildFilePath = buildFileDir + "/compile_commands.json"; + + // Get a stream where to generate things. + this->CompileCommandsStream = + new cmGeneratedFileStream(buildFilePath.c_str()); + *this->CompileCommandsStream << "["; + } else { + *this->CompileCommandsStream << "," << std::endl; + } + + *this->CompileCommandsStream << "\n{\n" + << " \"directory\": \"" + << cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n" + << " \"command\": \"" + << cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n" + << " \"file\": \"" + << cmGlobalGenerator::EscapeJSON(sourceFile) << "\"\n" + << "}"; +} + +void cmGlobalNinjaGenerator::CloseCompileCommandsStream() +{ + if (this->CompileCommandsStream) + { + *this->CompileCommandsStream << "\n]"; + delete this->CompileCommandsStream; + this->CompileCommandsStream = 0; + } + +} + void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) { os @@ -783,7 +825,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) cmLocalGenerator *lg = this->LocalGenerators[0]; cmMakefile* mfRoot = lg->GetMakefile(); - std::ostringstream cmd; + cmOStringStream cmd; cmd << lg->ConvertToOutputFormat( mfRoot->GetRequiredDefinition("CMAKE_COMMAND"), cmLocalGenerator::SHELL) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e652972..7b6b9b7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -213,6 +213,9 @@ public: cmGeneratedFileStream* GetRulesFileStream() const { return this->RulesFileStream; } + void AddCXXCompileCommand(const std::string &commandLine, + const std::string &sourceFile); + /** * Add a rule to the generated build system. * Call WriteRule() behind the scene but perform some check before like: @@ -254,6 +257,8 @@ private: void OpenBuildFileStream(); void CloseBuildFileStream(); + void CloseCompileCommandsStream(); + void OpenRulesFileStream(); void CloseRulesFileStream(); @@ -311,6 +316,7 @@ private: /// The file containing the rule statements. (The action attached to each /// edge of the compilation DAG). cmGeneratedFileStream* RulesFileStream; + cmGeneratedFileStream* CompileCommandsStream; /// The type used to store the set of rules added to the generated build /// system. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index e63de9c..ebd8219 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -103,18 +103,6 @@ cmGlobalUnixMakefileGenerator3 } } -//---------------------------------------------------------------------------- -std::string EscapeJSON(const std::string& s) { - std::string result; - for (std::string::size_type i = 0; i < s.size(); ++i) { - if (s[i] == '"' || s[i] == '\\') { - result += '\\'; - } - result += s[i]; - } - return result; -} - void cmGlobalUnixMakefileGenerator3::Generate() { // first do superclass method @@ -179,11 +167,14 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( *this->CommandDatabase << "," << std::endl; } *this->CommandDatabase << "{" << std::endl - << " \"directory\": \"" << EscapeJSON(workingDirectory) << "\"," + << " \"directory\": \"" + << cmGlobalGenerator::EscapeJSON(workingDirectory) << "\"," << std::endl - << " \"command\": \"" << EscapeJSON(compileCommand) << "\"," + << " \"command\": \"" << + cmGlobalGenerator::EscapeJSON(compileCommand) << "\"," << std::endl - << " \"file\": \"" << EscapeJSON(sourceFile) << "\"" + << " \"file\": \"" << + cmGlobalGenerator::EscapeJSON(sourceFile) << "\"" << std::endl << "}"; } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 18a786d..947a1c9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -278,3 +278,9 @@ void cmGlobalVisualStudio10Generator::PathTooLong( this->LongestSource.SourceRel = sfRel; } } + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio10Generator::UseFolderProperty() +{ + return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty(); +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 4236563..060cdff 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -88,6 +88,9 @@ protected: std::string PlatformToolset; bool ExpressEdition; + + bool UseFolderProperty(); + private: struct LongestSourcePath { diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 425b219..f6a6bc2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -280,7 +280,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( // $in variables. A discussion about dealing with multiple commands in // a rule is started here: // groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 - std::ostringstream cmd; + cmOStringStream cmd; for (std::vector<std::string>::const_iterator li = cmdLines.begin(); li != cmdLines.end(); ++li) { if (li != cmdLines.begin()) @@ -299,7 +299,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, if (!wd) wd = this->GetMakefile()->GetStartOutputDirectory(); - std::ostringstream cdCmd; + cmOStringStream cdCmd; cdCmd << "cd " << this->ConvertToOutputFormat(wd, SHELL); cmdLines.push_back(cdCmd.str()); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a645303..db93529 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -36,6 +36,30 @@ #include <queue> //---------------------------------------------------------------------------- +// Escape special characters in Makefile dependency lines +class cmMakeSafe +{ +public: + cmMakeSafe(const char* s): Data(s) {} + cmMakeSafe(std::string const& s): Data(s.c_str()) {} +private: + const char* Data; + friend std::ostream& operator<<(std::ostream& os, + cmMakeSafe const& self) + { + for(const char* c = self.Data; *c; ++c) + { + switch (*c) + { + case '=': os << "$(EQUALS)"; break; + default: os << *c; break; + } + } + return os; + } +}; + +//---------------------------------------------------------------------------- // Helper function used below. static std::string cmSplitExtension(std::string const& in, std::string& base) { @@ -555,28 +579,13 @@ cmLocalUnixMakefileGenerator3 space = " "; } - // Warn about paths not supported by Make tools. - std::string::size_type pos = tgt.find_first_of("="); - if(pos != std::string::npos) - { - cmOStringStream m; - m << - "Make rule for\n" - " " << tgt << "\n" - "has '=' on left hand side. " - "The make tool may not support this."; - cmListFileBacktrace bt; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, m.str(), bt); - } - // Mark the rule as symbolic if requested. if(symbolic) { if(const char* sym = this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) { - os << tgt.c_str() << space << ": " << sym << "\n"; + os << cmMakeSafe(tgt) << space << ": " << sym << "\n"; } } @@ -584,7 +593,7 @@ cmLocalUnixMakefileGenerator3 if(depends.empty()) { // No dependencies. The commands will always run. - os << tgt.c_str() << space << ":\n"; + os << cmMakeSafe(tgt) << space << ":\n"; } else { @@ -595,7 +604,7 @@ cmLocalUnixMakefileGenerator3 { replace = *dep; replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); - os << tgt.c_str() << space << ": " << replace.c_str() << "\n"; + os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; } } @@ -608,7 +617,7 @@ cmLocalUnixMakefileGenerator3 } if(symbolic && !this->WatcomWMake) { - os << ".PHONY : " << tgt.c_str() << "\n"; + os << ".PHONY : " << cmMakeSafe(tgt) << "\n"; } os << "\n"; // Add the output to the local help if requested. @@ -687,6 +696,10 @@ cmLocalUnixMakefileGenerator3 << this->ConvertShellCommand(cmakecommand, FULL) << " -E remove -f\n" << "\n"; + makefileStream + << "# Escaping for special characters.\n" + << "EQUALS = =\n" + << "\n"; if(const char* edit_cmd = this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9faf46d..f2ab79d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1933,9 +1933,11 @@ cmLocalVisualStudio7Generator vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, cmSystemTools::KeyWOW64_32); - if (intelVersion.find("12") == 0 || (intelVersion.find("11") == 0)) + if (intelVersion.find("13") == 0 || + intelVersion.find("12") == 0 || + intelVersion.find("11") == 0) { - // Version 11.x and 12.x actually use 11.0 in project files! + // Version 11.x, 12.x, and 13.x actually use 11.0 in project files! intelVersion = "11.0" ; } else if(intelVersion.find("10") == 0) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8b86a98..1751091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -215,10 +215,10 @@ cmNinjaNormalTargetGenerator this->GetLocalGenerator()->BuildCommandLine(linkCmds); // Write the linker rule. - std::ostringstream comment; + cmOStringStream comment; comment << "Rule for linking " << this->TargetLinkLanguage << " " << this->GetVisibleTypeName() << "."; - std::ostringstream description; + cmOStringStream description; description << "Linking " << this->TargetLinkLanguage << " " << this->GetVisibleTypeName() << " $out"; this->GetGlobalGenerator()->AddRule(ruleName, @@ -353,7 +353,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() /*implib=*/true).c_str()); // Compute the comment. - std::ostringstream comment; + cmOStringStream comment; comment << "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b3394bb..a362d13 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -362,9 +362,9 @@ cmNinjaTargetGenerator this->GetLocalGenerator()->BuildCommandLine(compileCmds); // Write the rule for compiling file of the given language. - std::ostringstream comment; + cmOStringStream comment; comment << "Rule for compiling " << language << " files."; - std::ostringstream description; + cmOStringStream description; description << "Building " << language << " object $out"; this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), cmdLine, @@ -484,6 +484,39 @@ cmNinjaTargetGenerator vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) + { + cmLocalGenerator::RuleVariables compileObjectVars; + std::string lang = language; + compileObjectVars.Language = lang.c_str(); + std::string escapedSourceFileName = + this->LocalGenerator->ConvertToOutputFormat( + sourceFileName.c_str(), cmLocalGenerator::SHELL); + compileObjectVars.Source = escapedSourceFileName.c_str(); + compileObjectVars.Object = objectFileName.c_str(); + compileObjectVars.Flags = vars["FLAGS"].c_str(); + compileObjectVars.Defines = vars["DEFINES"].c_str(); + + // Rule for compiling object file. + std::string compileCmdVar = "CMAKE_"; + compileCmdVar += language; + compileCmdVar += "_COMPILE_OBJECT"; + std::string compileCmd = + this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + std::vector<std::string> compileCmds; + cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + + for (std::vector<std::string>::iterator i = compileCmds.begin(); + i != compileCmds.end(); ++i) + this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars); + + std::string cmdLine = + this->GetLocalGenerator()->BuildCommandLine(compileCmds); + + this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, + sourceFileName); + } + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment, rule, diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index ca27530..113d678 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -18,6 +18,7 @@ #include "cmSystemTools.h" #include <cmsys/Terminal.h> +#include <cmsys/ios/sstream> #include <string.h> #if defined(__APPLE__) @@ -549,7 +550,7 @@ bool cmQtAutomoc::RunAutomoc() this->GenerateMoc(it->first, it->second); } - std::stringstream outStream(std::stringstream::out); + cmsys_ios::stringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; bool automocCppChanged = false; @@ -1077,7 +1078,7 @@ bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) std::string cmQtAutomoc::ReadAll(const std::string& filename) { std::ifstream file(filename.c_str()); - std::stringstream stream; + cmsys_ios::stringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index db52fc8..c835503 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -394,7 +394,7 @@ enum { _stl_num_primes = 31 }; // create a function with a static local to that function that returns // the static -inline const unsigned long* get_stl_prime_list() { +static inline const unsigned long* get_stl_prime_list() { static const unsigned long _stl_prime_list[_stl_num_primes] = { |