mirror of
https://github.com/git/git.git
synced 2026-04-14 02:40:08 +02:00
git-gui: extract script to generate macOS wrapper
Extract script to generate the macOS wrapper for git-gui. This change allows us to reuse the build logic with the Meson build system. Signed-off-by: Patrick Steinhardt <ps@pks.im>
This commit is contained in:
@@ -4,3 +4,4 @@ GITGUI_RELATIVE=@GITGUI_RELATIVE@
|
||||
SHELL_PATH=@SHELL_PATH@
|
||||
TCLTK_PATH=@TCLTK_PATH@
|
||||
TCL_PATH=@TCL_PATH@
|
||||
TKEXECUTABLE=@TKEXECUTABLE@
|
||||
|
||||
18
Makefile
18
Makefile
@@ -113,6 +113,7 @@ ifeq ($(uname_S),Darwin)
|
||||
endif
|
||||
endif
|
||||
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
|
||||
TKEXECUTABLE_SQ = $(subst ','\'',$(TKEXECUTABLE))
|
||||
endif
|
||||
|
||||
ifeq ($(findstring $(firstword -$(MAKEFLAGS)),s),s)
|
||||
@@ -155,20 +156,8 @@ endif
|
||||
ifdef GITGUI_MACOSXAPP
|
||||
GITGUI_MAIN := git-gui.tcl
|
||||
|
||||
git-gui: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
|
||||
$(QUIET_GEN)rm -f $@ $@+ && \
|
||||
echo '#!$(SHELL_PATH_SQ)' >$@+ && \
|
||||
echo 'if test "z$$*" = zversion ||' >>$@+ && \
|
||||
echo ' test "z$$*" = z--version' >>$@+ && \
|
||||
echo then >>$@+ && \
|
||||
echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
|
||||
echo else >>$@+ && \
|
||||
echo ' libdir="$${GIT_GUI_LIB_DIR:-$(libdir_SQ)}"' >>$@+ && \
|
||||
echo ' 'exec \"'$$libdir/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\" \
|
||||
'"$$0" "$$@"' >>$@+ && \
|
||||
echo fi >>$@+ && \
|
||||
chmod +x $@+ && \
|
||||
mv $@+ $@
|
||||
git-gui: generate-macos-wrapper.sh GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS
|
||||
$(QUIET_GEN)$(SHELL_PATH) generate-macos-wrapper.sh "$@" ./GIT-GUI-BUILD-OPTIONS ./GIT-VERSION-FILE
|
||||
|
||||
Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-BUILD-OPTIONS \
|
||||
macosx/Info.plist \
|
||||
@@ -236,6 +225,7 @@ GIT-GUI-BUILD-OPTIONS: FORCE
|
||||
-e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
|
||||
-e 's|@TCLTK_PATH@|$(TCLTK_PATH_SQ)|' \
|
||||
-e 's|@TCL_PATH@|$(TCL_PATH_SQ)|' \
|
||||
-e 's|@TKEXECUTABLE@|$(TKEXECUTABLE_SQ)|' \
|
||||
$@.in >$@+
|
||||
@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
|
||||
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
|
||||
|
||||
35
generate-macos-wrapper.sh
Executable file
35
generate-macos-wrapper.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if test "$#" -ne 3
|
||||
then
|
||||
echo >&2 "usage: $0 <OUTPUT> <BUILD_OPTIONS> <VERSION_FILE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTPUT="$1"
|
||||
BUILD_OPTIONS="$2"
|
||||
VERSION_FILE="$3"
|
||||
|
||||
. "$BUILD_OPTIONS"
|
||||
|
||||
rm -f "$OUTPUT" "$OUTPUT+"
|
||||
|
||||
(
|
||||
echo "#!$SHELL_PATH"
|
||||
cat "$BUILD_OPTIONS" "$VERSION_FILE"
|
||||
cat <<-'EOF'
|
||||
if test "z$*" = zversion ||
|
||||
test "z$*" = z--version
|
||||
then
|
||||
echo "git-gui version $GITGUI_VERSION"
|
||||
else
|
||||
libdir="${GIT_GUI_LIB_DIR:-$GITGUI_LIBDIR}"
|
||||
exec "$libdir/Git Gui.app/Contents/MacOS/$TKEXECUTABLE" "$0" "$@"
|
||||
fi
|
||||
EOF
|
||||
) >"$OUTPUT+"
|
||||
|
||||
chmod +x "$OUTPUT+"
|
||||
mv "$OUTPUT+" "$OUTPUT"
|
||||
Reference in New Issue
Block a user