[Cmake-commits] CMake branch, next, updated. v2.8.10.2-2726-g83ad6f3

Robert Maynard robert.maynard at kitware.com
Fri Apr 5 14:02:48 EDT 2013


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  83ad6f30e91042601c099ade62c8dad6d74d95d4 (commit)
       via  ba0732ac873ef8b52f93d4f0da63784ecd772d9a (commit)
       via  92e82b86913c8c068c16be3064b99868ae035d0f (commit)
      from  d69b4b641bac5afb9b2468d61ee3ba9639e814c5 (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=83ad6f30e91042601c099ade62c8dad6d74d95d4
commit 83ad6f30e91042601c099ade62c8dad6d74d95d4
Merge: d69b4b6 ba0732a
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Apr 5 14:02:45 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Apr 5 14:02:45 2013 -0400

    Merge topic 'ninja_phony_file_targets' into next
    
    ba0732a Ninja Custom Command file depends don't need to exist before building
    92e82b8 Add a test to expose a bug with add_custom_command and ninja.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba0732ac873ef8b52f93d4f0da63784ecd772d9a
commit ba0732ac873ef8b52f93d4f0da63784ecd772d9a
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Apr 3 16:06:22 2013 -0400
Commit:     Robert Maynard <robert.maynard at kitware.com>
CommitDate: Fri Apr 5 13:56:00 2013 -0400

    Ninja Custom Command file depends don't need to exist before building
    
    When converting custom commands for the ninja build system we
    need to make sure that any file dependencies that exist in the build
    tree are converted to phony targets. This tells ninja that these
    files might not exist when starting the build, but could be generated
    during the build.
    
    This is done by tracking all dependencies for custom command targets.
    After all have been written out we remove all items from the set
    that have been seen as a; target, custom command output, an alias,
    or a file in the source directory. Anything that is left is considered
    to be a file that will be generated as a side effect of another
    custom command.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index fa277b1..4bf279b 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -250,7 +250,6 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
   cmNinjaVars vars;
   vars["COMMAND"] = cmd;
   vars["DESC"] = EncodeLiteral(description);
-
   cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream,
                                      comment,
                                      "CUSTOM_COMMAND",
@@ -259,6 +258,14 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
                                      cmNinjaDeps(),
                                      orderOnlyDeps,
                                      vars);
+
+//we need to track every dependency that comes in, since we are trying
+//to find dependencies that are side effects of other custom commands
+//
+for(cmNinjaDeps::const_iterator i=deps.begin(); i != deps.end(); ++i)
+  {
+  this->UnkownCustomCommandFileDependencies.insert(*i);
+  }
 }
 
 void
@@ -478,6 +485,7 @@ void cmGlobalNinjaGenerator::Generate()
 
   this->WriteAssumedSourceDependencies();
   this->WriteTargetAliases(*this->BuildFileStream);
+  this->WriteUnkownCustomDependencies(*this->BuildFileStream);
   this->WriteBuiltinTargets(*this->BuildFileStream);
 
   if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -885,7 +893,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
   cmGlobalNinjaGenerator::WriteDivider(os);
   os << "# Target aliases.\n\n";
 
-  for (TargetAliasMap::iterator i = TargetAliases.begin();
+  for (TargetAliasMap::const_iterator i = TargetAliases.begin();
        i != TargetAliases.end(); ++i) {
     // Don't write ambiguous aliases.
     if (!i->second)
@@ -901,6 +909,50 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
   }
 }
 
