Commit 8011b0fa authored by Daniel Stone's avatar Daniel Stone Committed by Pekka Paalanen

Add Meson build system

Meson is a build system, currently implemented in Python, with multiple
output backends, including Ninja and Make. The build file syntax is
clean and easy to read unlike autotools. In practise, configuring and
building with Meson and Ninja has been observed to be much faster than
with autotools. Also cross-building support is excellent.

More information at http://mesonbuild.com

Since moving to Meson requires some changes from users in any case, we
took this opportunity to revamp build options. Most of the build options
still exist, some have changed names or more, and a few have been
dropped. The option to choose the Cairo flavour is not implemented since
for the longest time the Cairo image backend has been the only
recommended one.

This Meson build should be fully functional and it installs everything
an all-enabled autotools build does. Installed pkg-config files have
some minor differences that should be insignificant. Building of some
developer documentation that was never installed with autotools is
missing.

It is expected that the autotools build system will be removed soon
after the next Weston release.
Signed-off-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
Co-authored-by: Pekka Paalanen's avatarPekka Paalanen <pq@iki.fi>
Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pq@iki.fi>
parent ed75c89f
if get_option('resize-pool')
config_h.set('USE_RESIZE_POOL', '1')
endif
srcs_toytoolkit = [
'window.c',
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
text_cursor_position_client_protocol_h,
text_cursor_position_protocol_c,
relative_pointer_unstable_v1_client_protocol_h,
relative_pointer_unstable_v1_protocol_c,
pointer_constraints_unstable_v1_client_protocol_h,
pointer_constraints_unstable_v1_protocol_c,
ivi_application_client_protocol_h,
ivi_application_protocol_c,
]
deps_toytoolkit = [
dep_wayland_client,
dep_lib_cairo_shared,
dep_xkbcommon,
dependency('wayland-cursor'),
cc.find_library('util'),
]
lib_toytoolkit = static_library(
'toytoolkit',
srcs_toytoolkit,
include_directories: include_directories('..', '../shared'),
dependencies: deps_toytoolkit,
install: false,
)
dep_toytoolkit = declare_dependency(
link_with: lib_toytoolkit,
dependencies: deps_toytoolkit,
)
simple_clients = [
{
'name': 'damage',
'sources': [
'simple-damage.c',
viewporter_client_protocol_h,
viewporter_protocol_c,
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
],
'dep_objs': [ dep_wayland_client, dep_libshared ]
},
{
'name': 'dmabuf-v4l',
'sources': [
'simple-dmabuf-v4l.c',
linux_dmabuf_unstable_v1_client_protocol_h,
linux_dmabuf_unstable_v1_protocol_c,
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
],
'dep_objs': [ dep_wayland_client, dep_libdrm_headers ]
},
{
'name': 'egl',
'sources': [
'simple-egl.c',
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
ivi_application_client_protocol_h,
ivi_application_protocol_c,
],
'dep_objs': [ dep_wayland_client, dep_libshared, dep_libm ],
'deps': [ 'egl', 'wayland-egl', 'glesv2', 'wayland-cursor' ]
},
# weston-simple-im is handled specially separately due to install_dir and odd window.h usage
{
'name': 'shm',
'sources': [
'simple-shm.c',
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
ivi_application_client_protocol_h,
ivi_application_protocol_c,
],
'dep_objs': [ dep_wayland_client, dep_libshared ]
},
{
'name': 'touch',
'sources': [
'simple-touch.c',
],
'dep_objs': [ dep_wayland_client, dep_libshared ]
},
]
simple_clients_enabled = get_option('simple-clients')
simple_build_all = simple_clients_enabled.contains('all')
foreach t : simple_clients
if simple_build_all or simple_clients_enabled.contains(t.get('name'))
t_name = 'weston-simple-' + t.get('name')
t_deps = t.get('dep_objs', [])
foreach depname : t.get('deps', [])
dep = dependency(depname, required: false)
if not dep.found()
error('@0@ requires @1@ which was not found. If you rather not build this, drop "@2@" from simple-clients option.'.format(t_name, depname, t.get('name')))
endif
t_deps += dep
endforeach
executable(
t_name, t.get('sources'),
include_directories: include_directories('..'),
dependencies: t_deps,
install: true
)
endif
endforeach
if simple_build_all or simple_clients_enabled.contains('im')
executable(
'weston-simple-im', [
'simple-im.c',
input_method_unstable_v1_client_protocol_h,
input_method_unstable_v1_protocol_c,
],
include_directories: include_directories('..'),
dependencies: [
dep_libshared,
dep_wayland_client,
dep_xkbcommon,
dependency('wayland-cursor'),
dependency('cairo')
],
install: true,
install_dir: dir_libexec
)
endif
tools_enabled = get_option('tools')
tools_list = [
{
'name': 'calibrator',
'sources': [
'calibrator.c',
'../shared/matrix.c',
],
'deps': [ dep_toytoolkit ],
},
{
'name': 'debug',
'sources': [
'weston-debug.c',
weston_debug_client_protocol_h,
weston_debug_protocol_c,
],
'deps': [ dep_wayland_client ]
},
{
'name': 'info',
'sources': [
'weston-info.c',
presentation_time_client_protocol_h,
presentation_time_protocol_c,
linux_dmabuf_unstable_v1_client_protocol_h,
linux_dmabuf_unstable_v1_protocol_c,
tablet_unstable_v2_client_protocol_h,
tablet_unstable_v2_protocol_c,
xdg_output_unstable_v1_client_protocol_h,
xdg_output_unstable_v1_protocol_c,
],
'deps': [ dep_wayland_client, dep_libshared ]
},
{
'name': 'terminal',
'sources': [ 'terminal.c' ],
'deps': [ dep_toytoolkit ],
},
{
'name': 'touch-calibrator',
'sources': [
'touch-calibrator.c',
'../shared/matrix.c',
weston_touch_calibration_client_protocol_h,
weston_touch_calibration_protocol_c,
],
'deps': [ dep_toytoolkit ],
},
]
foreach t : tools_list
if tools_enabled.contains(t.get('name'))
executable(
'weston-@0@'.format(t.get('name')),
t.get('sources'),
include_directories: include_directories('..', '../shared'),
dependencies: t.get('deps', []),
install: true
)
endif
endforeach
demo_clients = [
{ 'basename': 'clickdot' },
{
'basename': 'cliptest',
'add_sources': [ '../libweston/vertex-clipping.c' ]
},
{ 'basename': 'confine' },
{ 'basename': 'dnd' },
{
'basename': 'editor',
'add_sources': [
text_input_unstable_v1_client_protocol_h,
text_input_unstable_v1_protocol_c,
],
'add_deps': [ dependency('pangocairo') ]
},
{ 'basename': 'eventdemo' },
{ 'basename': 'flower' },
{
'basename': 'fullscreen',
'add_sources': [
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
]
},
{ 'basename': 'image' },
{ 'basename': 'multi-resource' },
{
'basename': 'presentation-shm',
'add_sources': [
presentation_time_client_protocol_h,
presentation_time_protocol_c,
]
},
{ 'basename': 'resizor' },
{
'basename': 'scaler',
'add_sources': [
viewporter_client_protocol_h,
viewporter_protocol_c,
]
},
{ 'basename': 'smoke' },
{ 'basename': 'stacking' },
{
'basename': 'subsurfaces',
'add_deps': [ dep_egl, dep_glesv2, dep_wl_egl ]
},
{ 'basename': 'transformed' },
]
if get_option('demo-clients')
foreach t : demo_clients
t_name = 'weston-' + t.get('basename')
t_srcs = [ t.get('basename') + '.c' ] + t.get('add_sources', [])
t_deps = [ dep_toytoolkit ] + t.get('add_deps', [])
executable(
t_name, t_srcs,
include_directories: include_directories('..', '../shared'),
dependencies: t_deps,
install: true
)
endforeach
endif
simple_dmabuf_drm_opts = get_option('simple-dmabuf-drm')
simple_dmabuf_drm_deps = []
foreach driver : [ 'etnaviv', 'intel', 'freedreno' ]
if simple_dmabuf_drm_opts.contains(driver)
required = true
enabled = true
elif simple_dmabuf_drm_opts.contains('auto')
required = get_option('auto_features').enabled()
enabled = not get_option('auto_features').disabled()
else
enabled = false
endif
if enabled
dep = dependency('libdrm_' + driver, required: required)
if dep.found()
simple_dmabuf_drm_deps += dep
config_h.set('HAVE_LIBDRM_' + driver.to_upper(), 1)
endif
endif
endforeach
if simple_dmabuf_drm_deps.length() > 0
executable(
'weston-simple-dmabuf-drm',
'simple-dmabuf-drm.c',
xdg_shell_unstable_v6_client_protocol_h,
xdg_shell_unstable_v6_protocol_c,
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
linux_dmabuf_unstable_v1_client_protocol_h,
linux_dmabuf_unstable_v1_protocol_c,
include_directories: include_directories('..'),
dependencies: [
dep_wayland_client,
dep_libdrm,
simple_dmabuf_drm_deps
],
install: true
)
endif
if get_option('shell-desktop')
exe_keyboard = executable(
'weston-keyboard',
'keyboard.c',
text_input_unstable_v1_client_protocol_h,
text_input_unstable_v1_protocol_c,
input_method_unstable_v1_client_protocol_h,
input_method_unstable_v1_protocol_c,
include_directories: include_directories('..'),
dependencies: dep_toytoolkit,
install_dir: get_option('libexecdir'),
install: true
)
env_modmap += 'weston-keyboard=@0@;'.format(exe_keyboard.full_path())
exe_shooter = executable(
'weston-screenshooter',
'screenshot.c',
weston_screenshooter_client_protocol_h,
weston_screenshooter_protocol_c,
include_directories: include_directories('..'),
dependencies: dep_toytoolkit,
install_dir: get_option('libexecdir'),
install: true
)
env_modmap += 'weston-screenshooter=@0@;'.format(exe_shooter.full_path())
exe_shell_desktop = executable(
'weston-desktop-shell',
'desktop-shell.c',
weston_desktop_shell_client_protocol_h,
weston_desktop_shell_protocol_c,
include_directories: include_directories('..'),
dependencies: dep_toytoolkit,
install_dir: get_option('libexecdir'),
install: true
)
env_modmap += 'weston-desktop-shell=@0@;'.format(exe_shell_desktop.full_path())
endif
if get_option('shell-ivi')
exe_shell_ivi_ui = executable(
'weston-ivi-shell-user-interface',
'ivi-shell-user-interface.c',
ivi_hmi_controller_client_protocol_h,
ivi_hmi_controller_protocol_c,
ivi_application_client_protocol_h,
ivi_application_protocol_c,
include_directories: include_directories('..'),
dependencies: dep_toytoolkit,
install: true,
install_dir: get_option('libexecdir')
)
env_modmap += 'weston-ivi-shell-user-interface=@0@;'.format(exe_shell_ivi_ui.full_path())
endif
srcs_weston = [
git_version_h,
'main.c',
'text-backend.c',
'weston-screenshooter.c',
text_input_unstable_v1_server_protocol_h,
text_input_unstable_v1_protocol_c,
input_method_unstable_v1_server_protocol_h,
input_method_unstable_v1_protocol_c,
weston_screenshooter_server_protocol_h,
weston_screenshooter_protocol_c,
]
deps_weston = [
dep_libshared,
dep_libweston,
dep_libinput,
dep_libdl,
dep_threads,
]
if get_option('xwayland')
srcs_weston += 'xwayland.c'
config_h.set_quoted('XSERVER_PATH', get_option('xwayland-path'))
endif
exe_weston = executable(
'weston',
srcs_weston,
include_directories: include_directories('..', '../shared'),
link_args: [ '-export-dynamic' ],
dependencies: deps_weston,
install: true
)
install_headers('weston.h', subdir: 'weston')
pkgconfig.generate(
filebase: 'weston',
name: 'Weston Plugin API',
version: version_weston,
description: 'Header files for Weston plugin development',
requires_private: [ lib_weston ],
variables: [
'libexecdir=' + join_paths('${prefix}', get_option('libexecdir')),
'pkglibexecdir=${libexecdir}/weston'
],
subdirs: 'weston'
)
install_data(
'weston.desktop',
install_dir: join_paths(dir_data, 'wayland-sessions')
)
if get_option('screenshare')
srcs_screenshare = [
'screen-share.c',
fullscreen_shell_unstable_v1_client_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
]
deps_screenshare = [
dep_libweston,
dep_wayland_client,
]
plugin_screenshare = shared_library(
'screen-share',
srcs_screenshare,
include_directories: include_directories('..', '../shared'),
dependencies: deps_screenshare,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'screen-share.so=@0@;'.format(plugin_screenshare.full_path())
endif
if get_option('color-management-lcms')
config_h.set('HAVE_LCMS', '1')
srcs_lcms = [
'cms-static.c',
'cms-helper.c',
]
deps_lcms = [
dep_libweston,
dependency('lcms2'),
]
plugin_lcms = shared_library(
'cms-static',
srcs_lcms,
include_directories: include_directories('..', '../shared'),
dependencies: deps_lcms,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'cms-static.so=@0@;'.format(plugin_lcms.full_path())
endif
if get_option('color-management-colord')
if not get_option('color-management-lcms')
error('LCMS must be enabled to support colord')
endif
srcs_colord = [
'cms-colord.c',
'cms-helper.c',
]
deps_colord = [
dep_libweston,
dependency('colord', version: '>= 0.1.27')
]
plugin_colord = shared_library(
'cms-colord',
srcs_colord,
include_directories: include_directories('..', '../shared'),
dependencies: deps_colord,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'cms-colord.so=@0@;'.format(plugin_colord.full_path())
endif
if get_option('systemd')
plugin_systemd_notify = shared_library(
'systemd-notify',
'systemd-notify.c',
include_directories: include_directories('..', '../shared'),
dependencies: [ dep_libweston, dependency('libsystemd') ],
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'systemd-notify.so=@0@;'.format(plugin_systemd_notify.full_path())
endif
weston_ini_config = configuration_data()
weston_ini_config.set('bindir', dir_bin)
weston_ini_config.set('libexecdir', dir_libexec)
weston_ini_config.set('abs_top_srcdir', meson.source_root())
weston_ini_config.set('abs_top_builddir', meson.build_root())
configure_file(
input: '../weston.ini.in',
output: 'weston.ini',
configuration: weston_ini_config
)
install_data(
[
'background.png',
'border.png',
'fullscreen.png',
'home.png',
'icon_editor.png',
'icon_flower.png',
'icon_ivi_clickdot.png',
'icon_ivi_flower.png',
'icon_ivi_simple-egl.png',
'icon_ivi_simple-shm.png',
'icon_ivi_smoke.png',
'icon_terminal.png',
'icon_window.png',
'panel.png',
'pattern.png',
'random.png',
'sidebyside.png',
'sign_close.png',
'sign_maximize.png',
'sign_minimize.png',
'terminal.png',
'tiling.png',
'wayland.png',
'wayland.svg',
],
install_dir: join_paths(dir_data, 'weston')
)
if get_option('shell-desktop')
config_h.set_quoted('WESTON_SHELL_CLIENT', get_option('desktop-shell-client-default'))
srcs_shell_desktop = [
'shell.c',
'exposay.c',
'input-panel.c',
'../shared/matrix.c',
weston_desktop_shell_server_protocol_h,
weston_desktop_shell_protocol_c,
input_method_unstable_v1_server_protocol_h,
input_method_unstable_v1_protocol_c,
]
deps_shell_desktop = [
dep_libshared,
dep_lib_desktop,
dep_libweston,
]
plugin_shell_desktop = shared_library(
'desktop-shell',
srcs_shell_desktop,
include_directories: include_directories('..', '../shared'),
dependencies: deps_shell_desktop,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'desktop-shell.so=@0@;'.format(plugin_shell_desktop.full_path())
endif
if get_option('shell-fullscreen')
srcs_shell_fullscreen = [
'fullscreen-shell.c',
'../shared/matrix.c',
fullscreen_shell_unstable_v1_server_protocol_h,
fullscreen_shell_unstable_v1_protocol_c,
]
shared_library(
'fullscreen-shell',
srcs_shell_fullscreen,
include_directories: include_directories('..', '../shared'),
dependencies: dep_libweston,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
endif
if get_option('shell-ivi')
srcs_shell_ivi = [
'ivi-shell.c',
'ivi-layout.c',
'ivi-layout-transition.c',
ivi_application_server_protocol_h,
ivi_application_protocol_c,
input_method_unstable_v1_server_protocol_h,
input_method_unstable_v1_protocol_c,
]
plugin_shell_ivi = shared_library(
'ivi-shell',
srcs_shell_ivi,
include_directories: include_directories('..', '../shared'),
dependencies: dep_libweston,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'ivi-shell.so=@0@;'.format(plugin_shell_ivi.full_path())
install_headers('ivi-layout-export.h', subdir: 'weston')
srcs_ivi_hmi = [
'hmi-controller.c',
ivi_hmi_controller_server_protocol_h,
ivi_hmi_controller_protocol_c,
]
plugin_ivi_hmi = shared_library(
'hmi-controller',
srcs_ivi_hmi,
include_directories: include_directories('..', '../shared'),
dependencies: dep_libweston,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'hmi-controller.so=@0@;'.format(plugin_ivi_hmi.full_path())
ivi_test_config = configuration_data()
ivi_test_config.set('bindir', dir_bin)
ivi_test_config.set('libexecdir', dir_libexec)
ivi_test_config.set('abs_top_srcdir', meson.current_source_dir())
ivi_test_config.set('abs_top_builddir', meson.current_build_dir())
ivi_test_config.set('plugin_prefix', meson.current_build_dir())
ivi_test_config.set('westondatadir', join_paths(dir_data, 'weston'))
ivi_test_ini = configure_file(
input: '../ivi-shell/weston.ini.in',
output: 'weston-ivi-test.ini',
install: false,
configuration: ivi_test_config
)
endif
srcs_libdesktop = [
'libweston-desktop.c',
'client.c',
'seat.c',
'surface.c',
'xwayland.c',
'wl-shell.c',
'xdg-shell-v6.c',
xdg_shell_unstable_v6_server_protocol_h,
xdg_shell_unstable_v6_protocol_c,
]
lib_desktop = shared_library(
'weston-desktop-@0@'.format(libweston_major),
srcs_libdesktop,
include_directories: include_directories('..', '../shared'),
install: true,
version: '0.0.@0@'.format(libweston_revision),
dependencies: dep_libweston
)
dep_lib_desktop = declare_dependency(
link_with: lib_desktop,
dependencies: dep_libweston
)
install_headers('libweston-desktop.h', subdir: dir_include_libweston)
pkgconfig.generate(
filebase: 'libweston-desktop-@0@'.format(libweston_major),
name: 'libweston-desktop',
version: version_weston,
description: 'Desktop shells abstraction library for libweston compositors',
libraries: lib_desktop,
requires_private: [ lib_weston, dep_wayland_server ],
subdirs: dir_include_libweston
)
#define BUILD_ID "@VCS_TAG@"
deps_libweston = [
dep_wayland_server,
dep_pixman,
dep_libm,
dep_libdl,
dep_libdrm_headers,
dep_libshared,
dep_xkbcommon,
]
srcs_libweston = [
git_version_h,
'animation.c',
'bindings.c',
'clipboard.c',
'compositor.c',
'data-device.c',
'input.c',
'linux-dmabuf.c',
'log.c',
'noop-renderer.c',
'pixel-formats.c',
'pixman-renderer.c',
'plugin-registry.c',
'screenshooter.c',
'timeline.c',
'touch-calibration.c',
'weston-debug.c',
'zoom.c',
'../shared/matrix.c',
linux_dmabuf_unstable_v1_protocol_c,
linux_dmabuf_unstable_v1_server_protocol_h,
input_method_unstable_v1_protocol_c,
input_method_unstable_v1_server_protocol_h,
input_timestamps_unstable_v1_protocol_c,
input_timestamps_unstable_v1_server_protocol_h,
presentation_time_protocol_c,
presentation_time_server_protocol_h,
pointer_constraints_unstable_v1_protocol_c,
pointer_constraints_unstable_v1_server_protocol_h,
relative_pointer_unstable_v1_protocol_c,
relative_pointer_unstable_v1_server_protocol_h,
weston_screenshooter_protocol_c,
weston_screenshooter_server_protocol_h,
text_cursor_position_protocol_c,
text_cursor_position_server_protocol_h,
text_input_unstable_v1_protocol_c,
text_input_unstable_v1_server_protocol_h,
weston_touch_calibration_protocol_c,
weston_touch_calibration_server_protocol_h,
viewporter_protocol_c,
viewporter_server_protocol_h,
weston_debug_protocol_c,
weston_debug_server_protocol_h,
]
install_headers(
'compositor.h',
'plugin-registry.h',
'timeline-object.h',
'windowed-output-api.h',
'../shared/config-parser.h',
'../shared/matrix.h',
'../shared/zalloc.h',
subdir: dir_include_libweston
)
lib_weston = shared_library(
'weston-@0@'.format(libweston_major),
srcs_libweston,
include_directories: include_directories('..', '../shared'),
link_args: [ '-export-dynamic' ],
install: true,
version: '0.0.@0@'.format(libweston_revision),
dependencies: deps_libweston
)
dep_libweston = declare_dependency(
link_with: lib_weston,
include_directories: include_directories('.'),
dependencies: deps_libweston
)
pkgconfig.generate(
filebase: 'libweston-@0@'.format(libweston_major),
name: 'libweston API',
version: version_weston,
description: 'Header files for libweston compositors development',
libraries: lib_weston,
requires_private: [ dep_wayland_server, dep_pixman, dep_xkbcommon ],
subdirs: dir_include_libweston
)
pkgconfig.generate(
filebase: 'libweston-@0@-protocols'.format(libweston_major),
name: 'libWeston Protocols',
version: version_weston,
description: 'libWeston protocol files',
variables: [
'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_protocol_libweston)