[Cmake-commits] CMake branch, next, updated. v2.8.8-2619-gaec9c6e

Brad King brad.king at kitware.com
Thu Apr 19 07:50:01 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  aec9c6ed79ea47a17d44ea4928e99b56df3b61a8 (commit)
       via  72333a464870155d040e215bec37a7a31070f875 (commit)
       via  369e3464beb8258ce5b2af8bcbe6b476fca379de (commit)
       via  f9b758e91a9afa17123c5b81b5568ebbd52db598 (commit)
      from  8a78562bdf92d76d9ec8579d92813efb5207bfb9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aec9c6ed79ea47a17d44ea4928e99b56df3b61a8
commit aec9c6ed79ea47a17d44ea4928e99b56df3b61a8
Merge: 8a78562 72333a4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Apr 19 07:49:48 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Apr 19 07:49:48 2012 -0400

    Merge topic 'vs10-rule-files' into next
    
    72333a4 VS10: Avoid creating .rule files next to outputs (#13141)
    369e346 Factor out custom command .rule file path generation
    f9b758e Cleanup custom command .rule file internal handling


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=72333a464870155d040e215bec37a7a31070f875
commit 72333a464870155d040e215bec37a7a31070f875
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 18 15:50:49 2012 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 18 15:54:35 2012 -0400

    VS10: Avoid creating .rule files next to outputs (#13141)
    
    Hide custom command .rule files inside the CMakeFiles directory.  Ensure
    a short, deterministic, and unique name by using a hash of the directory
    path containing the output file.  Preserve the file name so the entry in
    the IDE is human-readable.  Clarify the comment that explains why the
    rule file must be created on disk.

diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 22ead10..28d738a 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -212,3 +212,21 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
     return false;
     }
 }
+
+//----------------------------------------------------------------------------
+std::string
+cmGlobalVisualStudio10Generator
+::GenerateRuleFile(std::string const& output) const
+{
+  // The VS 10 generator needs to create the .rule files on disk.
+  // Hide them away under the CMakeFiles directory.
+  std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
+  ruleDir += cmake::GetCMakeFilesDirectory();
+  ruleDir += "/";
+  ruleDir += cmSystemTools::ComputeStringMD5(
+    cmSystemTools::GetFilenamePath(output).c_str());
+  std::string ruleFile = ruleDir + "/";
+  ruleFile += cmSystemTools::GetFilenameName(output);
+  ruleFile += ".rule";
+  return ruleFile;
+}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 750b89c..e2cc14e 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -75,6 +75,10 @@ public:
   virtual const char* GetCMakeCFGIntDir() const
     { return "$(Configuration)";}
   bool Find64BitTools(cmMakefile* mf);
