git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS

The GIT-GUI-VARS file is used to track whether any of our build options has changed. Unfortunately, the format of that file does not allow us to propagate those build options to other scripts. But as we are about to introduce support for the Meson build system, we will extract a couple of scripts to deduplicate core build logic across Makefiles and Meson. With this refactoring, it will become necessary to make build options more widely accessible. Replace GIT-GUI-VARS with a new GIT-GUI-BUILD-OPTIONS file that is being populated from a template. This file can easily be sourced from build scripts in subsequent steps. Signed-off-by: Patrick Steinhardt <ps@pks.im>

Patrick Steinhardt committed May 12, 2025 at 11:25 UTC 3271d2e9e71678cdc22378b1fd58c07641f8c424
3 files changed +23 -21
.gitignore
+1 -1
@@ -2,7 +2,7 @@
2 config.mak
3 Git Gui.app*
4 git-gui.tcl
5 +GIT-GUI-BUILD-OPTIONS
6 GIT-VERSION-FILE
6 -GIT-GUI-VARS
7 git-gui
8 lib/tclIndex
GIT-GUI-BUILD-OPTIONS.in new
+6
@@ -0,0 +1,6 @@
1 +GITGUI_GITEXECDIR=@GITGUI_GITEXECDIR@
2 +GITGUI_LIBDIR=@GITGUI_LIBDIR@
3 +GITGUI_RELATIVE=@GITGUI_RELATIVE@
4 +SHELL_PATH=@SHELL_PATH@
5 +TCLTK_PATH=@TCLTK_PATH@
6 +TCL_PATH=@TCL_PATH@
Makefile
+16 -20
@@ -158,7 +158,7 @@ endif
158 ifdef GITGUI_MACOSXAPP
159 GITGUI_MAIN := git-gui.tcl
160
161 -git-gui: GIT-VERSION-FILE GIT-GUI-VARS
161 +git-gui: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
162 $(QUIET_GEN)rm -f $@ $@+ && \
163 echo '#!$(SHELL_PATH_SQ)' >$@+ && \
164 echo 'if test "z$$*" = zversion ||' >>$@+ && \
@@ -173,7 +173,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
173 chmod +x $@+ && \
174 mv $@+ $@
175
176 -Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
176 +Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
177 macosx/Info.plist \
178 macosx/git-gui.icns \
179 macosx/AppMain.tcl \
@@ -202,7 +202,7 @@ git-gui: windows/git-gui.sh
202 cp $< $@
203 endif
204
205 -$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
205 +$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
206 $(QUIET_GEN)rm -f $@ $@+ && \
207 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
208 -e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
@@ -238,7 +238,7 @@ update-po:: $(PO_TEMPLATE)
238 $(ALL_MSGFILES): %.msg : %.po
239 $(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< $(QUIET_MSGFMT1)
240
241 -lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
241 +lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-BUILD-OPTIONS
242 $(QUIET_INDEX)if echo \
243 $(foreach p,$(PRELOAD_FILES),source $p\;) \
244 auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
@@ -252,21 +252,17 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
252 echo >>$@ ; \
253 fi
254
255 -TRACK_VARS = \
256 - $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
257 - $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
258 - $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
259 - $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
260 - $(subst ','\'',gg_libdir='$(libdir_SQ)') \
261 - GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
262 -#end TRACK_VARS
263 -
264 -GIT-GUI-VARS: FORCE
265 - @VARS='$(TRACK_VARS)'; \
266 - if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
267 - echo >&2 " * new locations or Tcl/Tk interpreter"; \
268 - echo >$@ "$$VARS"; \
269 - fi
255 +GIT-GUI-BUILD-OPTIONS: FORCE
256 + @sed \
257 + -e 's|@GITGUI_GITEXECDIR@|$(gitexecdir_SQ)|' \
258 + -e 's|@GITGUI_LIBDIR@|$(libdir_SQ)|' \
259 + -e 's|@GITGUI_RELATIVE@|$(GITGUI_RELATIVE)|' \
260 + -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
261 + -e 's|@TCLTK_PATH@|$(TCLTK_PATH_SQ)|' \
262 + -e 's|@TCL_PATH@|$(TCL_PATH_SQ)|' \
263 + $@.in >$@+
264 + @if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
265 + @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
266
267 ifdef GITGUI_MACOSXAPP
268 all:: git-gui Git\ Gui.app
@@ -322,7 +318,7 @@ dist-version:
318
319 clean::
320 $(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE)
325 - $(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS
321 + $(RM_RF) GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
322 ifdef GITGUI_MACOSXAPP
323 $(RM_RF) 'Git Gui.app'* git-gui
324 endif