[Cmake-commits] CMake branch, next, updated. v3.1.0-2281-ga75bb83

Ben Boeckel ben.boeckel at kitware.com
Wed Jan 21 13:20:19 EST 2015


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  a75bb8377e228107917135b06a1af42aec1ecd52 (commit)
       via  38ad671c4a5ef9e2346893b7dfa37a8a67c16c1e (commit)
       via  caeffcc6b43df91f09fe3502454119148362a543 (commit)
      from  6a5da86d1eb53526ad48724cae6ce23151f56e0e (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=a75bb8377e228107917135b06a1af42aec1ecd52
commit a75bb8377e228107917135b06a1af42aec1ecd52
Merge: 6a5da86 38ad671
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Jan 21 13:20:17 2015 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jan 21 13:20:17 2015 -0500

    Merge topic 'ninja-generate-outputs' into next
    
    38ad671c test: test that ninja regenerates properly
    caeffcc6 ninja: list outputs of CMake's generate step


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38ad671c4a5ef9e2346893b7dfa37a8a67c16c1e
commit 38ad671c4a5ef9e2346893b7dfa37a8a67c16c1e
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Jan 21 13:16:33 2015 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Jan 21 13:16:33 2015 -0500

    test: test that ninja regenerates properly
    
    Currently tests that the ninja files are regenerated when any of the
    following occurs:
    
      - an input for a configure_file is touched;
      - an input for a try_compile is touched; and
      - an output of a configure_file is removed.

diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 3a61751..358a918 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -175,3 +175,7 @@ add_RunCMake_test(CommandLine)
 add_RunCMake_test(install)
 add_RunCMake_test(CPackInstallProperties)
 add_RunCMake_test(ExternalProject)
+
+if(CMAKE_GENERATOR MATCHES "Ninja")
+  add_RunCMake_test(ninja)
+endif()
diff --git a/Tests/RunCMake/ninja/CMakeLists.txt b/Tests/RunCMake/ninja/CMakeLists.txt
new file mode 100644
index 0000000..67a38be
--- /dev/null
+++ b/Tests/RunCMake/ninja/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8.4)
+
+set(test_binary_dir "${test_binary_root}/init-build")
+
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ninja/RunCMakeTest.cmake b/Tests/RunCMake/ninja/RunCMakeTest.cmake
new file mode 100644
index 0000000..4bf4ed1
--- /dev/null
+++ b/Tests/RunCMake/ninja/RunCMakeTest.cmake
@@ -0,0 +1,21 @@
+include(RunCMake)
+
+# Test that Ninja is rerun properly.
+set(test_dir "${CMAKE_CURRENT_BINARY_DIR}/ninja/test")
+
+set(RunCMake_BINARY_DIR "${test_dir}")
+run_cmake(init)
+
+function (busy_loop)
+  execute_process(
+    COMMAND "${CMAKE_COMMAND}" -E sleep
+            2)
+endfunction ()
+
+set(RunCMake_TEST_OPTIONS "-Dtest_binary_root=${test_dir}")
+busy_loop()
+run_cmake(touch_try_compile)
+busy_loop()
+run_cmake(remove_configured_file)
+busy_loop()
+run_cmake(touch_configure)
diff --git a/Tests/RunCMake/ninja/check_build.cmake b/Tests/RunCMake/ninja/check_build.cmake
new file mode 100644
index 0000000..0969639
--- /dev/null
+++ b/Tests/RunCMake/ninja/check_build.cmake
@@ -0,0 +1,24 @@
+function (busy_loop)
+  execute_process(
+    COMMAND "${CMAKE_COMMAND}" -E sleep
+            2)
+endfunction ()
+
+file(TIMESTAMP "${test_binary_dir}/build.ninja" orig_time "%Y%m%d%H%M%S")
+
+busy_loop()
+# Force NINJA_STATUS to be a certain style to not break the regex.
+set(ENV{NINJA_STATUS} "[%s/%t] ")
+execute_process(
+  COMMAND           "${CMAKE_MAKE_PROGRAM}"
+  OUTPUT_VARIABLE   out
+  ERROR_VARIABLE    err
+  WORKING_DIRECTORY "${test_binary_dir}")
+message("-->${out}<--")
+message("-->${err}<--")
+
+file(TIMESTAMP "${test_binary_dir}/build.ninja" rerun_time "%Y%m%d%H%M%S")
+
+if (NOT rerun_time GREATER orig_time)
+  message(FATAL_ERROR "Ninja did not rerun? (old: ${orig_time}; new: ${rerun_time})")
+endif ()
diff --git a/Tests/RunCMake/ninja/init-stderr.txt b/Tests/RunCMake/ninja/init-stderr.txt
new file mode 100644
index 0000000..3510266
--- /dev/null
+++ b/Tests/RunCMake/ninja/init-stderr.txt
@@ -0,0 +1 @@
+^FALSE$
diff --git a/Tests/RunCMake/ninja/init.cmake b/Tests/RunCMake/ninja/init.cmake
new file mode 100644
index 0000000..48b1f23
--- /dev/null
+++ b/Tests/RunCMake/ninja/init.cmake
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.0)
+project(ninja C)
+
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/test.txt.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/test.txt")
+
+try_compile(res
+  "${CMAKE_CURRENT_BINARY_DIR}/bin"
+  SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tc.c")
+message("${res}")
diff --git a/Tests/RunCMake/ninja/remove_configured_file-stderr.txt b/Tests/RunCMake/ninja/remove_configured_file-stderr.txt
new file mode 100644
index 0000000..f12a099
--- /dev/null
+++ b/Tests/RunCMake/ninja/remove_configured_file-stderr.txt
@@ -0,0 +1,6 @@
+^-->\[1/1\] Re-running CMake\.\.\.
+.*
+ninja: no work to do.
+<--
+-->FALSE
+<--$
diff --git a/Tests/RunCMake/ninja/remove_configured_file.cmake b/Tests/RunCMake/ninja/remove_configured_file.cmake
new file mode 100644
index 0000000..6cd9d61
--- /dev/null
+++ b/Tests/RunCMake/ninja/remove_configured_file.cmake
@@ -0,0 +1,3 @@
+file(REMOVE "${test_binary_dir}/test.txt")
+
+include("${CMAKE_CURRENT_LIST_DIR}/check_build.cmake")
diff --git a/Tests/RunCMake/ninja/tc.c b/Tests/RunCMake/ninja/tc.c
new file mode 100644
index 0000000..ee6947a
--- /dev/null
+++ b/Tests/RunCMake/ninja/tc.c
@@ -0,0 +1,4 @@
+int main(int /*argc*/, char* /*argv*/[])
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/ninja/test.txt.in b/Tests/RunCMake/ninja/test.txt.in
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/ninja/touch_configure-stderr.txt b/Tests/RunCMake/ninja/touch_configure-stderr.txt
new file mode 100644
index 0000000..f12a099
--- /dev/null
+++ b/Tests/RunCMake/ninja/touch_configure-stderr.txt
@@ -0,0 +1,6 @@
+^-->\[1/1\] Re-running CMake\.\.\.
+.*
+ninja: no work to do.
+<--
+-->FALSE
+<--$
diff --git a/Tests/RunCMake/ninja/touch_configure.cmake b/Tests/RunCMake/ninja/touch_configure.cmake
new file mode 100644
index 0000000..4915081
--- /dev/null
+++ b/Tests/RunCMake/ninja/touch_configure.cmake
@@ -0,0 +1,5 @@
+execute_process(
+  COMMAND "${CMAKE_COMMAND}" -E touch
+          "${CMAKE_CURRENT_LIST_DIR}/test.txt.in")
+
+include("${CMAKE_CURRENT_LIST_DIR}/check_build.cmake")
diff --git a/Tests/RunCMake/ninja/touch_try_compile-stderr.txt b/Tests/RunCMake/ninja/touch_try_compile-stderr.txt
new file mode 100644
index 0000000..f12a099
--- /dev/null
+++ b/Tests/RunCMake/ninja/touch_try_compile-stderr.txt
@@ -0,0 +1,6 @@
+^-->\[1/1\] Re-running CMake\.\.\.
+.*
+ninja: no work to do.
+<--
+-->FALSE
+<--$
diff --git a/Tests/RunCMake/ninja/touch_try_compile.cmake b/Tests/RunCMake/ninja/touch_try_compile.cmake
new file mode 100644
index 0000000..738cfcb
--- /dev/null
+++ b/Tests/RunCMake/ninja/touch_try_compile.cmake
@@ -0,0 +1,5 @@
+execute_process(
+  COMMAND "${CMAKE_COMMAND}" -E touch
+          "${CMAKE_CURRENT_LIST_DIR}/tc.c")
+
+include("${CMAKE_CURRENT_LIST_DIR}/check_build.cmake")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=caeffcc6b43df91f09fe3502454119148362a543
commit caeffcc6b43df91f09fe3502454119148362a543
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Jan 21 12:35:22 2015 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Jan 21 12:35:22 2015 -0500

    ninja: list outputs of CMake's generate step
    
    List outputs of the generate step as outputs of the RERUN_CMAKE target.
    Any outputs which are also inputs are not considered outputs because if
    they are missing, Ninja will need to rerun CMake anyways since an input
    file changed.
    
    The "restat = 1" flag is also required in case outputs are not updated.
    
    Fixes #15256.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 3c07be1..3b599be 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1119,11 +1119,12 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
             /*deptype=*/ "",
             /*rspfile=*/ "",
             /*rspcontent*/ "",
-            /*restat=*/ "",
+            /*restat=*/ "1",
             /*generator=*/ true);
 
   cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg);
 
