mdbx-build: поддержка переменной среды SOURCE_DATE_EPOCH в качестве MDBX_BUILD_TIMESTAMP для воспроизводимости сборок.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-11-19 23:37:37 +03:00
parent 881d4d4207
commit 1c9c49dd1a
2 changed files with 8 additions and 4 deletions

View File

@ -1216,7 +1216,11 @@ endif(MDBX_INSTALL_STATIC)
# collect options & build info
if(NOT DEFINED MDBX_BUILD_TIMESTAMP)
string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC)
if(NOT "$ENV{SOURCE_DATE_EPOCH}" STREQUAL "")
set(FPTA_BUILD_TIMESTAMP "$ENV{SOURCE_DATE_EPOCH}")
else()
string(TIMESTAMP FPTA_BUILD_TIMESTAMP UTC)
endif()
endif()
set(MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS})
if(MDBX_BUILD_CXX)

View File

@ -56,9 +56,9 @@ CMAKE_OPT ?=
# build options
MDBX_BUILD_OPTIONS ?=-DNDEBUG=1
MDBX_BUILD_TIMESTAMP ?=$(shell date +%Y-%m-%dT%H:%M:%S%z)
MDBX_BUILD_CXX ?= YES
MDBX_BUILD_METADATA ?= ""
MDBX_BUILD_TIMESTAMP ?=$(if $(SOURCE_DATE_EPOCH),$(SOURCE_DATE_EPOCH),$(shell date +%Y-%m-%dT%H:%M:%S%z))
MDBX_BUILD_CXX ?=YES
MDBX_BUILD_METADATA ?=
# probe and compose common compiler flags with variable expansion trick (seems this work two times per session for GNU Make 3.81)
CFLAGS ?= $(strip $(eval CFLAGS := -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $$(shell for opt in -fno-semantic-interposition -Wno-unused-command-line-argument -Wno-tautological-compare; do [ -z "$$$$($(CC) '-DMDBX_BUILD_FLAGS="probe"' $$$${opt} -c $(SRC_PROBE_C) -o /dev/null >/dev/null 2>&1 || echo failed)" ] && echo "$$$${opt} "; done)$(CFLAGS_EXTRA))$(CFLAGS))