-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
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. |
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! |
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. |
There was a problem hiding this 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= |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; \ |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, indeed, good catch.
Have to stop for today. Still need to go through the last 4 commits. |
There are multiple reasons:
|
Makefile
Outdated
@@ -322,7 +318,7 @@ dist-version: | |||
|
|||
clean:: | |||
$(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE) | |||
$(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS | |||
$(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS GIT-GUI-BUILD-OPTIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also cleans up GIT-GUI-VARS
, which is not used anymore. It was not in the earlier round. Is this a deliberate decision or a glitched conflict resolution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter. Fixed now.
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 <ps@pks.im>
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 <ps@pks.im>
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 <ps@pks.im>
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 <ps@pks.im>
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 <ps@pks.im>
Extract script to generate "tclIndex". This change allows us to reuse the build logic with the Meson build system. Signed-off-by: Patrick Steinhardt <ps@pks.im>
generate-macos-wrapper.sh
Outdated
echo 'git-gui version $GITGUI_VERSION' | ||
else | ||
libdir="\${GIT_GUI_LIB_DIR:-$GITGUI_LIBDIR}" | ||
exec "\$libdir/Git Gui.app/Contents/MacOS/$TKEXECUTABLE" "\$0" "\$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have quite a few levels of quoting here. The values of $GITGUI_LIBDIR
and $TKEXECUTABLE
are taken from the file $BUILD_OPTIONS
, but are not protected against meta-characters that could be interpreted as part of the shell syntax.
I suggest to construct the file by including the contents of $BUILD_OPTIONS
and $VERSION_FILE
:
(
echo "#!$SHELL_PATH"
cat "$BUILD_OPTIONS" "$VERSION_FILE" - <<-'EOF'
... rest as above without the extra quoting plus dq around "$GITGUI_VERSION"
EOF
) >"$OUTPUT"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That reads much better indeed, thanks!
generate-macos-app.sh
Outdated
-e "s|@@gitexecdir@@|$GITGUI_GITEXECDIR|" \ | ||
-e "s|@@GITGUI_LIBDIR@@|$GITGUI_LIBDIR|" \ | ||
"$SOURCE_DIR/macosx/AppMain.tcl" \ | ||
>"$OUTPUT"+/Contents/Resources/Scripts/AppMain.tcl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not worth a reroll by itself, but everywhere else double-quotes surround the entire word "$OUTPUT+/more/stuff"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, as well.
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>
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>
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 <ps@pks.im>
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 <ps@pks.im>
This round looks good. I tested the scripts in a basic fashion, and they look good. I don't have MacOS to test, but I think that the transcription of the old Makefile instructions are faithful. I haven't tested the meson build, though. Do you want this version pulled into upstream Git early (before 2.50)? |
I did, for all I can see it works alright :) Same caveat though, I didn't test on macOS.
This isn't time critical in any way, so I'll let you decide when you create the upstream pull request. Thanks for your review! |
Similar to the recent MR in
gitk
, this patch series wires up support for Meson ingit-gui
. Once landed, I'll send a patch series to Git to wire up both of these over there.