[Cmake-commits] CMake branch, next, updated. v3.7.2-2340-gffd0a35
Brad King
brad.king at kitware.com
Wed Jan 25 13:40:48 EST 2017
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 ffd0a359ca89ce397cd2603166b3370cbcfb25ff (commit)
via fc0d4d17232df6f2f2e7a130f25398db37ac4dcb (commit)
from 203112a512053157b7931ba0d92573e1a1bf86ba (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffd0a359ca89ce397cd2603166b3370cbcfb25ff
commit ffd0a359ca89ce397cd2603166b3370cbcfb25ff
Merge: 203112a fc0d4d1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Wed Jan 25 13:40:46 2017 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jan 25 13:40:46 2017 -0500
Merge topic 'topic-reproducible-build' into next
fc0d4d17 cmTimestamp: Support SOURCE_DATE_EPOCH to override current time
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fc0d4d17232df6f2f2e7a130f25398db37ac4dcb
commit fc0d4d17232df6f2f2e7a130f25398db37ac4dcb
Author: Bernhard M. Wiedemann <bwiedemann at suse.de>
AuthorDate: Wed Jan 25 07:15:40 2017 +0100
Commit: Brad King <brad.king at kitware.com>
CommitDate: Wed Jan 25 13:39:02 2017 -0500
cmTimestamp: Support SOURCE_DATE_EPOCH to override current time
See https://reproducible-builds.org/ for why this is good and
https://reproducible-builds.org/specs/source-date-epoch/ for the
definition of this variable.
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 77538f6..2c7847a 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -329,6 +329,12 @@ If no explicit ``<format string>`` is given it will default to:
Write a string which can be used as an identifier in C.
+.. note::
+
+ If the ``SOURCE_DATE_EPOCH`` environment variable is set,
+ its value will be used instead of the current time.
+ See https://reproducible-builds.org/specs/source-date-epoch/ for details.
+
UUID
""""
diff --git a/Help/release/dev/SOURCE_DATE_EPOCH.rst b/Help/release/dev/SOURCE_DATE_EPOCH.rst
new file mode 100644
index 0000000..576e1da
--- /dev/null
+++ b/Help/release/dev/SOURCE_DATE_EPOCH.rst
@@ -0,0 +1,5 @@
+SOURCE_DATE_EPOCH
+-----------------
+
+* The :command:`string(TIMESTAMP)` will now honor the ``SOURCE_DATE_EPOCH``
+ environment variable and use its value instead of the current time.
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 4a97114..b61b15d 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -12,6 +12,16 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString,
bool utcFlag)
{
time_t currentTimeT = time(CM_NULLPTR);
+ std::string source_date_epoch;
+ cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch);
+ if (!source_date_epoch.empty()) {
+ std::istringstream iss(source_date_epoch);
+ iss >> currentTimeT;
+ if (iss.fail() || !iss.eof()) {
+ cmSystemTools::Error("Error parsing SOURCE_DATE_EPOCH as int");
+ exit(27);
+ }
+ }
if (currentTimeT == time_t(-1)) {
return std::string();
}
diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake
index 8067d9d..38a77b0 100644
--- a/Tests/RunCMake/string/RunCMakeTest.cmake
+++ b/Tests/RunCMake/string/RunCMakeTest.cmake
@@ -6,6 +6,11 @@ run_cmake(AppendNoArgs)
run_cmake(Concat)
run_cmake(ConcatNoArgs)
+run_cmake(Timestamp)
+run_cmake(TimestampEmpty)
+run_cmake(TimestampInvalid)
+run_cmake(TimestampInvalid2)
+
run_cmake(Uuid)
run_cmake(UuidMissingNamespace)
run_cmake(UuidMissingNamespaceValue)
diff --git a/Tests/RunCMake/string/Timestamp-result.txt b/Tests/RunCMake/string/Timestamp-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/string/Timestamp-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt
new file mode 100644
index 0000000..10952b2
--- /dev/null
+++ b/Tests/RunCMake/string/Timestamp-stderr.txt
@@ -0,0 +1 @@
+RESULT=2005-08-07 23:19:49
diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake
new file mode 100644
index 0000000..b698627
--- /dev/null
+++ b/Tests/RunCMake/string/Timestamp.cmake
@@ -0,0 +1,3 @@
+set(ENV{SOURCE_DATE_EPOCH} "1123456789")
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC)
+message("RESULT=${RESULT}")
diff --git a/Tests/RunCMake/string/TimestampEmpty-result.txt b/Tests/RunCMake/string/TimestampEmpty-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampEmpty-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/string/TimestampEmpty-stderr.txt b/Tests/RunCMake/string/TimestampEmpty-stderr.txt
new file mode 100644
index 0000000..35cbd3c
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampEmpty-stderr.txt
@@ -0,0 +1 @@
+RESULT=2
diff --git a/Tests/RunCMake/string/TimestampEmpty.cmake b/Tests/RunCMake/string/TimestampEmpty.cmake
new file mode 100644
index 0000000..21b770f
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampEmpty.cmake
@@ -0,0 +1,3 @@
+set(ENV{SOURCE_DATE_EPOCH} "")
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC)
+message("RESULT=${RESULT}")
diff --git a/Tests/RunCMake/string/TimestampInvalid-result.txt b/Tests/RunCMake/string/TimestampInvalid-result.txt
new file mode 100644
index 0000000..f64f5d8
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid-result.txt
@@ -0,0 +1 @@
+27
diff --git a/Tests/RunCMake/string/TimestampInvalid-stderr.txt b/Tests/RunCMake/string/TimestampInvalid-stderr.txt
new file mode 100644
index 0000000..f7195c2
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Error parsing SOURCE_DATE_EPOCH as int
diff --git a/Tests/RunCMake/string/TimestampInvalid.cmake b/Tests/RunCMake/string/TimestampInvalid.cmake
new file mode 100644
index 0000000..ab36270
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid.cmake
@@ -0,0 +1,3 @@
+set(ENV{SOURCE_DATE_EPOCH} "invalid-integer")
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC)
+message("RESULT=${RESULT}")
diff --git a/Tests/RunCMake/string/TimestampInvalid2-result.txt b/Tests/RunCMake/string/TimestampInvalid2-result.txt
new file mode 100644
index 0000000..f64f5d8
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid2-result.txt
@@ -0,0 +1 @@
+27
diff --git a/Tests/RunCMake/string/TimestampInvalid2-stderr.txt b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt
new file mode 100644
index 0000000..f7195c2
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Error parsing SOURCE_DATE_EPOCH as int
diff --git a/Tests/RunCMake/string/TimestampInvalid2.cmake b/Tests/RunCMake/string/TimestampInvalid2.cmake
new file mode 100644
index 0000000..5cc61b8
--- /dev/null
+++ b/Tests/RunCMake/string/TimestampInvalid2.cmake
@@ -0,0 +1,3 @@
+set(ENV{SOURCE_DATE_EPOCH} "123trailing-garbage")
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC)
+message("RESULT=${RESULT}")
-----------------------------------------------------------------------
Summary of changes:
Help/command/string.rst | 6 ++++++
Help/release/dev/SOURCE_DATE_EPOCH.rst | 5 +++++
Source/cmTimestamp.cxx | 10 ++++++++++
Tests/RunCMake/string/RunCMakeTest.cmake | 5 +++++
.../Timestamp-result.txt} | 0
Tests/RunCMake/string/Timestamp-stderr.txt | 1 +
Tests/RunCMake/string/Timestamp.cmake | 3 +++
.../TimestampEmpty-result.txt} | 0
Tests/RunCMake/string/TimestampEmpty-stderr.txt | 1 +
Tests/RunCMake/string/TimestampEmpty.cmake | 3 +++
Tests/RunCMake/string/TimestampInvalid-result.txt | 1 +
Tests/RunCMake/string/TimestampInvalid-stderr.txt | 1 +
Tests/RunCMake/string/TimestampInvalid.cmake | 3 +++
Tests/RunCMake/string/TimestampInvalid2-result.txt | 1 +
Tests/RunCMake/string/TimestampInvalid2-stderr.txt | 1 +
Tests/RunCMake/string/TimestampInvalid2.cmake | 3 +++
16 files changed, 44 insertions(+)
create mode 100644 Help/release/dev/SOURCE_DATE_EPOCH.rst
copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => string/Timestamp-result.txt} (100%)
create mode 100644 Tests/RunCMake/string/Timestamp-stderr.txt
create mode 100644 Tests/RunCMake/string/Timestamp.cmake
copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => string/TimestampEmpty-result.txt} (100%)
create mode 100644 Tests/RunCMake/string/TimestampEmpty-stderr.txt
create mode 100644 Tests/RunCMake/string/TimestampEmpty.cmake
create mode 100644 Tests/RunCMake/string/TimestampInvalid-result.txt
create mode 100644 Tests/RunCMake/string/TimestampInvalid-stderr.txt
create mode 100644 Tests/RunCMake/string/TimestampInvalid.cmake
create mode 100644 Tests/RunCMake/string/TimestampInvalid2-result.txt
create mode 100644 Tests/RunCMake/string/TimestampInvalid2-stderr.txt
create mode 100644 Tests/RunCMake/string/TimestampInvalid2.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list