Merge pull request #3452 from emersion/meson-features

Use Meson feature options
This commit is contained in:
Drew DeVault 2019-01-18 15:39:07 -05:00 committed by GitHub
commit 639b66b676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 44 deletions

View file

@ -2,6 +2,7 @@ project(
'sway', 'sway',
'c', 'c',
license: 'MIT', license: 'MIT',
meson_version: '>=0.48.0',
default_options: [ default_options: [
'c_std=c11', 'c_std=c11',
'warning_level=2', 'warning_level=2',
@ -45,37 +46,39 @@ xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo') cairo = dependency('cairo')
pango = dependency('pango') pango = dependency('pango')
pangocairo = dependency('pangocairo') pangocairo = dependency('pangocairo')
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: false) gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
libevdev = dependency('libevdev') libevdev = dependency('libevdev')
libinput = dependency('libinput', version: '>=1.6.0') libinput = dependency('libinput', version: '>=1.6.0')
libpam = cc.find_library('pam', required: false)
crypt = cc.find_library('crypt', required: false)
systemd = dependency('libsystemd', required: false) systemd = dependency('libsystemd', required: false)
elogind = dependency('libelogind', required: false) elogind = dependency('libelogind', required: false)
xcb = dependency('xcb', required: get_option('xwayland'))
math = cc.find_library('m') math = cc.find_library('m')
rt = cc.find_library('rt') rt = cc.find_library('rt')
git = find_program('git', required: false) git = find_program('git', required: false)
have_xwayland = xcb.found()
tray_deps_found = systemd.found() or elogind.found()
if get_option('tray').enabled() and not tray_deps_found
error('Building with -Dtray=enabled, but libsystemd and libelogind have not been not found')
endif
have_tray = (not get_option('tray').disabled()) and tray_deps_found
conf_data = configuration_data() conf_data = configuration_data()
conf_data.set10('HAVE_XWAYLAND', get_option('enable-xwayland')) conf_data.set10('HAVE_XWAYLAND', have_xwayland)
if get_option('enable-xwayland')
xcb = dependency('xcb')
endif
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found()) conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
conf_data.set10('HAVE_SYSTEMD', systemd.found()) conf_data.set10('HAVE_SYSTEMD', systemd.found())
conf_data.set10('HAVE_ELOGIND', elogind.found()) conf_data.set10('HAVE_ELOGIND', elogind.found())
conf_data.set10('HAVE_TRAY', get_option('enable-tray') and (systemd.found() or elogind.found())) conf_data.set10('HAVE_TRAY', have_tray)
if not systemd.found() and not elogind.found() if not systemd.found() and not elogind.found()
warning('The sway binary must be setuid when compiled without (e)logind') warning('The sway binary must be setuid when compiled without (e)logind')
warning('You must do this manually post-install: chmod a+s /path/to/sway') warning('You must do this manually post-install: chmod a+s /path/to/sway')
endif endif
scdoc = find_program('scdoc', required: false) scdoc = find_program('scdoc', required: get_option('man-pages'))
if scdoc.found() if scdoc.found()
sh = find_program('sh') sh = find_program('sh')
mandir = get_option('mandir') mandir = get_option('mandir')
@ -123,17 +126,6 @@ else
endif endif
add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
if get_option('use_rpath')
if get_option('custom_rpath') == ''
# default to platform specific libdir, one level up from the binary
rpathdir = join_paths('$ORIGIN', '..', '$LIB')
else
rpathdir = get_option('custom_rpath')
endif
else
rpathdir = ''
endif
sway_inc = include_directories('include') sway_inc = include_directories('include')
subdir('include') subdir('include')
@ -180,7 +172,7 @@ install_data(
install_dir: datadir + '/wayland-sessions' install_dir: datadir + '/wayland-sessions'
) )
if (get_option('default-wallpaper')) if get_option('default-wallpaper')
wallpaper_files = files( wallpaper_files = files(
'assets/Sway_Wallpaper_Blue_768x1024.png', 'assets/Sway_Wallpaper_Blue_768x1024.png',
'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png', 'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png',
@ -196,7 +188,7 @@ if (get_option('default-wallpaper'))
install_data(wallpaper_files, install_dir: wallpaper_install_dir) install_data(wallpaper_files, install_dir: wallpaper_install_dir)
endif endif
if (get_option('zsh-completions')) if get_option('zsh-completions')
zsh_files = files( zsh_files = files(
'completions/zsh/_sway', 'completions/zsh/_sway',
'completions/zsh/_swaymsg', 'completions/zsh/_swaymsg',
@ -206,7 +198,7 @@ if (get_option('zsh-completions'))
install_data(zsh_files, install_dir: zsh_install_dir) install_data(zsh_files, install_dir: zsh_install_dir)
endif endif
if (get_option('bash-completions')) if get_option('bash-completions')
bash_files = files( bash_files = files(
'completions/bash/sway', 'completions/bash/sway',
'completions/bash/swaybar', 'completions/bash/swaybar',
@ -217,7 +209,7 @@ if (get_option('bash-completions'))
install_data(bash_files, install_dir: bash_install_dir) install_data(bash_files, install_dir: bash_install_dir)
endif endif
if (get_option('fish-completions')) if get_option('fish-completions')
fish_files = files( fish_files = files(
'completions/fish/sway.fish', 'completions/fish/sway.fish',
'completions/fish/swaymsg.fish', 'completions/fish/swaymsg.fish',

View file

@ -1,9 +1,9 @@
option('sway-version', type : 'string', description: 'The version string reported in `sway --version`.') option('sway-version', type : 'string', description: 'The version string reported in `sway --version`.')
option('use_rpath', type: 'boolean', value: false, description: 'install binaries with rpath set')
option('custom_rpath', type: 'string', value: '', description: 'override rpath with a custom one')
option('default-wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.') option('default-wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.')
option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.') option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.') option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.') option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support for X11 applications') option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
option('enable-tray', type: 'boolean', value: false, description: 'Enable support for swaybar tray') option('tray', type: 'feature', value: 'auto', description: 'Enable support for swaybar tray')
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg')
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')

View file

@ -194,7 +194,7 @@ sway_deps = [
xkbcommon, xkbcommon,
] ]
if get_option('enable-xwayland') if have_xwayland
sway_sources += 'desktop/xwayland.c' sway_sources += 'desktop/xwayland.c'
sway_deps += xcb sway_deps += xcb
endif endif
@ -205,6 +205,5 @@ executable(
include_directories: [sway_inc], include_directories: [sway_inc],
dependencies: sway_deps, dependencies: sway_deps,
link_with: [lib_sway_common], link_with: [lib_sway_common],
install_rpath : rpathdir,
install: true install: true
) )

View file

@ -1,4 +1,4 @@
tray_files = get_option('enable-tray') ? [ tray_files = have_tray ? [
'tray/host.c', 'tray/host.c',
'tray/icon.c', 'tray/icon.c',
'tray/item.c', 'tray/item.c',
@ -19,7 +19,7 @@ swaybar_deps = [
wayland_cursor, wayland_cursor,
wlroots, wlroots,
] ]
if get_option('enable-tray') if have_tray
if systemd.found() if systemd.found()
swaybar_deps += systemd swaybar_deps += systemd
elif elogind.found() elif elogind.found()
@ -42,6 +42,5 @@ executable(
include_directories: [sway_inc], include_directories: [sway_inc],
dependencies: swaybar_deps, dependencies: swaybar_deps,
link_with: [lib_sway_common, lib_sway_client], link_with: [lib_sway_common, lib_sway_client],
install_rpath : rpathdir,
install: true install: true
) )

View file

@ -14,6 +14,5 @@ executable(
wlroots, wlroots,
], ],
link_with: [lib_sway_common, lib_sway_client], link_with: [lib_sway_common, lib_sway_client],
install_rpath : rpathdir,
install: true install: true
) )

View file

@ -1,9 +1,8 @@
executable( executable(
'swaymsg', 'swaymsg',
'main.c', 'main.c',
include_directories: [sway_inc], include_directories: [sway_inc],
dependencies: [jsonc, wlroots], dependencies: [jsonc, wlroots],
link_with: [lib_sway_common], link_with: [lib_sway_common],
install_rpath : rpathdir, install: true
install: true
) )

View file

@ -19,6 +19,5 @@ executable(
wlroots, wlroots,
], ],
link_with: [lib_sway_common, lib_sway_client], link_with: [lib_sway_common, lib_sway_client],
install_rpath : rpathdir,
install: true install: true
) )