[vlc-devel] [PATCH 0/1] [RFC] Meson build system port

Marvin Scholz epirat07 at gmail.com
Thu Aug 1 12:08:46 CEST 2019

This patch is an early RFC for the Meson build system port for VLC,
it is not finished and some things might not work as expected yet but
I am sending this in order to get some Feedback before I continue porting
more modules and adding the missing things.

What currently does not work:
- Some modules are missing
- i18n (gettext and such)
- Windows store specifics
- Android specifics
- iOS specifics

It should build fine on Linux and macOS and cross-compiling for Windows using
mingw-w64 works mostly too.

To build with Meson, make sure you have Ninja installed and a very recent
version of Meson, at least 0.49.1 but preferably 0.50.1.
Then invoke meson, either in the source dir with the path to where you want
to build or in the build dir with the path to the source dir.
I will assume we are in the source dir and want to build in a directory named
"build". This does not need to exist, meson will create it.

  $ meson build

This will run the meson setup step which is similar to what the configure
script does. It runs all the setup-time checks and generated the ninja files
when done.

Now change to the build dir and run ninja:

  $ cd build
  $ ninja

Ninja will automatically do a parallel build if the system has multiple cores
and will be non-verbose by default. When a command fails it will print the
full failed command though, so running in non-verbose mode is usually never
an issue even for debugging failures. To see all commands ninja invokes,
run it with -v (for verbose).

Below are some note about Meson and why I did some things in the port in the
way I did them:

Build files:
Meson build definition files can be split across multiple subfolders, I've
did it mostly like we did it for the Makefile.am files as that makes sense
and makes the build definitions close to the source files.
As meson does not has separate configure/build definitions, it means that most
checks can be close to the actual definition of the module or library, 
executable, etc. The subdirs are included with the subdir() function.
Most of the "global" configuration I put in the main meson.build file, which
kind of mimics the configure.ac regarding the checks that are done.
Dependency detection is done as close as possible to where they are used.

Meson build definitions have not variable scope, so all variables are global.
While this makes it easy to write if/else branches without having to declare
a variable first, it can cause some trouble for variables that are not used
close to where they are defined. Thankfully thats not really a problem when
choosing a careful name and following some naming conventions.
The biggest case where variables are not used always close to where they are
defined are dependencies. Therefore I've chosen a naming sheme for depenencies
and libraries suffixing them with _dep or _lib (or plural forms for arrays
of those).

Meson finds most dependencies using pkg-config, libraries that have no
"automatic" way at all to find them can be found by querying the compiler
with cc.has_library. Care must the take for dependencies that are used
in multiple places with different version requirements, those may not be
queried for multiple times as meson will cache the first successfully found
dependency and use that for all following dependency() calls with the same
name regardless of the version. So the version needs to be explicitly checked
in that case before using the dependency.

Meson has a concept of disabler objects. These are most useful for libraries
or build features, as you can just turn a not-found library into an disabler
object and then all parts of the build that would use this library are disabled
then. As you can see I've not used disabler objects in my port so far, but
instead always explicitly check using if foo_dep.found() … endif.
I've done this as it is clearer to read but it is a lot of boilerplate so
dependening on the feedback I get about this, we could change it to use disabler
objects instead. (Another reason for not using them already was a bug in meson
with disabler objects in nested arrays but that one was fixed recently).

Please try it out and give me feedback about what you think!

Marvin Scholz (1):
  Meson: Add meson build system

 bin/meson.build                        |  33 ++
 compat/meson.build                     |  13 +
 config.h.meson                         | 638 +++++++++++++++++++++
 extras/buildsystem/gen-vlc-about.py    |  34 ++
 include/meson.build                    | 126 ++++
 lib/meson.build                        |  26 +
 meson.build                            | 759 +++++++++++++++++++++++++
 meson_options.txt                      | 333 +++++++++++
 modules/access/http/meson.build        |  93 +++
 modules/access/meson.build             | 182 ++++++
 modules/audio_filter/meson.build       | 215 +++++++
 modules/audio_mixer/meson.build        |  13 +
 modules/audio_output/meson.build       |  61 ++
 modules/codec/meson.build              | 584 +++++++++++++++++++
 modules/control/meson.build            |  49 ++
 modules/demux/meson.build              | 473 +++++++++++++++
 modules/gui/meson.build                |  30 +
 modules/gui/qt/meson.build             | 265 +++++++++
 modules/keystore/meson.build           |  47 ++
 modules/logger/meson.build             |  31 +
 modules/meson.build                    | 157 +++++
 modules/meta_engine/meson.build        |  15 +
 modules/misc/meson.build               | 160 ++++++
 modules/packetizer/meson.build         |  98 ++++
 modules/services_discovery/meson.build |  71 +++
 modules/text_renderer/meson.build      |  11 +
 modules/video_chroma/meson.build       |  20 +
 modules/video_filter/meson.build       |  25 +
 modules/video_output/meson.build       | 164 ++++++
 modules/video_splitter/meson.build     |  24 +
 modules/visualization/meson.build      |  29 +
 src/meson.build                        | 268 +++++++++
 src/revision.c.in                      |   2 +
 33 files changed, 5049 insertions(+)
 create mode 100644 bin/meson.build
 create mode 100644 compat/meson.build
 create mode 100644 config.h.meson
 create mode 100644 extras/buildsystem/gen-vlc-about.py
 create mode 100644 include/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 modules/access/http/meson.build
 create mode 100644 modules/access/meson.build
 create mode 100644 modules/audio_filter/meson.build
 create mode 100644 modules/audio_mixer/meson.build
 create mode 100644 modules/audio_output/meson.build
 create mode 100644 modules/codec/meson.build
 create mode 100644 modules/control/meson.build
 create mode 100644 modules/demux/meson.build
 create mode 100644 modules/gui/meson.build
 create mode 100644 modules/gui/qt/meson.build
 create mode 100644 modules/keystore/meson.build
 create mode 100644 modules/logger/meson.build
 create mode 100644 modules/meson.build
 create mode 100644 modules/meta_engine/meson.build
 create mode 100644 modules/misc/meson.build
 create mode 100644 modules/packetizer/meson.build
 create mode 100644 modules/services_discovery/meson.build
 create mode 100644 modules/text_renderer/meson.build
 create mode 100644 modules/video_chroma/meson.build
 create mode 100644 modules/video_filter/meson.build
 create mode 100644 modules/video_output/meson.build
 create mode 100644 modules/video_splitter/meson.build
 create mode 100644 modules/visualization/meson.build
 create mode 100644 src/meson.build
 create mode 100644 src/revision.c.in


More information about the vlc-devel mailing list