Skip to content
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

Meson: Add support for Meson build system #675

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

Conversation

kakurasan
Copy link
Contributor

@kakurasan kakurasan commented Oct 8, 2018

The changes in this PR add support for Meson build system.

Benefits

  • Build time will be reduced
  • No need to run bootstrap script
  • intltool is not needed, instead, recent gettext tools (msgfmt and xgettext) can handle *.appdata.xml.in and *.desktop.in files

Dependencies

  • Python 3.5 or later
  • gettext 0.19.7 or later
  • Meson 0.47.0 or later
  • Ninja 1.5 or later

How to build / install with Meson

(Configure)
$ meson ([options...]) [builddir]

(Reconfigure or show config)
$ meson configure ([options...]) [builddir]

(Build)
$ ninja -C [builddir]

(Install)
$ sudo ninja -C [builddir] install
or
$ DESTDIR=/path/to/destdir ninja -C [builddir] install

Project options

Name Value Description
nls auto,enabled,disabled NLS support
drm auto,enabled,disabled DRM method
randr auto,enabled,disabled RANDR method
vidmode auto,enabled,disabled VidMode method
quartz auto,enabled,disabled Quartz (macOS) method
wingdi auto,enabled,disabled WinGDI method
corelocation auto,enabled,disabled CoreLocation (macOS) provider
geoclue2 auto,enabled,disabled Geoclue2 provider
gui auto,enabled,disabled GUI status icon
ubuntu auto,enabled,disabled Ubuntu icons
apparmor auto,enabled,disabled AppArmor profile
systemduserunitdir Path to directory,auto,disabled Directory for systemd user unit files

See also meson_options.txt.

Meson automatically detects method/provider related libraries and enables them if available.

Example (disable VidMode method + enable Ubuntu icons):

$ meson --prefix=/usr -Dvidmode=disabled -Dubuntu=enabled _build

How to update .pot file and .po files

Update redshift.pot:

$ ninja -C [builddir] redshift-pot

Update redshift.pot and *.po:

$ ninja -C [builddir] redshift-update-po

How to create dist (source .tar.xz) file in git tree

$ ninja -C [builddir] dist

[builddir]/meson-dist/redshift-[version].tar.xz will be created.

Issues and notes

  • A new translatable string redshift comes from Icon=redshift in data/applications/*.desktop.in files: Icon= is actually translatable, see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
  • Some existing *.in files (appdata, desktop) are not compatible with "Meson + gettext"
    • We can extract translatable strings and merge translations with "Meson + gettext 0.19.7 or later", however, the expected file formats (appdata XML and Desktop template) are different from existing files (for intltool).
    • Some meson_*.in files that match the expected formats were added. They are not compatible with intltool.
    • We can replace existing *.in files (for intltool) with the added files when dropping autotools-based build system in the future.
  • Travis CI
    • Python, Ninja, and gettext are too old on Ubuntu Trusty.
      • We use Ubuntu Xenial to use newer gettext and Ninja
      • Python 3.7 is available without additional installation (as of Feb 2019): We use it (~/virtualenv/python3.7/bin/) directly.
  • AppVeyor
    • We download Ninja for Windows from https://github.com/mesonbuild/cidata repo that is maintained by Meson developer.
    • Meson can detect/use Microsoft compilers on Windows if calling vcvarsall.bat beforehand, but there are lots of MSVC-specific issues.
  • Unity build (meson --unity=on) failure
    • Both hooks.c and redshift.c have static variable period_names. It causes compilation error (error: redefinition of ‘period_names’).
  • Issues in Meson 0.48.0
    • Travis Ubuntu build fails: Fixed upstream, no release yet. Fixed in 0.48.1.
    • Target name related warnings: Fixed upstream, no release yet. Fixed in 0.49.0.
    • We can pin Meson version if pip3 is used (e.g. pip3 install meson==0.47.2).
    • We use Meson 0.49.2 (pip3 install meson==0.49.2).

@jonls jonls self-requested a review October 8, 2018 17:17
@jonls
Copy link
Owner

jonls commented Oct 20, 2018

@kakurasan Thanks for doing this! I was looking into meson earlier this year but I ran into a number of issues. My initial question looking at this is about keeping both the autotools build system and meson (it looks like you're keeping both and testing both on Travis and Appveyor). I think I'd want to completely replace autotools before adding meson. Maintaining two separate build systems in Redshift is going to be too much work. Would that be feasible at this point and is there anything stopping you from completely replacing autotools?

@kakurasan
Copy link
Contributor Author

Hello.

My initial question looking at this is about keeping both the autotools build system and meson (it looks like you're keeping both and testing both on Travis and Appveyor).

Some projects that have Meson support still support autotools (See the list in https://mesonbuild.com/Users.html, in some projects Meson is "not the default yet"). I guess they are in a period of transition (e.g. for testing).

I think I'd want to completely replace autotools before adding meson. Maintaining two separate build systems in Redshift is going to be too much work. Would that be feasible at this point and is there anything stopping you from completely replacing autotools?

Nothing else. It would be simpler and easy to maintain if dropping autotools. Redshift's tree is simple and already tested with Meson, so I think we can now replace unless we need transition period.

@kakurasan kakurasan force-pushed the add_meson_support branch 2 times, most recently from 8e08701 to 7addcb4 Compare October 22, 2018 14:28
redshift_libs += libredshift_common

executable('redshift',
redshift_sources,

Choose a reason for hiding this comment

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

dependencies : redshift_deps should be used here (in the executable) too, in order to avoid losing dependencies' include directories.

This doesn't affect anything as-is, but with #704 (Wayland support) on FreeBSD it would lose /usr/local/include from the include path and there's an error about not finding wayland-client.h when building redshift.c.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@myfreeweb You're right, I didn't test on FreeBSD but confirmed cflags for external libs were missing when compiling redshift.c (potential build issue) and dependencies : redshift_deps fixed it.
Thanks for your feedback!

@CameronNemo
Copy link
Contributor

What functionality does this offer that wasn't previously available?

@kakurasan
Copy link
Contributor Author

This PR doesn't add any functionalities to redshift itself. It only changes the build system for redshift.

@kakurasan kakurasan force-pushed the add_meson_support branch from fe1f046 to 7b78aa1 Compare June 14, 2020 05:42
# Check Geoclue2 location provider
gio_dep = dependency(
'gio-2.0', version : '>= 2.26', required : get_option('geoclue2'))
if gio_dep.found()
Copy link
Contributor

Choose a reason for hiding this comment

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

if the geoclue2 option is disabled, but the gio dependency is found, what happens? same for similar checks in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When -Dgeoclue2=disabled is specified, Geoclue2 support will be disabled and GIO will not be used (GIO is used only in Geoclue2 location provider).

  • The value of the geoclue2 option (type : feature) is auto in meson_options.txt: Geoclue2 support will be enabled only when GIO is detected
  • If -Dgeoclue2=enabled is specified and GIO is not found, an error will occur (build failure)

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.

4 participants