diff mbox series

[09/12] gitk: extract script to build Gitk

Message ID 20250218-b4-pks-meson-contrib-v1-9-c3edd292beb8@pks.im (mailing list archive)
State Superseded
Headers show
Series meson: wire up bits and pieces from "contrib/" | expand

Commit Message

Patrick Steinhardt Feb. 18, 2025, 7:45 a.m. UTC
Extract the script that "builds" Gitk from our Makefile so that we can
reuse it in Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 gitk-git/Makefile        |  7 +++----
 gitk-git/generate-tcl.sh | 11 +++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

Comments

Junio C Hamano Feb. 18, 2025, 10:25 p.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> Extract the script that "builds" Gitk from our Makefile so that we can
> reuse it in Meson.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  gitk-git/Makefile        |  7 +++----
>  gitk-git/generate-tcl.sh | 11 +++++++++++
>  2 files changed, 14 insertions(+), 4 deletions(-)

You would want to coordinate this with Johannes Sixt, who may still
want to maintain the subtree arrangement.

Thanks.


> diff --git a/gitk-git/Makefile b/gitk-git/Makefile
> index e1f0aff4a19..a396eef581e 100644
> --- a/gitk-git/Makefile
> +++ b/gitk-git/Makefile
> @@ -8,6 +8,7 @@ gitk_libdir   ?= $(sharedir)/gitk/lib
>  msgsdir    ?= $(gitk_libdir)/msgs
>  msgsdir_SQ  = $(subst ','\'',$(msgsdir))
>  
> +SHELL_PATH ?= /bin/sh
>  TCL_PATH ?= tclsh
>  TCLTK_PATH ?= wish
>  INSTALL ?= install
> @@ -63,10 +64,8 @@ clean::
>  	$(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
>  
>  gitk-wish: gitk GIT-TCLTK-VARS
> -	$(QUIET_GEN)$(RM) $@ $@+ && \
> -	sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
> -	chmod +x $@+ && \
> -	mv -f $@+ $@
> +	$(QUIET_GEN)$(RM) $@ $@+
> +	$(QUIET_GEN)$(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@"
>  
>  $(PO_TEMPLATE): gitk
>  	$(XGETTEXT) -kmc -LTcl -o $@ gitk
> diff --git a/gitk-git/generate-tcl.sh b/gitk-git/generate-tcl.sh
> new file mode 100755
> index 00000000000..46bba6d2464
> --- /dev/null
> +++ b/gitk-git/generate-tcl.sh
> @@ -0,0 +1,11 @@
> +#!/bin/sh
> +
> +set -e
> +
> +WISH=$(echo "$1" | sed 's/|/\\|/g')
> +INPUT="$2"
> +OUTPUT="$3"
> +
> +sed -e "1,3s|^exec .* \"\$0\"|exec $WISH \"\$0\"|" "$INPUT" >"$OUTPUT"+
> +chmod a+x "$OUTPUT"+
> +mv "$OUTPUT"+ "$OUTPUT"
Patrick Steinhardt Feb. 19, 2025, 5:53 a.m. UTC | #2
On Tue, Feb 18, 2025 at 02:25:43PM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > Extract the script that "builds" Gitk from our Makefile so that we can
> > reuse it in Meson.
> >
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> >  gitk-git/Makefile        |  7 +++----
> >  gitk-git/generate-tcl.sh | 11 +++++++++++
> >  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> You would want to coordinate this with Johannes Sixt, who may still
> want to maintain the subtree arrangement.

Oh, I had him in mind when writing the patch series, but thought that he
only maintained git-gui, not gitk. Must have been misremembering.

Anyway, Johannes, I'm happy to evict these changes from this patch
series and create them as a pull request against your tree. We should
then also be including the project as a `subproject()` so that it can be
used standalone.

Patrick
Johannes Sixt Feb. 19, 2025, 11:42 a.m. UTC | #3
Am 19.02.25 um 06:53 schrieb Patrick Steinhardt:
> On Tue, Feb 18, 2025 at 02:25:43PM -0800, Junio C Hamano wrote:
>> You would want to coordinate this with Johannes Sixt, who may still
>> want to maintain the subtree arrangement.
> 
> Anyway, Johannes, I'm happy to evict these changes from this patch
> series and create them as a pull request against your tree. We should
> then also be including the project as a `subproject()` so that it can be
> used standalone.

We can do that.

But there will be a time frame where the Git repository already knows
how to (and wants to) build Gitk as subproject, but the Gitk repository
has not been pulled, yet, and is missing the corresponding Meson
instructions. Will this work, or should we wait until Gitk's part has
been integrated in the Git repository?

-- Hannes
Patrick Steinhardt Feb. 19, 2025, 11:51 a.m. UTC | #4
On Wed, Feb 19, 2025 at 12:42:44PM +0100, Johannes Sixt wrote:
> Am 19.02.25 um 06:53 schrieb Patrick Steinhardt:
> > On Tue, Feb 18, 2025 at 02:25:43PM -0800, Junio C Hamano wrote:
> >> You would want to coordinate this with Johannes Sixt, who may still
> >> want to maintain the subtree arrangement.
> > 
> > Anyway, Johannes, I'm happy to evict these changes from this patch
> > series and create them as a pull request against your tree. We should
> > then also be including the project as a `subproject()` so that it can be
> > used standalone.
> 
> We can do that.
> 
> But there will be a time frame where the Git repository already knows
> how to (and wants to) build Gitk as subproject, but the Gitk repository
> has not been pulled, yet, and is missing the corresponding Meson
> instructions. Will this work, or should we wait until Gitk's part has
> been integrated in the Git repository?

I guess the easiest way is to land the Meson support in gitk first,
pull those changes into Git and then I'll create a follow-up patch
where we start to use gitk as a subproject. Does that work for you?

Patrick
Johannes Sixt Feb. 19, 2025, 5:32 p.m. UTC | #5
Am 19.02.25 um 12:51 schrieb Patrick Steinhardt:
> I guess the easiest way is to land the Meson support in gitk first,
> pull those changes into Git and then I'll create a follow-up patch
> where we start to use gitk as a subproject. Does that work for you?

Sure, let's do that.

-- Hannes
diff mbox series

Patch

diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index e1f0aff4a19..a396eef581e 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -8,6 +8,7 @@  gitk_libdir   ?= $(sharedir)/gitk/lib
 msgsdir    ?= $(gitk_libdir)/msgs
 msgsdir_SQ  = $(subst ','\'',$(msgsdir))
 
+SHELL_PATH ?= /bin/sh
 TCL_PATH ?= tclsh
 TCLTK_PATH ?= wish
 INSTALL ?= install
@@ -63,10 +64,8 @@  clean::
 	$(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
 
 gitk-wish: gitk GIT-TCLTK-VARS
-	$(QUIET_GEN)$(RM) $@ $@+ && \
-	sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
-	chmod +x $@+ && \
-	mv -f $@+ $@
+	$(QUIET_GEN)$(RM) $@ $@+
+	$(QUIET_GEN)$(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@"
 
 $(PO_TEMPLATE): gitk
 	$(XGETTEXT) -kmc -LTcl -o $@ gitk
diff --git a/gitk-git/generate-tcl.sh b/gitk-git/generate-tcl.sh
new file mode 100755
index 00000000000..46bba6d2464
--- /dev/null
+++ b/gitk-git/generate-tcl.sh
@@ -0,0 +1,11 @@ 
+#!/bin/sh
+
+set -e
+
+WISH=$(echo "$1" | sed 's/|/\\|/g')
+INPUT="$2"
+OUTPUT="$3"
+
+sed -e "1,3s|^exec .* \"\$0\"|exec $WISH \"\$0\"|" "$INPUT" >"$OUTPUT"+
+chmod a+x "$OUTPUT"+
+mv "$OUTPUT"+ "$OUTPUT"