+  cmNinjaDeps outputs;
   cmNinjaDeps implicitDeps;
   for(std::vector<cmLocalGenerator*>::const_iterator i =
         this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i)
@@ -1134,13 +1135,30 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
       {
       implicitDeps.push_back(ng->ConvertToNinjaPath(*fi));
       }
+    std::vector<std::string> const& localOutputs =
+      (*i)->GetMakefile()->GetOutputFiles();
+    for(std::vector<std::string>::const_iterator o = localOutputs.begin();
+        o != localOutputs.end(); ++o)
+      {
+      outputs.push_back(ng->ConvertToNinjaPath(*o));
+      }
     }
+  outputs.push_back(NINJA_BUILD_FILE);
   implicitDeps.push_back("CMakeCache.txt");
 
   std::sort(implicitDeps.begin(), implicitDeps.end());
   implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
                      implicitDeps.end());
 
+  std::sort(outputs.begin(), outputs.end());
+  outputs.erase(std::unique(outputs.begin(), outputs.end()),
+                outputs.end());
+
+  cmNinjaDeps filteredOutputs;
+  std::set_difference(outputs.begin(), outputs.end(),
+                      implicitDeps.begin(), implicitDeps.end(),
+                      std::back_inserter(filteredOutputs));
+
   cmNinjaVars variables;
   // Use 'console' pool to get non buffered output of the CMake re-run call
   // Available since Ninja 1.5
@@ -1152,7 +1170,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
   this->WriteBuild(os,
                    "Re-run CMake if any of its inputs changed.",
                    "RERUN_CMAKE",
-                   /*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE),
+                   /*outputs=*/ filteredOutputs,
                    /*explicitDeps=*/ cmNinjaDeps(),
                    implicitDeps,
                    /*orderOnlyDeps=*/ cmNinjaDeps(),

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

Summary of changes:
 Source/cmGlobalNinjaGenerator.cxx                  |   22 ++++++++++++++++--
 Tests/RunCMake/CMakeLists.txt                      |    4 ++++
 Tests/RunCMake/{CMP0026 => ninja}/CMakeLists.txt   |    3 +++
 Tests/RunCMake/ninja/RunCMakeTest.cmake            |   21 +++++++++++++++++
 Tests/RunCMake/ninja/check_build.cmake             |   24 ++++++++++++++++++++
 Tests/RunCMake/ninja/init-stderr.txt               |    1 +
 Tests/RunCMake/ninja/init.cmake                    |   11 +++++++++
 .../ninja/remove_configured_file-stderr.txt        |    6 +++++
 Tests/RunCMake/ninja/remove_configured_file.cmake  |    3 +++
 Tests/RunCMake/ninja/tc.c                          |    4 ++++
 .../hello.f => Tests/RunCMake/ninja/test.txt.in    |    0
 Tests/RunCMake/ninja/touch_configure-stderr.txt    |    6 +++++
 Tests/RunCMake/ninja/touch_configure.cmake         |    5 ++++
 Tests/RunCMake/ninja/touch_try_compile-stderr.txt  |    6 +++++
 Tests/RunCMake/ninja/touch_try_compile.cmake       |    5 ++++
 15 files changed, 119 insertions(+), 2 deletions(-)
 copy Tests/RunCMake/{CMP0026 => ninja}/CMakeLists.txt (64%)
 create mode 100644 Tests/RunCMake/ninja/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/ninja/check_build.cmake
 create mode 100644 Tests/RunCMake/ninja/init-stderr.txt
 create mode 100644 Tests/RunCMake/ninja/init.cmake
 create mode 100644 Tests/RunCMake/ninja/remove_configured_file-stderr.txt
 create mode 100644 Tests/RunCMake/ninja/remove_configured_file.cmake
 create mode 100644 Tests/RunCMake/ninja/tc.c
 copy Modules/IntelVSImplicitPath/hello.f => Tests/RunCMake/ninja/test.txt.in (100%)
 create mode 100644 Tests/RunCMake/ninja/touch_configure-stderr.txt
 create mode 100644 Tests/RunCMake/ninja/touch_configure.cmake
 create mode 100644 Tests/RunCMake/ninja/touch_try_compile-stderr.txt
 create mode 100644 Tests/RunCMake/ninja/touch_try_compile.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list