]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS
authorPatrick Steinhardt <ps@pks.im>
Mon, 12 May 2025 09:25:05 +0000 (11:25 +0200)
committerPatrick Steinhardt <ps@pks.im>
Tue, 13 May 2025 06:27:09 +0000 (08:27 +0200)
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>
.gitignore
GIT-GUI-BUILD-OPTIONS.in [new file with mode: 0644]
Makefile

index 6483b21cbfc73601602d628a2c609d3ca84f9e53..ff6e0be4b4126cf804dde11d37d762a4d1d1a817 100644 (file)
@@ -2,7 +2,7 @@
 config.mak
 Git Gui.app*
 git-gui.tcl
+GIT-GUI-BUILD-OPTIONS
 GIT-VERSION-FILE
-GIT-GUI-VARS
 git-gui
 lib/tclIndex
diff --git a/GIT-GUI-BUILD-OPTIONS.in b/GIT-GUI-BUILD-OPTIONS.in
new file mode 100644 (file)
index 0000000..3c112af
--- /dev/null
@@ -0,0 +1,6 @@
+GITGUI_GITEXECDIR=@GITGUI_GITEXECDIR@
+GITGUI_LIBDIR=@GITGUI_LIBDIR@
+GITGUI_RELATIVE=@GITGUI_RELATIVE@
+SHELL_PATH=@SHELL_PATH@
+TCLTK_PATH=@TCLTK_PATH@
+TCL_PATH=@TCL_PATH@
index 9f9389aea99cd0444673e80602ead3a65343f31c..f4f98961b2eec59f98045d5611d1ca5fed857688 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -158,7 +158,7 @@ endif
 ifdef GITGUI_MACOSXAPP
 GITGUI_MAIN := git-gui.tcl
 
-git-gui: GIT-VERSION-FILE GIT-GUI-VARS
+git-gui: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
        $(QUIET_GEN)rm -f $@ $@+ && \
        echo '#!$(SHELL_PATH_SQ)' >$@+ && \
        echo 'if test "z$$*" = zversion ||' >>$@+ && \
@@ -173,7 +173,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
        chmod +x $@+ && \
        mv $@+ $@
 
-Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
+Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
                macosx/Info.plist \
                macosx/git-gui.icns \
                macosx/AppMain.tcl \
@@ -202,7 +202,7 @@ git-gui: windows/git-gui.sh
        cp $< $@
 endif
 
-$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
+$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
        $(QUIET_GEN)rm -f $@ $@+ && \
        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
                -e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
@@ -238,7 +238,7 @@ update-po:: $(PO_TEMPLATE)
 $(ALL_MSGFILES): %.msg : %.po
        $(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< $(QUIET_MSGFMT1)
 
-lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
+lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-BUILD-OPTIONS
        $(QUIET_INDEX)if echo \
          $(foreach p,$(PRELOAD_FILES),source $p\;) \
          auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
@@ -252,21 +252,17 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
         echo >>$@ ; \
        fi
 
-TRACK_VARS = \
-       $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
-       $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
-       $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
-       $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
-       $(subst ','\'',gg_libdir='$(libdir_SQ)') \
-       GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
-#end TRACK_VARS
-
-GIT-GUI-VARS: FORCE
-       @VARS='$(TRACK_VARS)'; \
-       if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
-               echo >&2 "    * new locations or Tcl/Tk interpreter"; \
-               echo >$@ "$$VARS"; \
-       fi
+GIT-GUI-BUILD-OPTIONS: FORCE
+       @sed \
+               -e 's|@GITGUI_GITEXECDIR@|$(gitexecdir_SQ)|' \
+               -e 's|@GITGUI_LIBDIR@|$(libdir_SQ)|' \
+               -e 's|@GITGUI_RELATIVE@|$(GITGUI_RELATIVE)|' \
+               -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
+               -e 's|@TCLTK_PATH@|$(TCLTK_PATH_SQ)|' \
+               -e 's|@TCL_PATH@|$(TCL_PATH_SQ)|' \
+               $@.in >$@+
+       @if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
+       @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
 
 ifdef GITGUI_MACOSXAPP
 all:: git-gui Git\ Gui.app
@@ -322,7 +318,7 @@ dist-version:
 
 clean::
        $(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE)
-       $(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS
+       $(RM_RF) GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
 ifdef GITGUI_MACOSXAPP
        $(RM_RF) 'Git Gui.app'* git-gui
 endif