+
+  /** Generate an <output>.rule file path for a given command output.  */
+  virtual std::string GenerateRuleFile(std::string const& output) const;
+
 protected:
   virtual const char* GetIDEVersion() { return "10.0"; }
 
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5921530..9c25b0c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -459,7 +459,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
                                                  command)
 {
   std::string sourcePath = source->GetFullPath();
-  // the rule file seems to need to exist for vs10
+  // VS 10 will always rebuild a custom command attached to a .rule
+  // file that doesn't exist so create the file explicitly.
   if (source->GetPropertyAsBool("__CMAKE_RULE"))
     {
     if(!cmSystemTools::FileExists(sourcePath.c_str()))

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=369e3464beb8258ce5b2af8bcbe6b476fca379de
commit 369e3464beb8258ce5b2af8bcbe6b476fca379de
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 18 15:28:12 2012 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 18 15:49:38 2012 -0400

    Factor out custom command .rule file path generation
    
    Add cmGlobalGenerator::GenerateRuleFile to compute a generator-specific
    rule file location.  This will allow specific generators to override the
    location of .rule files without changing the behavior of other
    generators.

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 545f9e8..b06cdb4 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2092,6 +2092,21 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
 }
 
 //----------------------------------------------------------------------------
+std::string
+cmGlobalGenerator::GenerateRuleFile(std::string const& output) const
+{
+  std::string ruleFile = output;
+  ruleFile += ".rule";
+  const char* dir = this->GetCMakeCFGIntDir();
+  if(dir && dir[0] == '$')
+    {
+    cmSystemTools::ReplaceString(ruleFile, dir,
+                                 cmake::GetCMakeFilesDirectory());
+    }
+  return ruleFile;
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
                                                  const char*, std::string&)
 {
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 80b948b..5254b89 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -277,6 +277,9 @@ public:
       i.e. "Can I build Debug and Release in the same tree?" */
   virtual bool IsMultiConfig() { return false; }
 
+  /** Generate an <output>.rule file path for a given command output.  */
+  virtual std::string GenerateRuleFile(std::string const& output) const;
+
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f2865f6..17bb5ed 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -948,17 +948,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
   // Generate a rule file if the main dependency is not available.
   if(!file)
     {
+    cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
+
     // Construct a rule file associated with the first output produced.
-    std::string outName = outputs[0];
-    outName += ".rule";
-    const char* dir =
-      this->LocalGenerator->GetGlobalGenerator()->
-      GetCMakeCFGIntDir();
-    if(dir && dir[0] == '$')
-      {
-      cmSystemTools::ReplaceString(outName, dir,
-                                   cmake::GetCMakeFilesDirectory());
-      }
+    std::string outName = gg->GenerateRuleFile(outputs[0]);
+
     // Check if the rule file already exists.
     file = this->GetSource(outName.c_str());
     if(file && file->GetCustomCommand() && !replace)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9b758e91a9afa17123c5b81b5568ebbd52db598
commit f9b758e91a9afa17123c5b81b5568ebbd52db598
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 18 14:42:43 2012 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 18 15:48:50 2012 -0400

    Cleanup custom command .rule file internal handling
    
    Teach cmMakefile::AddCustomCommandToOutput to return the cmSourceFile
    instance to which the custom command is attached.  Use the return value
    instead of separately adding a .rule extension and searching for the
    source.  Mark CMake-generated .rule files explicitly with a property
    instead of trusting the file extension.

diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index a723109..ac70a9b 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -214,13 +214,11 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget()
   // (this could be avoided with per-target source files)
   const char* no_main_dependency = 0;
   const char* no_working_directory = 0;
-  mf->AddCustomCommandToOutput(
-    stamps, listFiles,
-    no_main_dependency, commandLines, "Checking Build System",
-    no_working_directory, true);
-  std::string ruleName = stamps[0];
-  ruleName += ".rule";
-  if(cmSourceFile* file = mf->GetSource(ruleName.c_str()))
+  if(cmSourceFile* file =
+     mf->AddCustomCommandToOutput(
+       stamps, listFiles,
+       no_main_dependency, commandLines, "Checking Build System",
+       no_working_directory, true))
     {
     tgt->AddSourceFile(file);
     }
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 99a4c95..5ab223b 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -320,7 +320,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
     sourceGroup.AssignSource(*i);
     // while we are at it, if it is a .rule file then for visual studio 6 we
     // must generate it
-    if ((*i)->GetExtension() == "rule")
+    if ((*i)->GetPropertyAsBool("__CMAKE_RULE"))
       {
       if(!cmSystemTools::FileExists(source.c_str()))
         {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e7e5eda..f2865f6 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -883,7 +883,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
 }
 
 //----------------------------------------------------------------------------
-void
+cmSourceFile*
 cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
                                      const std::vector<std::string>& depends,
                                      const char* main_dependency,
@@ -897,7 +897,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
   if(outputs.empty())
     {
     cmSystemTools::Error("Attempt to add a custom rule with no output!");
-    return;
+    return 0;
     }
 
   // Validate custom commands.  TODO: More strict?
@@ -910,7 +910,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
       cmOStringStream e;
       e << "COMMAND may not contain literal quotes:\n  " << cl[0] << "\n";
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
-      return;
+      return 0;
       }
     }
 
@@ -928,7 +928,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
         {
         // The existing custom command is identical.  Silently ignore
         // the duplicate.
-        return;
+        return file;
         }
       else
         {
@@ -970,11 +970,12 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
                              outName.c_str(),
                              "\" which already has a custom rule.");
         }
-      return;
+      return file;
       }
 
     // Create a cmSourceFile for the rule file.
     file = this->GetOrCreateSource(outName.c_str(), true);
+    file->SetProperty("__CMAKE_RULE", "1");
     }
 
   // Always create the output sources and mark them generated.
@@ -1004,10 +1005,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
     cc->SetEscapeAllowMakeVars(true);
     file->SetCustomCommand(cc);
     }
+  return file;
 }
 
 //----------------------------------------------------------------------------
