git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RFC v7 21/22] Introduce support for the Meson build system

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 15, 2024, 12:20 UTC
Message-ID
<CAP8UFD17rBAg6xYdA6BsNCgYtqBv_gijWj3EG_JZV+RL8ZaNnQ@mail.gmail.com>
In-Reply-To
<20241115-pks-meson-v7-21-47ec19b780b2@pks.im>
On Fri, Nov 15, 2024 at 8:21 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 25 quoted lines
> +# Basic usage
> +# ===========
> +#
> +# In the most trivial case, you can configure, build and install Git like this:
> +#
> +#  1. Set up the build directory. This only needs to happen once per build
> +#     directory you want to have. You can also configure multiple different
> +#     build directories with different configurations.
> +#
> +#      $ meson setup build/
> +#
> +#     The build directory gets ignored by Git automatically as Meson will write
> +#     a ".gitignore" file into it. From hereon, we will assume that you execute
> +#     commands inside this build directory.
> +#
> +# 2. Compile Git. You can either use Meson, Ninja or Samurai to do this, so all
> +#    of the following invocations are equivalent:
> +#
> +#      $ meson compile
> +#      $ ninja
> +#      $ samu
> +#
> +#   The different invocations should ultimately not make much of a difference.
> +#   Using Meson also works with other generators though, like when the build
> +#   directory has been set up for use with Microsoft Visual Studio.

I think it might be helpful to say if the above commands are using multiple processes in parallel (like `make -j 10` for example) to build or not. If they are using multiple processes, it might be useful to shortly say how the number of processes used is computed. If they are not using multiple processes, it might be interesting to say if an option exists for this or not, and if not, why.

If the above commands use ccache or can use it, or similar tools, it could be interesting to say so too.

Show 23 quoted lines
> +#
> +# 3. Execute tests. Again, you can either use Meson, Ninja or Samurai to do this:
> +#
> +#      $ meson test
> +#      $ ninja test
> +#      $ samu test
> +#
> +#   It is recommended to use Meson in this case though as it also provides you
> +#   additional features that the other build systems don't have available.
> +#   You can e.g. pass additional arguments to the test executables or run
> +#   individual tests:
> +#
> +#      # Execute the t0000-basic integration test and t-reftable-stack unit test.
> +#      $ meson test t0000-basic t-reftable-stack
> +#
> +#      # Execute all reftable unit tests.
> +#      $ meson test t-reftable-*
> +#
> +#      # Execute all tests and stop with the first failure.
> +#      $ meson test --maxfail 1
> +#
> +#      # Execute single test interactively such that features like `debug ()` work.
> +#      $ meson test -i --test-args='-ix' t1400-update-ref

How about executing tests in parallel? I am asking because it's an easy way to speed up test execution.

Show 14 quoted lines
> +# 4. Install the Git distribution. Again, this can be done via Meson, Ninja or
> +#    Samurai:
> +#
> +#      $ meson install
> +#      $ ninja install
> +#      $ samu install
> +#
> +#    The prefix into which Git shall be installed is defined when setting up
> +#    the build directory. More on that in the "Configuration" section.
> +#
> +# Meson supports multiple backends. The default backend generates Ninja build
> +# instructions, but it also supports the generation of Microsoft Visual
> +# Studio solutions as well as Xcode projects. IDEs like Eclipse and Visual
> +# Studio Code provide plugins to import Meson files directly.

So I guess it's not necessary to configure Meson to make it use a backend that generates VS Code or Xcode projects.

Show 22 quoted lines
> +# Configuration
> +# =============
> +#
> +# The exact configuration of Git is determined when setting up the build
> +# directory via `meson setup`. Unless told otherwise, Meson will automatically
> +# detect the availability of various bits and pieces. There are two different
> +# kinds of options that can be used to further tweak the build:
> +#
> +#   - Built-in options provided by Meson.
> +#
> +#   - Options defined by the project in the "meson_options.txt" file.
> +#
> +# Both kinds of options can be inspected by running `meson configure` in the
> +# build directory, which will give you a list of the current value for all
> +# options.
> +#
> +# Options can be configured either when setting up the build directory or can
> +# be changed in preexisting build directories:
> +#
> +#      # Set up a new build directory with optimized settings that will be
> +#      # installed into an alternative prefix.
> +#      $ meson setup --buildtype release --optimization 3 --strip --prefix=/home/$USER build

"build" is the name that was already given to the build directory above in this doc, so it might be better to use something else, like maybe "build-optimized/".

> +#      # Set up a new build directory with a higher warning level. Level 2 is
> +#      # mostly equivalent to setting DEVELOPER=1, level 3 and "everything"
> +#      # will enable even more warnings.
> +#      $ meson setup -Dwarning_level=2

There is no name for the new build directory in the above command, maybe something like "build-warning/" should be added.

> +#      # Set up a new build directory with 'address' and 'undefined' sanitizers
> +#      # using Clang.
> +#      $ CC=clang meson setup -Db_sanitize=address,undefined build
Maybe "build-address/" instead of "build".
> +#      # Disable tests in a preexisting build directory.
> +#      $ meson configure -Dtests=false
What happens if we run `meson test` then?
Show 12 quoted lines
> +#      # Disable features based on Python
> +#      $ meson configure -Dpython=disabled
> +#
> +# Options have a type like booleans, choices, strings or features. Features are
> +# somewhat special as they can have one of three values: enabled, disabled or
> +# auto. While the first two values are self-explanatory, "auto" will enable or
> +# disable the feature based on the availability of prerequisites to support it.
> +# Python-based features for example will be enabled automatically when a Python
> +# interpreter could be found. The default value of such features can be changed
> +# globally via `meson setup --auto-features={enabled,disabled,auto}`, which
> +# will set the value of all features with a value of "auto" to the provided one
> +# by default.

