Skip to content

Commit 3271d2e

Browse files
committed
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 <[email protected]>
1 parent 309bb87 commit 3271d2e

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
config.mak
33
Git Gui.app*
44
git-gui.tcl
5+
GIT-GUI-BUILD-OPTIONS
56
GIT-VERSION-FILE
6-
GIT-GUI-VARS
77
git-gui
88
lib/tclIndex

GIT-GUI-BUILD-OPTIONS.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ endif
158158
ifdef GITGUI_MACOSXAPP
159159
GITGUI_MAIN := git-gui.tcl
160160

161-
git-gui: GIT-VERSION-FILE GIT-GUI-VARS
161+
git-gui: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
162162
$(QUIET_GEN)rm -f $@ $@+ && \
163163
echo '#!$(SHELL_PATH_SQ)' >$@+ && \
164164
echo 'if test "z$$*" = zversion ||' >>$@+ && \
@@ -173,7 +173,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
173173
chmod +x $@+ && \
174174
mv $@+ $@
175175

176-
Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
176+
Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
177177
macosx/Info.plist \
178178
macosx/git-gui.icns \
179179
macosx/AppMain.tcl \
@@ -202,7 +202,7 @@ git-gui: windows/git-gui.sh
202202
cp $< $@
203203
endif
204204

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
206206
$(QUIET_GEN)rm -f $@ $@+ && \
207207
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
208208
-e 's|@@SHELL_PATH@@|$(SHELL_PATH_SQ)|' \
@@ -238,7 +238,7 @@ update-po:: $(PO_TEMPLATE)
238238
$(ALL_MSGFILES): %.msg : %.po
239239
$(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< $(QUIET_MSGFMT1)
240240

241-
lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
241+
lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-BUILD-OPTIONS
242242
$(QUIET_INDEX)if echo \
243243
$(foreach p,$(PRELOAD_FILES),source $p\;) \
244244
auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
@@ -252,21 +252,17 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
252252
echo >>$@ ; \
253253
fi
254254

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
270266

271267
ifdef GITGUI_MACOSXAPP
272268
all:: git-gui Git\ Gui.app
@@ -322,7 +318,7 @@ dist-version:
322318

323319
clean::
324320
$(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
326322
ifdef GITGUI_MACOSXAPP
327323
$(RM_RF) 'Git Gui.app'* git-gui
328324
endif

0 commit comments

Comments
 (0)