mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Use SOURCE_DATE_EPOCH for timestamp if present
The Debian reproducible builds effort suggests using this environment variable for timestamps.
This commit is contained in:
parent
ead869992c
commit
f06f5d0702
@ -14,8 +14,6 @@ set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION})
|
|||||||
set (CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo"
|
set (CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo"
|
||||||
CACHE STRING "" FORCE)
|
CACHE STRING "" FORCE)
|
||||||
|
|
||||||
string (TIMESTAMP BUILD_DATE "%Y-%m-%d")
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
@ -98,6 +96,18 @@ else()
|
|||||||
message(FATAL_ERROR "No python interpreter found")
|
message(FATAL_ERROR "No python interpreter found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# allow for reproducible builds - python for portability
|
||||||
|
if (DEFINED ENV{SOURCE_DATE_EPOCH})
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${PYTHON}" "${CMAKE_MODULE_PATH}/formatdate.py" "$ENV{SOURCE_DATE_EPOCH}"
|
||||||
|
OUTPUT_VARIABLE BUILD_DATE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
else ()
|
||||||
|
string (TIMESTAMP BUILD_DATE "%Y-%m-%d")
|
||||||
|
endif ()
|
||||||
|
message(STATUS "Build date: ${BUILD_DATE}")
|
||||||
|
|
||||||
|
|
||||||
if(${RAGEL} STREQUAL "RAGEL-NOTFOUND")
|
if(${RAGEL} STREQUAL "RAGEL-NOTFOUND")
|
||||||
message(FATAL_ERROR "Ragel state machine compiler not found")
|
message(FATAL_ERROR "Ragel state machine compiler not found")
|
||||||
endif()
|
endif()
|
||||||
|
18
cmake/formatdate.py
Executable file
18
cmake/formatdate.py
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
print("Usage:", os.path.basename(sys.argv[0]), "<seconds from epoch>")
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
usage()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
ts = sys.argv[1]
|
||||||
|
|
||||||
|
build_date = datetime.datetime.utcfromtimestamp(int(ts))
|
||||||
|
|
||||||
|
print(build_date.strftime("%Y-%m-%d"))
|
Loading…
x
Reference in New Issue
Block a user