Skip to content

Commit 114494a

Browse files
pks-tgitster
authored andcommitted
Makefile: introduce template for GIT-VERSION-GEN
Introduce a new template to call GIT-VERSION-GEN. This will allow us to iterate on how exactly the script is called in subsequent commits without having to adapt all call sites every time. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b329f2e commit 114494a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Documentation/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ XMLTO_EXTRA += --skip-validation
211211
XMLTO_EXTRA += -x manpage.xsl
212212

213213
asciidoctor-extensions.rb: asciidoctor-extensions.rb.in FORCE
214-
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@
214+
$(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
215215
else
216216
asciidoc.conf: asciidoc.conf.in FORCE
217-
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@
217+
$(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@)
218218
endif
219219

220220
ASCIIDOC_DEPS += docinfo.html

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ include shared.mak
593593

594594
GIT-VERSION-FILE: FORCE
595595
@OLD=$$(cat $@ 2>/dev/null || :) && \
596-
$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" GIT-VERSION-FILE.in $@ && \
596+
$(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \
597597
NEW=$$(cat $@ 2>/dev/null || :) && \
598598
if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi
599599
-include GIT-VERSION-FILE
@@ -2509,7 +2509,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
25092509
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
25102510

25112511
version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT
2512-
$(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@
2512+
$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
25132513

25142514
version.sp version.s version.o: version-def.h
25152515

@@ -2550,7 +2550,7 @@ $(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS G
25502550
mv $@+ $@
25512551

25522552
git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE
2553-
$(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@
2553+
$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
25542554

25552555
git.res: git.rc GIT-PREFIX
25562556
$(QUIET_RC)$(RC) -i $< -o $@

shared.mak

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,11 @@ endef
116116
define libpath_template
117117
-L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1))
118118
endef
119+
120+
# Populate build information into a file via GIT-VERSION-GEN. Requires the
121+
# absolute path to the root source directory as well as input and output files
122+
# as arguments, in that order.
123+
define version_gen
124+
GIT_USER_AGENT="$(GIT_USER_AGENT)" \
125+
$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)"
126+
endef

0 commit comments

Comments
 (0)