Git fork

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 <ps@pks.im>

+34 -20
+3 -19
Makefile
··· 112 112 TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app 113 113 endif 114 114 endif 115 - TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app) 115 + TKEXECUTABLE = $(TKFRAMEWORK)/Contents/MacOS/$(shell basename "$(TKFRAMEWORK)" .app) 116 116 TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE)) 117 117 endif 118 118 ··· 130 130 131 131 gg_libdir ?= $(sharedir)/git-gui/lib 132 132 libdir_SQ = $(subst ','\'',$(gg_libdir)) 133 - libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir_sed_in))) 134 133 exedir = $(dir $(gitexecdir))share/git-gui/lib 135 134 136 135 GITGUI_RELATIVE := ··· 139 138 ifeq ($(exedir),$(gg_libdir)) 140 139 GITGUI_RELATIVE := 1 141 140 endif 142 - gg_libdir_sed_in := $(gg_libdir) 143 141 ifeq ($(uname_S),Darwin) 144 142 ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y) 145 143 GITGUI_MACOSXAPP := YesPlease ··· 163 161 macosx/Info.plist \ 164 162 macosx/git-gui.icns \ 165 163 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 182 166 endif 183 167 184 168 ifdef GITGUI_WINDOWS_WRAPPER
+30
generate-macos-app.sh
··· 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"
+1 -1
generate-macos-wrapper.sh
··· 26 26 echo "git-gui version $GITGUI_VERSION" 27 27 else 28 28 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" "$@" 30 30 fi 31 31 EOF 32 32 ) >"$OUTPUT+"