mdbx: allow to predefine/override MDBX_BUILD_TIMESTAMP for builds reproducibility.

Resolve https://github.com/erthink/libmdbx/issues/201
This commit is contained in:
Leonid Yuriev 2021-06-02 14:44:58 +03:00
parent 50328de63c
commit f951f246b8
4 changed files with 16 additions and 7 deletions

View File

@ -750,7 +750,9 @@ endif(MDBX_INSTALL_STATIC)
################################################################################ ################################################################################
# collect options & build info # collect options & build info
if(NOT DEFINED MDBX_BUILD_TIMESTAMP)
string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC) string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC)
endif()
set(MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS}) set(MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS})
if(MDBX_BUILD_CXX) if(MDBX_BUILD_CXX)
set(MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS}) set(MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS})

View File

@ -17,6 +17,10 @@ ChangeLog
- Finalize C++ API (few typos and trivia bugs are still likely for now). - Finalize C++ API (few typos and trivia bugs are still likely for now).
- Packages for [Astra Linux](https://astralinux.ru/), [ALT Linux](https://www.altlinux.org/), [ROSA Linux](https://www.rosalinux.ru/), etc. - Packages for [Astra Linux](https://astralinux.ru/), [ALT Linux](https://www.altlinux.org/), [ROSA Linux](https://www.rosalinux.ru/), etc.
New features:
- Allow to predefine/override `MDBX_BUILD_TIMESTAMP` for builds reproducibility (https://github.com/erthink/libmdbx/issues/201).
## v0.10.1 at 2021-06-01 ## v0.10.1 at 2021-06-01

View File

@ -30,6 +30,7 @@ CC ?= gcc
CFLAGS_EXTRA ?= CFLAGS_EXTRA ?=
LD ?= ld LD ?= ld
MDBX_BUILD_OPTIONS ?=-DNDEBUG=1 MDBX_BUILD_OPTIONS ?=-DNDEBUG=1
MDBX_BUILD_TIMESTAMP ?=$(shell date +%Y-%m-%dT%H:%M:%S%z)
CFLAGS ?= -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $(CFLAGS_EXTRA) CFLAGS ?= -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $(CFLAGS_EXTRA)
# -Wno-tautological-compare # -Wno-tautological-compare
CXX ?= g++ CXX ?= g++
@ -124,6 +125,7 @@ help:
show-options: show-options:
@echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)" @echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)"
@echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)"
@echo '## TIP: Use `make options` to listing available build options.' @echo '## TIP: Use `make options` to listing available build options.'
@echo " CFLAGS =$(CFLAGS)" @echo " CFLAGS =$(CFLAGS)"
@echo " CXXFLAGS =$(CXXFLAGS)" @echo " CXXFLAGS =$(CXXFLAGS)"
@ -150,6 +152,7 @@ options:
@echo " LIBS =$(LIBS)" @echo " LIBS =$(LIBS)"
@echo "" @echo ""
@echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)" @echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)"
@echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)"
@echo "" @echo ""
@echo "## Assortment items for MDBX_BUILD_OPTIONS:" @echo "## Assortment items for MDBX_BUILD_OPTIONS:"
@echo "## Note that the defaults should already be correct for most platforms;" @echo "## Note that the defaults should already be correct for most platforms;"
@ -198,7 +201,7 @@ MAN_SRCDIR := man1/
config.h: mdbx.c $(lastword $(MAKEFILE_LIST)) config.h: mdbx.c $(lastword $(MAKEFILE_LIST))
@echo ' MAKE $@' @echo ' MAKE $@'
$(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \ $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \
&& echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \ && echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \
&& echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \ && echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \ && echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
@ -388,7 +391,7 @@ src/version.c: src/version.c.in $(lastword $(MAKEFILE_LIST)) $(git_DIR)/HEAD $(g
src/config.h: src/version.c $(lastword $(MAKEFILE_LIST)) src/config.h: src/version.c $(lastword $(MAKEFILE_LIST))
@echo ' MAKE $@' @echo ' MAKE $@'
$(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \ $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \
&& echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \ && echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \
&& echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \ && echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \ && echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \

View File

@ -21978,7 +21978,7 @@ __dll_export
#ifdef MDBX_BUILD_TIMESTAMP #ifdef MDBX_BUILD_TIMESTAMP
MDBX_BUILD_TIMESTAMP MDBX_BUILD_TIMESTAMP
#else #else
__DATE__ " " __TIME__ "\"" __DATE__ " " __TIME__ "\""
#endif /* MDBX_BUILD_TIMESTAMP */ #endif /* MDBX_BUILD_TIMESTAMP */
, ,