Skip to content

Commit 9d6c955

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 7893a5e commit 9d6c955

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-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

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

233+
# make >= 4.0 has a `file` function that may be faster than `shell cat`
234+
# for now, portability wins
235+
KNOWN_RELEASE_INFO = $(shell cat .release_info 2>/dev/null)
236+
ifneq ($(GIT_INFO), $(KNOWN_RELEASE_INFO))
237+
$(filter %_parse_options$(OBJEXT), $(OBJ)): .release_info
238+
239+
.release_info:
240+
echo $(GIT_INFO) > $@
241+
endif
242+
233243
clean:
234244
$(RM) $(patsubst %.cpp, %$(OBJEXT), $(filter %.cpp, $(SRC))) \
235245
$(patsubst %.cpp, %$(DEPEXT), $(filter %.cpp, $(SRC))) \
236246
$(patsubst %.cc, %$(OBJEXT), $(filter %.cc, $(SRC))) \
237247
$(patsubst %.cc, %$(DEPEXT), $(filter %.cc, $(SRC))) \
238-
$(CLEANFILES)
248+
$(CLEANFILES) .release_info
239249

240250
.PHONY: first_target clean all
241251
.PHONY: sources generated_files

0 commit comments

Comments
 (0)