"globally" here means for all the builds directories of the current system user, or for all the build directories inside the directory where `meson setup --auto-features={enabled,disabled,auto}` was run, or just for all the features in the current build directory if this is run inside a build directory?

Show 16 quoted lines
> +# It is also possible to store a set of configuration options in machine files.
> +# This can be useful in case you regularly want to reuse the same set of options:
> +#
> +#   [binaries]
> +#   c = ['clang']
> +#   ar = ['ar']
> +#
> +#   [project options]
> +#   gettext = 'disabled'
> +#   default_editor = 'vim'
> +#
> +#   [built-in options]
> +#   b_lto = true
> +#   b_sanitize = 'address,undefined'
> +#
> +# These machine files can be passed to Meson via `meson setup --native-file`.

I think it might be helpful to say that "machine files" is the name used by meson for basically "config files".

Also it's not very clear which build directories will be impacted when `meson setup --native-file my-machine-file` is run.

> +# Subproject wrappers
> +# ===================
> +#
> +# Subproject wrappers are a feature provided by Meson that allow the automatic
s/allow/allows/
Show 8 quoted lines
> +# fallback to a "wrapped" dependency in case the dependency is not provided by
> +# the system. For example if the system is lacking curl, then Meson will use
> +# "subprojects/curl.wrap" to set up curl as a subproject and compile and link
> +# the dependency into Git itself. This is especially helpful on systems like
> +# Windows, where you typically don't have such dependencies installed.
> +#
> +# The use of subproject wrappers can be disabled by executing `meson setup
> +# --wrap-mode nofallback`.
It's not very clear which build directories will be impacted by this command.
Thanks.
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 23 of 31 in “Modernize the build system”
  1. 00/22 Modernize the build systemPatrick Steinhardt, Nov 15, 2024
  2. 01/22 Makefile: use common template for GIT-BUILD-OPTIONSPatrick Steinhardt, Nov 15, 2024
  3. 02/22 Makefile: consistently use @PLACEHOLDER@ to substitutePatrick Steinhardt, Nov 15, 2024
  4. 03/22 Makefile: refactor GIT-VERSION-GEN to be reusablePatrick Steinhardt, Nov 15, 2024
  5. 04/22 Makefile: propagate Git version via generated headerPatrick Steinhardt, Nov 15, 2024
  6. 05/22 Makefile: generate "git.rc" via GIT-VERSION-GENPatrick Steinhardt, Nov 15, 2024
  7. 06/22 Makefile: consistently use PERL_PATHPatrick Steinhardt, Nov 15, 2024
  8. 07/22 Makefile: extract script to massage Perl scriptsPatrick Steinhardt, Nov 15, 2024
  9. 08/22 Makefile: use "generate-perl.sh" to massage Perl libraryPatrick Steinhardt, Nov 15, 2024
  10. 10/22 Makefile: extract script to generate gitweb.cgiPatrick Steinhardt, Nov 15, 2024
  11. 09/22 Makefile: extract script to massage Shell scriptsPatrick Steinhardt, Nov 15, 2024
  12. 11/22 Makefile: extract script to generate gitweb.jsPatrick Steinhardt, Nov 15, 2024
  13. 12/22 Makefile: refactor generators to be PWD-independentPatrick Steinhardt, Nov 15, 2024
  14. 13/22 Makefile: allow "bin-wrappers/" directory to existPatrick Steinhardt, Nov 15, 2024
  15. 14/22 Makefile: simplify building of templatesPatrick Steinhardt, Nov 15, 2024
  16. 16/22 Documentation: teach "cmd-list.perl" about out-of-tree buildsPatrick Steinhardt, Nov 15, 2024
  17. 15/22 Documentation: allow sourcing generated includes from separate dirPatrick Steinhardt, Nov 15, 2024
  18. 17/22 Documentation: extract script to generate a list of mergetoolsPatrick Steinhardt, Nov 15, 2024
  19. 19/22 t: allow overriding build dirPatrick Steinhardt, Nov 15, 2024
  20. 18/22 t: better support for out-of-tree buildsPatrick Steinhardt, Nov 15, 2024
  21. 20/22 Documentation: add comparison of build systemsPatrick Steinhardt, Nov 15, 2024
  22. 21/22 Introduce support for the Meson build systemPatrick Steinhardt, Nov 15, 2024
  23. Christian CouderNov 15, 2024
  24. Patrick SteinhardtNov 18, 2024
  25. 22/22 meson: fix conflicts with in-flight topicsPatrick Steinhardt, Nov 15, 2024
  26. Patrick SteinhardtNov 15, 2024
  27. Ramsay JonesNov 16, 2024
  28. Patrick SteinhardtNov 18, 2024
  29. Junio C HamanoNov 18, 2024
  30. Patrick SteinhardtNov 18, 2024
  31. Junio C HamanoNov 18, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.