mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Enhance version string
Use sha and git diff-index status for full version string. closes https://github.com/official-stockfish/Stockfish/pull/6965 No functional change
This commit is contained in:
@@ -6,6 +6,7 @@ src/temp_builds
|
||||
src/universal/network_dump.inc
|
||||
.build_sha.txt
|
||||
.build_date.txt
|
||||
.build_diffindex.txt
|
||||
|
||||
# Built binary
|
||||
src/stockfish*
|
||||
|
||||
+12
-9
@@ -911,13 +911,15 @@ ifeq ($(syzygy),no)
|
||||
endif
|
||||
|
||||
### 3.8.1 Try to include git info for versioning and avoid recompiles if nothing changes
|
||||
BUILD_SHA_FILE := .build_sha.txt
|
||||
BUILD_DATE_FILE := .build_date.txt
|
||||
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8 || true)
|
||||
GIT_DATE := $(shell git show -s --date=format:%Y%m%d --format=%cd HEAD 2>/dev/null || true)
|
||||
COMPILER_DATE := $(shell date +%Y%m%d 2>/dev/null)
|
||||
BUILD_SHA_FILE := .build_sha.txt
|
||||
BUILD_DATE_FILE := .build_date.txt
|
||||
BUILD_DIFFINDEX_FILE := .build_diffindex.txt
|
||||
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8 || true)
|
||||
GIT_DATE := $(shell git show -s --date=format:%Y%m%d --format=%cd HEAD 2>/dev/null || true)
|
||||
GIT_DIFFINDEX := $(shell git diff-index --quiet HEAD -- 2>/dev/null; [ $$? -eq 1 ] && echo 1 || true)
|
||||
COMPILER_DATE := $(shell date +%Y%m%d 2>/dev/null)
|
||||
|
||||
BUILD_DATE := $(if $(GIT_DATE),$(GIT_DATE),$(COMPILER_DATE))
|
||||
BUILD_DATE := $(if $(GIT_DATE),$(GIT_DATE),$(COMPILER_DATE))
|
||||
|
||||
define cache_file_contents
|
||||
$(shell \
|
||||
@@ -929,6 +931,7 @@ endef
|
||||
ifneq ($(filter $(MAKECMDGOALS),help strip install clean net objclean profileclean format config-sanity),$(MAKECMDGOALS))
|
||||
_ := $(call cache_file_contents,$(BUILD_SHA_FILE),$(GIT_SHA))
|
||||
_ := $(call cache_file_contents,$(BUILD_DATE_FILE),$(BUILD_DATE))
|
||||
_ := $(call cache_file_contents,$(BUILD_DIFFINDEX_FILE),$(BUILD_DIFFINDEX))
|
||||
endif
|
||||
|
||||
### 3.8.2 Try to include architecture
|
||||
@@ -1207,7 +1210,7 @@ clean: objclean profileclean universalclean
|
||||
|
||||
# clean binaries and objects
|
||||
objclean:
|
||||
@rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o $(BUILD_SHA_FILE) $(BUILD_DATE_FILE)
|
||||
@rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o $(BUILD_SHA_FILE) $(BUILD_DATE_FILE) $(BUILD_DIFFINDEX_FILE)
|
||||
|
||||
# clean auxiliary profiling files
|
||||
profileclean:
|
||||
@@ -1313,8 +1316,8 @@ $(EXE): $(OBJS)
|
||||
%.o: %.cpp
|
||||
$(strip $(CXX) $(CPPFLAGS) $(CXXFLAGS)) -c -o $@ $<
|
||||
|
||||
misc.o: misc.cpp $(BUILD_SHA_FILE) $(BUILD_DATE_FILE)
|
||||
$(strip $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(if $(GIT_SHA),-DGIT_SHA=$(GIT_SHA)) $(if $(GIT_DATE),-DGIT_DATE=$(GIT_DATE))) -c -o $@ $<
|
||||
misc.o: misc.cpp $(BUILD_SHA_FILE) $(BUILD_DATE_FILE) $(BUILD_DIFFINDEX_FILE)
|
||||
$(strip $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(if $(GIT_SHA),-DGIT_SHA=$(GIT_SHA)) $(if $(GIT_DATE),-DGIT_DATE=$(GIT_DATE))) $(if $(GIT_DIFFINDEX),-DGIT_DIFFINDEX=$(GIT_DIFFINDEX)) -c -o $@ $<
|
||||
|
||||
clang-profile-make:
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
|
||||
|
||||
@@ -158,6 +158,10 @@ std::string engine_version_info() {
|
||||
<< std::setw(2) << std::setfill('0') << day;
|
||||
#endif
|
||||
|
||||
#ifdef GIT_DIFFINDEX
|
||||
ss << "-m";
|
||||
#endif
|
||||
|
||||
ss << "-";
|
||||
|
||||
#ifdef GIT_SHA
|
||||
|
||||
Reference in New Issue
Block a user