@matheusbsbs / matheus-bagliano / commits / 2f7c9a7f31
Fork 0

git-gui: Support native Win32 Tcl/Tk under Cygwin

Cygwin has been stuck on the 8.4.1 version of Tcl/Tk for quite some time, even though the main Tcl/Tk distribution is already shipping an 8.4.15. The problem is Tcl/Tk no longer supports Cygwin so apparently building the package for Cygwin is now a non-trivial task. Its actually quite easy to build the native Win32 version of Tcl/Tk by compiling with the -mno-cygwin flag passed to GCC but this means we lose all of the "fancy" Cygwin path translations that the Tcl library was doing for us. This is particularly an issue when we are trying to start git-gui through the git wrapper as the git wrapper is passing off a Cygwin path for $0 and Tcl cannot find the startup script or the library directory. We now use `cygpath -m -a` to convert the UNIX style paths to Windows style paths in our startup script if we are building on Cygwin. Doing so allows either the Cygwin-ized Tcl/Tk 8.4.1 that comes with Cygwin or a manually built 8.4.15 that is running the pure Win32 implementation to read our script. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Sep 20, 2007 at 21:25 UTC 2f7c9a7f310dae23989b4acd49514abc58334e5b
2 files changed +23 -14
Makefile
+20 -12
@@ -92,27 +92,35 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
92 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
93 TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
94 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
95 +TCLTK_PATH_SED = $(subst ','\'',$(subst \,\\,$(TCLTK_PATH)))
96
97 gg_libdir ?= $(sharedir)/git-gui/lib
98 libdir_SQ = $(subst ','\'',$(gg_libdir))
99 +libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir)))
100 +exedir = $(dir $(gitexecdir))share/git-gui/lib
101
99 -exedir = $(dir $(gitexecdir))share/git-gui/lib
100 -exedir_SQ = $(subst ','\'',$(exedir))
102 +GITGUI_SCRIPT := $$0
103 +GITGUI_RELATIVE :=
104 +
105 +ifeq ($(exedir),$(gg_libdir))
106 + GITGUI_RELATIVE := 1
107 +endif
108 +
109 +ifeq ($(uname_O),Cygwin)
110 + GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
111 + ifeq ($(GITGUI_RELATIVE),)
112 + gg_libdir := $(shell cygpath --windows --absolute "$(gg_libdir)")
113 + endif
114 +endif
115
116 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
117 $(QUIET_GEN)rm -f $@ $@+ && \
104 - GITGUI_RELATIVE= && \
105 - if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
106 - if test "$(uname_O)" = Cygwin; \
107 - then GITGUI_RELATIVE= ; \
108 - else GITGUI_RELATIVE=1; \
109 - fi; \
110 - fi && \
118 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
112 - -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
119 + -e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
120 + -e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
121 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
114 - -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
115 - -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
122 + -e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
123 + -e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
124 $@.sh >$@+ && \
125 chmod +x $@+ && \
126 mv $@+ $@
git-gui.sh
+3 -2
@@ -6,7 +6,8 @@
6 echo 'git-gui version @@GITGUI_VERSION@@'; \
7 exit; \
8 fi; \
9 - exec wish "$0" -- "$@"
9 + argv0=$0; \
10 + exec wish "$argv0" -- "$@"
11
12 set appvers {@@GITGUI_VERSION@@}
13 set copyright {
@@ -740,7 +741,7 @@ if {[catch {
741 exit 1
742 }
743 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
743 - catch {set _gitdir [exec cygpath --unix $_gitdir]}
744 + catch {set _gitdir [exec cygpath --windows $_gitdir]}
745 }
746 if {![file isdirectory $_gitdir]} {
747 catch {wm withdraw .}