Skip to content

Commit 0ee7ac5

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 6e388c2 commit 0ee7ac5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,28 @@ else
238238
$(CBMC_VERSION_FILES): CP_CXXFLAGS += -DCBMC_VERSION="\"$(CBMC_VERSION) ($(GIT_INFO))\""
239239
endif
240240

241+
# Use make >= 4.0's `file` function, if available - it should be faster than
242+
# `shell cat`
243+
ifeq ($(firstword $(subst ., , $(MAKE_VERSION))), 3)
244+
KNOWN_RELEASE_INFO = $(shell cat .release_info 2>/dev/null)
245+
else
246+
KNOWN_RELEASE_INFO = $(file < .release_info)
247+
endif
248+
ifneq ($(GIT_INFO), $(KNOWN_RELEASE_INFO))
249+
$(CBMC_VERSION_FILES): .release_info
250+
251+
.release_info:
252+
echo $(GIT_INFO) > $@
253+
254+
.PHONY: .release_info
255+
endif
256+
241257
clean:
242258
$(RM) $(patsubst %.cpp, %$(OBJEXT), $(filter %.cpp, $(SRC))) \
243259
$(patsubst %.cpp, %$(DEPEXT), $(filter %.cpp, $(SRC))) \
244260
$(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC))) \
245261
$(patsubst %.cc, %$(DEPEXT), $(filter %.cc, $(SRC))) \
246-
$(CLEANFILES)
262+
$(CLEANFILES) .release_info
247263

248264
.PHONY: first_target clean all
249265
.PHONY: sources generated_files

0 commit comments

Comments
 (0)