Skip to content

Commit 5e39b47

Browse files
committed
Build .release_info files containing the version string
By adding build-dependencies to all *_parse_options files whenever the contents of .release_info files differs from $(RELEASE_INFO), we ensure that binaries print the correct version strings.
1 parent cfceb6d commit 5e39b47

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Release/*
2828
*.obj
2929
*.a
3030
*.lib
31+
.release_info
3132
src/ansi-c/arm_builtin_headers.inc
3233
src/ansi-c/clang_builtin_headers.inc
3334
src/ansi-c/cprover_builtin_headers.inc

src/common

+17-1
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,28 @@ OBJ += $(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC)))
230230
%.obj:%.c
231231
$(CC) $(CP_CFLAGS) /nologo /c /EHsc $< /Fo$@
232232

233+
# Use make >= 4.0's `file` function, if available - it should be faster than
234+
# `shell cat`
235+
ifeq ($(firstword $(subst ., , $(MAKE_VERSION))), 3)
236+
KNOWN_RELEASE_INFO = $(shell cat .release_info 2>/dev/null)
237+
else
238+
KNOWN_RELEASE_INFO = $(file < .release_info)
239+
endif
240+
ifneq ($(GIT_INFO), $(KNOWN_RELEASE_INFO))
241+
$(filter %_parse_options$(OBJEXT), $(OBJ)): .release_info
242+
243+
.release_info:
244+
echo $(GIT_INFO) > $@
245+
246+
.PHONY: .release_info
247+
endif
248+
233249
clean:
234250
$(RM) $(patsubst %.cpp, %$(OBJEXT), $(filter %.cpp, $(SRC))) \
235251
$(patsubst %.cpp, %$(DEPEXT), $(filter %.cpp, $(SRC))) \
236252
$(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC))) \
237253
$(patsubst %.cc, %$(DEPEXT), $(filter %.cc, $(SRC))) \
238-
$(CLEANFILES)
254+
$(CLEANFILES) .release_info
239255

240256
.PHONY: first_target clean all
241257
.PHONY: sources generated_files

0 commit comments

Comments
 (0)