]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: extract script to generate "git-gui"
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Mar 2025 10:07:19 +0000 (11:07 +0100)
committerPatrick Steinhardt <ps@pks.im>
Tue, 13 May 2025 06:27:11 +0000 (08:27 +0200)
Extract script to generate "git-gui". This change allows us to reuse the
build logic with the Meson build system.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Makefile
generate-git-gui.sh [new file with mode: 0755]

index 1cbb16a92196a132bbe12fe1d91a15184852be63..58a65dba245706fdf0b490aa60b154038cc28172 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -127,7 +127,6 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
-TCLTK_PATH_SED = $(subst ','\'',$(subst \,\\,$(TCLTK_PATH)))
 
 gg_libdir ?= $(sharedir)/git-gui/lib
 libdir_SQ  = $(subst ','\'',$(gg_libdir))
@@ -202,16 +201,7 @@ git-gui: windows/git-gui.sh
 endif
 
 $(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)|' \
-               -e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
-               -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-               -e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
-               -e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
-               git-gui.sh >$@+ && \
-       chmod +x $@+ && \
-       mv $@+ $@
+       $(QUIET_GEN)$(SHELL_PATH) generate-git-gui.sh "$<" "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
 
 XGETTEXT   ?= xgettext
 ifdef NO_MSGFMT
diff --git a/generate-git-gui.sh b/generate-git-gui.sh
new file mode 100755 (executable)
index 0000000..39dfafd
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+if test "$#" -ne 4
+then
+       echo >&2 "usage: $0 <INPUT> <OUTPUT> <BUILD_OPTIONS> <VERSION_FILE>"
+       exit 1
+fi
+
+INPUT="$1"
+OUTPUT="$2"
+BUILD_OPTIONS="$3"
+VERSION_FILE="$4"
+
+. "${BUILD_OPTIONS}"
+. "${VERSION_FILE}"
+
+rm -f "$OUTPUT" "$OUTPUT+"
+sed \
+       -e "1s|#!.*/sh|#!$SHELL_PATH|" \
+       -e "s|@@SHELL_PATH@@|$SHELL_PATH|" \
+       -e "1,30s|^ exec wish | exec '$TCLTK_PATH' |" \
+       -e "s|@@GITGUI_VERSION@@|$GITGUI_VERSION|g" \
+       -e "s|@@GITGUI_RELATIVE@@|$GITGUI_RELATIVE|" \
+       -e "${GITGUI_RELATIVE}s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
+       "$INPUT" >"$OUTPUT"+
+chmod +x "$OUTPUT"+
+mv "$OUTPUT"+ "$OUTPUT"