Skip to content

Support for the Meson build system #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

pks-t
Copy link

@pks-t pks-t commented Mar 11, 2025

Similar to the recent MR in gitk, this patch series wires up support for Meson in git-gui. Once landed, I'll send a patch series to Git to wire up both of these over there.

@pks-t
Copy link
Author

pks-t commented Mar 11, 2025

I've tested the build instructions on NixOS, Windows 10 and (ancient) macOS 10.15 and have compared results between old/new Makefile results as well as Make and Meson. There are some minor differences around injected paths in Meson because we use the dynamically derived paths there. But other than that results looked mostly the same to me.

@j6t
Copy link
Owner

j6t commented Mar 11, 2025

Thank you. It will take some time until I can tend to this. Please bear with me.

@pks-t
Copy link
Author

pks-t commented Mar 11, 2025

Thank you. It will take some time until I can tend to this. Please bear with me.

No worries, take your time, there is no urgency here. Thanks!

@j6t
Copy link
Owner

j6t commented May 10, 2025

I started looking into this series, but then got side-tracked and forgot to follow up, hence, it's not included in my recent Git PR. My apologies for the delay.

Copy link
Owner

@j6t j6t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the problem is "the format of GIT-GUI-VARS does not allow us to propagate those build options to other scripts", why is this patch so much more than just "let's write it in a more usable format"? Why do we need a template file? What is the reason to rename the file?

GIT-VERSION-GEN Outdated
@@ -60,21 +74,21 @@ else
VN="$DEF_VER"
fi

dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
dirty=$(sh -c "git -C '$SOURCE_DIR' diff-index --name-only HEAD" 2>/dev/null) || dirty=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't kosher because single-quotes in $SOURCE_DIR aren't quoted. I don't see why we have to rungit in sh -c in the first place. Just run it in $() like we do everywhere else, including the redirection.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed.

else
VC=unset
fi
test "$VN" = "$VC" || {
echo >&2 "GITGUI_VERSION = $VN"
echo "GITGUI_VERSION = $VN" >$GVF
echo "GITGUI_VERSION = $VN" >$OUTPUT
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good time to put all "$OUTPUT" in double-quotes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, makes sense indeed.

$(QUIET_INDEX)if echo \
$(foreach p,$(PRELOAD_FILES),source $p\;) \
auto_mkindex lib $(patsubst lib/%,%,$(sort $(ALL_LIBFILES))) \
| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removal obsoletes Makefile variable QUIET_2DEVNULL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed.

Makefile Outdated
echo >>$@ ; \
fi
lib/tclIndex: $(ALL_LIBFILES) generate-tclindex.sh GIT-GUI-BUILD-OPTIONS
$(QUIET_INDEX)$(SHELL_PATH) -x generate-tclindex.sh . ./GIT-GUI-BUILD-OPTIONS $(ALL_LIBFILES)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-x is left over from debugging and not intended to remain, I assume?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, indeed, good catch.

@j6t
Copy link
Owner

j6t commented May 11, 2025

Have to stop for today. Still need to go through the last 4 commits.

pks-t added 10 commits May 12, 2025 11:25
The GIT-GUI-VARS file is used to track whether any of our build options
has changed. Unfortunately, the format of that file does not allow us to
propagate those build options to other scripts. But as we are about to
introduce support for the Meson build system, we will extract a couple
of scripts to deduplicate core build logic across Makefiles and Meson.
With this refactoring, it will become necessary to make build options
more widely accessible.

Replace GIT-GUI-VARS with a new GIT-GUI-BUILD-OPTIONS file that is being
populated from a template. This file can easily be sourced from build
scripts in subsequent steps.

Signed-off-by: Patrick Steinhardt <[email protected]>
The GIT-VERSION-GEN unconditionally writes version information into the
source directory in the form of the "GIT-VERSION-FILE". We are about to
introduce the Meson build system though, which enforces out-of-tree
builds by default, and in that context we cannot continue to write
version information into the source tree.

Prepare the script for out-of-tree builds by treating the source
directory different from the output file.

Signed-off-by: Patrick Steinhardt <[email protected]>
The output of GIT-VERSION-GEN can be sourced by our Makefile to make the
version available there. The output has a couple of spaces around the
equals sign, which is perfectly valid for parsing it in our Makefile.
But in subsequent steps we'll also want to source the file in a couple
of newly-introduced shell scripts, but having spaces around variable
assignments is invalid there.

Prepare for this step by dropping the spaces surrounding the equals
sign. Like this, we can easily use the same file both in our Makefile
and in shell scripts.

Signed-off-by: Patrick Steinhardt <[email protected]>
The value of the GITGUI_SCRIPT variable is only used in a single place
as part of an sed(1) script that massages the "git-gui.sh" script.
Interestingly, this specific replacement does seem to be a no-op: we
replace "^ argv0=$$0" with " argv=$(GITGUI_SCRIPT)", which has a value
of "$$0". The result would thus be completely unchanged.

Drop the replacement and its variable.

Signed-off-by: Patrick Steinhardt <[email protected]>
Extract script to generate "git-gui". This change allows us to reuse the
build logic with the Meson build system.

Signed-off-by: Patrick Steinhardt <[email protected]>
Extract script to generate "tclIndex". This change allows us to reuse
the build logic with the Meson build system.

Signed-off-by: Patrick Steinhardt <[email protected]>
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 <[email protected]>
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]>
The "GITGUI_VERSION" variable is made available by generating and
including the "GIT-VERSION-FILE" file. Its value has been used in
various build steps, but in the preceding commits we have refactored
those to instead source the "GIT-VERSION-FILE" directly. As a result,
the variable is now only used in a single recipe, and this use can be
trivially replaced with sed(1).

Refactor the recipe to do so and stop including "GIT-VERSION-FILE" to
simplify the build process.

Signed-off-by: Patrick Steinhardt <[email protected]>
The Git project has started to wire up Meson as a build system in Git
v2.48.0. Wire up support for Meson in "git-gui" so that we can trivially
include it as a subproject in Git.

Signed-off-by: Patrick Steinhardt <[email protected]>
@pks-t
Copy link
Author

pks-t commented May 12, 2025

If the problem is "the format of GIT-GUI-VARS does not allow us to propagate those build options to other scripts", why is this patch so much more than just "let's write it in a more usable format"? Why do we need a template file? What is the reason to rename the file?

There are multiple reasons:

  • It makes our life significantly easier with Meson, as we can then trivially use configure_file() to perform this operation.
  • Meson knows to warn about unreplaced variables, which gives us useful signal in case this ever were to break due to a new variable that we don't modify in Meson.
  • It makes it overall way more discoverable what variables we expect to exist.
  • It brings us in line with what downstream Git is using nowadays for a bit more consistency.

@pks-t pks-t force-pushed the pks-meson-support branch from c6b6131 to acd8451 Compare May 12, 2025 09:32
@pks-t pks-t requested a review from j6t May 12, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants