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

Note that as part of this change we also modify the TKEXECUTABLE
variable to track its full path. Like this we don't have to propagate
both the TKEXECUTABLE and TKFRAMEWORK variables into the script, and the
basename can be trivially computed from TKEXECUTABLE anyway.

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

index 722df4ae3fb42909399694c4d0127da63fbe9084..cde1b7e607d8b740d27fdc0af1800ee18cca5cb5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -112,7 +112,7 @@ ifeq ($(uname_S),Darwin)
                        TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
                 endif
         endif
-       TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
+       TKEXECUTABLE = $(TKFRAMEWORK)/Contents/MacOS/$(shell basename "$(TKFRAMEWORK)" .app)
        TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE))
 endif
 
@@ -130,7 +130,6 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 
 gg_libdir ?= $(sharedir)/git-gui/lib
 libdir_SQ  = $(subst ','\'',$(gg_libdir))
-libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir_sed_in)))
 exedir     = $(dir $(gitexecdir))share/git-gui/lib
 
 GITGUI_RELATIVE :=
@@ -139,7 +138,6 @@ GITGUI_MACOSXAPP :=
 ifeq ($(exedir),$(gg_libdir))
        GITGUI_RELATIVE := 1
 endif
-gg_libdir_sed_in := $(gg_libdir)
 ifeq ($(uname_S),Darwin)
         ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
                GITGUI_MACOSXAPP := YesPlease
@@ -163,22 +161,8 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
                macosx/Info.plist \
                macosx/git-gui.icns \
                macosx/AppMain.tcl \
-               $(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
-       $(QUIET_GEN)rm -rf '$@' '$@'+ && \
-       mkdir -p '$@'+/Contents/MacOS && \
-       mkdir -p '$@'+/Contents/Resources/Scripts && \
-       cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
-               '$@'+/Contents/MacOS && \
-       cp macosx/git-gui.icns '$@'+/Contents/Resources && \
-       sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-               -e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
-               macosx/Info.plist \
-               >'$@'+/Contents/Info.plist && \
-       sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
-               -e 's|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
-               macosx/AppMain.tcl \
-               >'$@'+/Contents/Resources/Scripts/AppMain.tcl && \
-       mv '$@'+ '$@'
+               $(TKEXECUTABLE)
+       $(QUIET_GEN)$(SHELL_PATH) generate-macos-app.sh . "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
 endif
 
 ifdef GITGUI_WINDOWS_WRAPPER
diff --git a/generate-macos-app.sh b/generate-macos-app.sh
new file mode 100755 (executable)
index 0000000..71b9fa6
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+SOURCE_DIR="$1"
+OUTPUT="$2"
+BUILD_OPTIONS="$3"
+VERSION_FILE="$4"
+
+. "$BUILD_OPTIONS"
+. "$VERSION_FILE"
+
+rm -rf "$OUTPUT" "$OUTPUT+"
+
+mkdir -p "$OUTPUT+/Contents/MacOS"
+mkdir -p "$OUTPUT+/Contents/Resources/Scripts"
+
+cp "$TKEXECUTABLE" "$OUTPUT+/Contents/MacOS"
+cp "$SOURCE_DIR/macosx/git-gui.icns" "$OUTPUT+/Contents/Resources"
+sed \
+       -e "s/@@GITGUI_VERSION@@/$GITGUI_VERSION/g" \
+       -e "s/@@GITGUI_TKEXECUTABLE@@/$(basename "$TKEXECUTABLE")/g" \
+       "$SOURCE_DIR/macosx/Info.plist" \
+       >"$OUTPUT+/Contents/Info.plist"
+sed \
+       -e "s|@@gitexecdir@@|$GITGUI_GITEXECDIR|" \
+       -e "s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
+       "$SOURCE_DIR/macosx/AppMain.tcl" \
+       >"$OUTPUT+/Contents/Resources/Scripts/AppMain.tcl"
+mv "$OUTPUT+" "$OUTPUT"
index da7e4782f7241e82553b6ff2e928bd88080525db..0304937f41e169b947539c2a80dcfec955e4be61 100755 (executable)
@@ -26,7 +26,7 @@ rm -f "$OUTPUT" "$OUTPUT+"
                echo "git-gui version $GITGUI_VERSION"
        else
                libdir="${GIT_GUI_LIB_DIR:-$GITGUI_LIBDIR}"
-               exec "$libdir/Git Gui.app/Contents/MacOS/$TKEXECUTABLE" "$0" "$@"
+               exec "$libdir/Git Gui.app/Contents/MacOS/$(basename "$TKEXECUTABLE")" "$0" "$@"
        fi
        EOF
 ) >"$OUTPUT+"