[Cmake-commits] CMake branch, next, updated. v2.8.12.1-7209-g9e4f373

Brad King brad.king at kitware.com
Tue Jan 21 13:56:22 EST 2014


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  9e4f373273a0deced509f8e1d7e8a6f7d7e66873 (commit)
       via  94389f6388367aa4d9bfa58c9cde89e33d1858dc (commit)
      from  47113a7d61ff34f9cda677f23fad233bcee15eec (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=9e4f373273a0deced509f8e1d7e8a6f7d7e66873
commit 9e4f373273a0deced509f8e1d7e8a6f7d7e66873
Merge: 47113a7 94389f6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 21 13:56:20 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jan 21 13:56:20 2014 -0500

    Merge topic 'cmake-E-sleep' into next
    
    94389f63 cmake: Add '-E sleep' command


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94389f6388367aa4d9bfa58c9cde89e33d1858dc
commit 94389f6388367aa4d9bfa58c9cde89e33d1858dc
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 21 13:48:30 2014 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 21 13:50:49 2014 -0500

    cmake: Add '-E sleep' command
    
    Add a cmake command-line interface to provide a cross-platform 'sleep'.

diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index d209b8b..5743ab7 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -39,7 +39,7 @@ Options
  that can be used on all systems.  Run with -E help for the usage
  information.  Commands available are: chdir, compare_files, copy,
  copy_directory, copy_if_different, echo, echo_append, environment,
- make_directory, md5sum, remove, remove_directory, rename, tar, time,
+ make_directory, md5sum, remove, remove_directory, rename, sleep, tar, time,
  touch, touch_nocreate.  In addition, some platform specific commands
  are available.  On Windows: delete_regv, write_regv.  On
  UNIX: create_symlink.
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index c1576c4..4ac1986 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -71,6 +71,7 @@ void CMakeCommandUsage(const char* program)
        "(on one volume)\n"
     << "  tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n"
     << "                            - create or extract a tar or zip archive\n"
+    << "  sleep <number>...         - sleep for given number of seconds\n"
     << "  time command [args] ...   - run command and return elapsed time\n"
     << "  touch file                - touch a file.\n"
     << "  touch_nocreate file       - touch a file but do not create it.\n"
@@ -279,6 +280,33 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       return 0;
       }
 
+    // Sleep command
+    else if (args[1] == "sleep" && args.size() > 2)
+      {
+      double total = 0;
+      for(size_t i = 2; i < args.size(); ++i)
+        {
+        double num = 0.0;
+        char unit;
+        char extra;
+        int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra);
+        if((n == 1 || (n == 2 && unit == 's')) && num >= 0)
+          {
+          total += num;
+          }
+        else
+          {
+          std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n";
+          return 1;
+          }
+        }
+      if(total > 0)
+        {
+        cmSystemTools::Delay(static_cast<unsigned int>(total*1000));
+        }
+      return 0;
+      }
+
     // Clock command
     else if (args[1] == "time" && args.size() > 2)
       {
diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt
new file mode 100644
index 0000000..45e6ebc
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt
@@ -0,0 +1 @@
+^Unknown sleep time format "x"\.$
diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt
new file mode 100644
index 0000000..399d47f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt
@@ -0,0 +1 @@
+^Unknown sleep time format "-1"\.$
diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake
new file mode 100644
index 0000000..977f1ef
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake
@@ -0,0 +1,2 @@
+Usage: .*/cmake -E \[command\] \[arguments \.\.\.\]
+Available commands:
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index ee6cd99..ada4cab 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -23,3 +23,8 @@ if(UNIX)
     ${CMAKE_COMMAND} -E create_symlink T .
     )
 endif()
+
+run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep)
+run_cmake_command(E_sleep-bad-arg1 ${CMAKE_COMMAND} -E sleep x)
+run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1)
+run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1)

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

Summary of changes:
 Help/manual/cmake.1.rst                            |    2 +-
 Source/cmcmd.cxx                                   |   28 ++++++++++++++++++++
 .../E_sleep-bad-arg1-result.txt}                   |    0
 .../CommandLine/E_sleep-bad-arg1-stderr.txt        |    1 +
 .../E_sleep-bad-arg2-result.txt}                   |    0
 .../CommandLine/E_sleep-bad-arg2-stderr.txt        |    1 +
 .../E_sleep-no-args-result.txt}                    |    0
 .../CommandLine/E_sleep-no-args-stderr.cmake       |    2 ++
 Tests/RunCMake/CommandLine/RunCMakeTest.cmake      |    5 ++++
 9 files changed, 38 insertions(+), 1 deletion(-)
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_sleep-bad-arg1-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_sleep-bad-arg2-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_sleep-no-args-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list