]> git.sesse.net Git - stockfish/blobdiff - src/Makefile
Change versioning and save binaries as CI artifacts
[stockfish] / src / Makefile
index e481aca5141a54377b1b43185faee8b672d42ffb..917bd5c06c7a83f9d4c48f9a531df196b0cb2d9d 100644 (file)
@@ -682,6 +682,18 @@ ifeq ($(pext),yes)
        endif
 endif
 
+### 3.7.1 Try to include git commit sha for versioning
+GIT_SHA = $(shell git rev-parse --short HEAD 2>/dev/null)
+ifneq ($(GIT_SHA), )
+       CXXFLAGS += -DGIT_SHA=\"$(GIT_SHA)\"
+endif
+
+### 3.7.2 Try to include git commit date for versioning
+GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null)
+ifneq ($(GIT_DATE), )
+       CXXFLAGS += -DGIT_DATE=\"$(GIT_DATE)\"
+endif
+
 ### 3.8 Link Time Optimization
 ### This is a mix of compile and link time options because the lto link phase
 ### needs access to the optimization flags.
@@ -800,7 +812,7 @@ endif
 
 .PHONY: help build profile-build strip install clean net objclean profileclean \
         config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
-        clang-profile-use clang-profile-make
+        clang-profile-use clang-profile-make FORCE
 
 build: net config-sanity
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all
@@ -948,6 +960,10 @@ config-sanity: net
 $(EXE): $(OBJS)
        +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
 
+# Force recompilation to ensure version info is up-to-date
+misc.o: FORCE
+FORCE:
+
 clang-profile-make:
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-instr-generate ' \