+void cmGlobalNinjaGenerator::WriteUnkownCustomDependencies(std::ostream& os)
+{
+  //Know write out the unknown dependencies. Don't write out any
+  //of these that are now have been added as a known output, file
+  //dependency or alias
+  cmGlobalNinjaGenerator::WriteDivider(os);
+  os << "#Unkown Build Time  Dependencies.\n\n";
+
+  const std::string rootBuildDirectory =
+      this->GetCMakeInstance()->GetHomeOutputDirectory();
+
+  //remove the following possible targets that we know
+  //are false positives
+  UnkownCustomCommandFileDependencies.erase("all");
+
+  typedef std::set<std::string>::const_iterator uccfd_iterator;
+  for (uccfd_iterator i = UnkownCustomCommandFileDependencies.begin();
+       i != UnkownCustomCommandFileDependencies.end(); ++i)
+    {
+    bool isUnkown = ( this->CustomCommandOutputs.find(*i) ==
+                      this->CustomCommandOutputs.end() );
+    isUnkown = isUnkown && ( this->CustomCommandFileDependencies.find(*i) ==
+                         this->CustomCommandFileDependencies.end() );
+    isUnkown = isUnkown && this->TargetAliases.count(*i) == 0;
+
+    if(!isUnkown)
+    {
+      continue;
+    }
+
+    //verify the file is in the build directory
+    const std::string absDepPath = cmSystemTools::CollapseFullPath(
+                                     i->c_str(), rootBuildDirectory.c_str());
+    if(absDepPath.find(rootBuildDirectory) == 0)
+      {
+      cmNinjaDeps deps(1,*i);
+      cmGlobalNinjaGenerator::WritePhonyBuild(os,
+                                              "",
+                                              deps,
+                                              deps);
+      }
+   }
+}
+
 void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
 {
   // Write headers.
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index c3df7d9..2954151 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -320,6 +320,7 @@ private:
   void WriteAssumedSourceDependencies();
 
   void WriteTargetAliases(std::ostream& os);
+  void WriteUnkownCustomDependencies(std::ostream& os);
 
   void WriteBuiltinTargets(std::ostream& os);
   void WriteTargetAll(std::ostream& os);
@@ -357,6 +358,14 @@ private:
   /// The set of custom command outputs we have seen.
   std::set<std::string> CustomCommandOutputs;
 
+  /// the set of custom command files dependencies we have seen.
+  std::set<std::string> CustomCommandFileDependencies;
+
+  /// the set of custom command files dependencies that we haven't
+  /// been able to find ownership of. These are presumed to be
+  /// created as a side effect of some custom command
+  std::set<std::string> UnkownCustomCommandFileDependencies;
+
   /// The mapping from source file to assumed dependencies.
   std::map<std::string, std::set<std::string> > AssumedSourceDependencies;
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92e82b86913c8c068c16be3064b99868ae035d0f
commit 92e82b86913c8c068c16be3064b99868ae035d0f
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Wed Apr 3 17:03:43 2013 -0400
Commit:     Robert Maynard <robert.maynard at kitware.com>
CommitDate: Wed Apr 3 17:19:28 2013 -0400

    Add a test to expose a bug with add_custom_command and ninja.
    
    Ninja Generator is unable to handle an add_custom_command having
    a dependency that is generated at build time by a previous target.

diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index d3ced3f..30daa7d 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -123,6 +123,19 @@ add_custom_command(
   COMMENT "Running TDocument post-build commands"
   )
 
+# Setup a custom target that will fail if the POST_BUILD custom command
+# isn't run before it.
+add_custom_command(
+  OUTPUT doc3post.txt
+  DEPENDS ${PROJECT_BINARY_DIR}/doc2post.txt
+  COMMAND ${CMAKE_COMMAND} -E echo " Copying doc2pre.txt to doc3post.txt."
+  COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc2post.txt
+                                   ${PROJECT_BINARY_DIR}/doc3post.txt
+  COMMENT "Running TDocument post-build dependent custom command"
+  )
+add_custom_target(doc3Post ALL DEPENDS doc3post.txt)
+add_dependencies(doc3Post TDocument)
+
 ################################################################
 #
 #  Test using a multistep generated file

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

Summary of changes:
 Source/cmGlobalNinjaGenerator.cxx  |   56 ++++++++++++++++++++++++++++++++++-
 Source/cmGlobalNinjaGenerator.h    |    9 ++++++
 Tests/CustomCommand/CMakeLists.txt |   13 ++++++++
 3 files changed, 76 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list