Skip to content

Commit 28a8e5c

Browse files
committed
git-gui: extract script to generate macOS app
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 <[email protected]>
1 parent 743e1cb commit 28a8e5c

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

Makefile

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ifeq ($(uname_S),Darwin)
112112
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
113113
endif
114114
endif
115-
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
115+
TKEXECUTABLE = $(TKFRAMEWORK)/Contents/MacOS/$(shell basename "$(TKFRAMEWORK)" .app)
116116
TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE))
117117
endif
118118

@@ -130,7 +130,6 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
130130

131131
gg_libdir ?= $(sharedir)/git-gui/lib
132132
libdir_SQ = $(subst ','\'',$(gg_libdir))
133-
libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir_sed_in)))
134133
exedir = $(dir $(gitexecdir))share/git-gui/lib
135134

136135
GITGUI_RELATIVE :=
@@ -139,7 +138,6 @@ GITGUI_MACOSXAPP :=
139138
ifeq ($(exedir),$(gg_libdir))
140139
GITGUI_RELATIVE := 1
141140
endif
142-
gg_libdir_sed_in := $(gg_libdir)
143141
ifeq ($(uname_S),Darwin)
144142
ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
145143
GITGUI_MACOSXAPP := YesPlease
@@ -163,22 +161,8 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
163161
macosx/Info.plist \
164162
macosx/git-gui.icns \
165163
macosx/AppMain.tcl \
166-
$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
167-
$(QUIET_GEN)rm -rf '$@' '$@'+ && \
168-
mkdir -p '$@'+/Contents/MacOS && \
169-
mkdir -p '$@'+/Contents/Resources/Scripts && \
170-
cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
171-
'$@'+/Contents/MacOS && \
172-
cp macosx/git-gui.icns '$@'+/Contents/Resources && \
173-
sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
174-
-e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
175-
macosx/Info.plist \
176-
>'$@'+/Contents/Info.plist && \
177-
sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
178-
-e 's|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
179-
macosx/AppMain.tcl \
180-
>'$@'+/Contents/Resources/Scripts/AppMain.tcl && \
181-
mv '$@'+ '$@'
164+
$(TKEXECUTABLE)
165+
$(QUIET_GEN)$(SHELL_PATH) generate-macos-app.sh . "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
182166
endif
183167

184168
ifdef GITGUI_WINDOWS_WRAPPER

generate-macos-app.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
SOURCE_DIR="$1"
6+
OUTPUT="$2"
7+
BUILD_OPTIONS="$3"
8+
VERSION_FILE="$4"
9+
10+
. "$BUILD_OPTIONS"
11+
. "$VERSION_FILE"
12+
13+
rm -rf "$OUTPUT" "$OUTPUT+"
14+
15+
mkdir -p "$OUTPUT+/Contents/MacOS"
16+
mkdir -p "$OUTPUT+/Contents/Resources/Scripts"
17+
18+
cp "$TKEXECUTABLE" "$OUTPUT+/Contents/MacOS"
19+
cp "$SOURCE_DIR/macosx/git-gui.icns" "$OUTPUT+/Contents/Resources"
20+
sed \
21+
-e "s/@@GITGUI_VERSION@@/$GITGUI_VERSION/g" \
22+
-e "s/@@GITGUI_TKEXECUTABLE@@/$(basename "$TKEXECUTABLE")/g" \
23+
"$SOURCE_DIR/macosx/Info.plist" \
24+
>"$OUTPUT+/Contents/Info.plist"
25+
sed \
26+
-e "s|@@gitexecdir@@|$GITGUI_GITEXECDIR|" \
27+
-e "s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \
28+
"$SOURCE_DIR/macosx/AppMain.tcl" \
29+
>"$OUTPUT+/Contents/Resources/Scripts/AppMain.tcl"
30+
mv "$OUTPUT+" "$OUTPUT"

generate-macos-wrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ rm -f "$OUTPUT" "$OUTPUT+"
2626
echo "git-gui version $GITGUI_VERSION"
2727
else
2828
libdir="${GIT_GUI_LIB_DIR:-$GITGUI_LIBDIR}"
29-
exec "$libdir/Git Gui.app/Contents/MacOS/$TKEXECUTABLE" "$0" "$@"
29+
exec "$libdir/Git Gui.app/Contents/MacOS/$(basename "$TKEXECUTABLE")" "$0" "$@"
3030
fi
3131
EOF
3232
) >"$OUTPUT+"

0 commit comments

Comments
 (0)