-void
+cmSourceFile*
 cmMakefile::AddCustomCommandToOutput(const char* output,
                                      const std::vector<std::string>& depends,
                                      const char* main_dependency,
@@ -1019,9 +1021,9 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
 {
   std::vector<std::string> outputs;
   outputs.push_back(output);
-  this->AddCustomCommandToOutput(outputs, depends, main_dependency,
-                                 commandLines, comment, workingDir,
-                                 replace, escapeOldStyle);
+  return this->AddCustomCommandToOutput(outputs, depends, main_dependency,
+                                        commandLines, comment, workingDir,
+                                        replace, escapeOldStyle);
 }
 
 //----------------------------------------------------------------------------
@@ -1054,13 +1056,14 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
     {
     // Get the name of this output.
     const char* output = oi->c_str();
+    cmSourceFile* sf;
 
     // Choose whether to use a main dependency.
     if(sourceFiles.find(source))
       {
       // The source looks like a real file.  Use it as the main dependency.
-      this->AddCustomCommandToOutput(output, depends, source,
-                                     commandLines, comment, 0);
+      sf = this->AddCustomCommandToOutput(output, depends, source,
+                                          commandLines, comment, 0);
       }
     else
       {
@@ -1068,20 +1071,18 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
       const char* no_main_dependency = 0;
       std::vector<std::string> depends2 = depends;
       depends2.push_back(source);
-      this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
-                                     commandLines, comment, 0);
+      sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
+                                          commandLines, comment, 0);
       }
 
     // If the rule was added to the source (and not a .rule file),
     // then add the source to the target to make sure the rule is
     // included.
-    std::string sname = output;
-    sname += ".rule";
-    if(!this->GetSource(sname.c_str()))
+    if(sf && !sf->GetPropertyAsBool("__CMAKE_RULE"))
       {
       if (this->Targets.find(target) != this->Targets.end())
         {
-        this->Targets[target].AddSource(source);
+        this->Targets[target].AddSourceFile(sf);
         }
       else
         {
@@ -1976,7 +1977,6 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname)
 
   // look through all the source files that have custom commands
   // and see if the custom command has the passed source file as an output
-  // keep in mind the possible .rule extension that may be tacked on
   for(std::vector<cmSourceFile*>::const_iterator i =
         this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
     {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 960ba39..8b3bef7 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -175,20 +175,22 @@ public:
                                 cmTarget::CustomCommandType type,
                                 const char* comment, const char* workingDir,
                                 bool escapeOldStyle = true);
-  void AddCustomCommandToOutput(const std::vector<std::string>& outputs,
-                                const std::vector<std::string>& depends,
-                                const char* main_dependency,
-                                const cmCustomCommandLines& commandLines,
-                                const char* comment, const char* workingDir,
-                                bool replace = false,
-                                bool escapeOldStyle = true);
-  void AddCustomCommandToOutput(const char* output,
-                                const std::vector<std::string>& depends,
-                                const char* main_dependency,
-                                const cmCustomCommandLines& commandLines,
-                                const char* comment, const char* workingDir,
-                                bool replace = false,
-                                bool escapeOldStyle = true);
+  cmSourceFile* AddCustomCommandToOutput(
+    const std::vector<std::string>& outputs,
+    const std::vector<std::string>& depends,
+    const char* main_dependency,
+    const cmCustomCommandLines& commandLines,
+    const char* comment, const char* workingDir,
+    bool replace = false,
+    bool escapeOldStyle = true);
+  cmSourceFile* AddCustomCommandToOutput(
+    const char* output,
+    const std::vector<std::string>& depends,
+    const char* main_dependency,
+    const cmCustomCommandLines& commandLines,
+    const char* comment, const char* workingDir,
+    bool replace = false,
+    bool escapeOldStyle = true);
   void AddCustomCommandOldStyle(const char* target,
                                 const std::vector<std::string>& outputs,
                                 const std::vector<std::string>& depends,
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 6caaad1..5921530 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -460,7 +460,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
 {
   std::string sourcePath = source->GetFullPath();
   // the rule file seems to need to exist for vs10
-  if (source->GetExtension() == "rule")
+  if (source->GetPropertyAsBool("__CMAKE_RULE"))
     {
     if(!cmSystemTools::FileExists(sourcePath.c_str()))
       {

-----------------------------------------------------------------------

Summary of changes:
 Source/cmGlobalGenerator.cxx               |   15 ++++++++
 Source/cmGlobalGenerator.h                 |    3 ++
 Source/cmGlobalVisualStudio10Generator.cxx |   18 ++++++++++
 Source/cmGlobalVisualStudio10Generator.h   |    4 ++
 Source/cmGlobalVisualStudio8Generator.cxx  |   12 +++----
 Source/cmLocalVisualStudio6Generator.cxx   |    2 +-
 Source/cmMakefile.cxx                      |   50 ++++++++++++---------------
 Source/cmMakefile.h                        |   30 +++++++++--------
 Source/cmVisualStudio10TargetGenerator.cxx |    5 ++-
 9 files changed, 87 insertions(+), 52 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list