forked from external/yambar
meson: initial support for building plugins as shared libraries
This commit is contained in:
parent
51e9d691e4
commit
fdb9a9bc1c
5 changed files with 169 additions and 80 deletions
|
@ -2,9 +2,17 @@ deco_sdk = declare_dependency(dependencies: [cairo, cairo_ft])
|
||||||
|
|
||||||
decorations = []
|
decorations = []
|
||||||
foreach deco : ['background', 'stack', 'underline']
|
foreach deco : ['background', 'stack', 'underline']
|
||||||
lib = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'decoration_@0@'.format(deco), '@0@.c'.format(deco), dependencies: deco_sdk)
|
shared_module('@0@'.format(deco), '@0@.c'.format(deco),
|
||||||
decorations += [declare_dependency(
|
dependencies: deco_sdk,
|
||||||
link_with: lib,
|
name_prefix: 'decoration_')
|
||||||
compile_args: '-DHAVE_PLUGIN_@0@'.format(deco.underscorify()))]
|
else
|
||||||
|
lib = static_library(
|
||||||
|
'decoration_@0@'.format(deco), '@0@.c'.format(deco), dependencies: deco_sdk,
|
||||||
|
target_type: target_type)
|
||||||
|
|
||||||
|
decorations += [declare_dependency(
|
||||||
|
link_with: lib,
|
||||||
|
compile_args: '-DHAVE_PLUGIN_@0@'.format(deco.underscorify()))]
|
||||||
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
45
meson.build
45
meson.build
|
@ -3,9 +3,8 @@ project('f00bar', 'c',
|
||||||
default_options: ['c_std=c11', 'warning_level=1', 'werror=true'])
|
default_options: ['c_std=c11', 'warning_level=1', 'werror=true'])
|
||||||
|
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
['-D_GNU_SOURCE',
|
['-D_GNU_SOURCE'] +
|
||||||
#'-Wno-unused-result'],
|
(get_option('core-plugins-as-shared-libraries') ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []),
|
||||||
],
|
|
||||||
language: 'c',
|
language: 'c',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,24 +17,19 @@ cairo_ft = dependency('cairo-ft')
|
||||||
yaml = dependency('yaml-0.1')
|
yaml = dependency('yaml-0.1')
|
||||||
|
|
||||||
# TODO: X11
|
# TODO: X11
|
||||||
xcb_aux = dependency('xcb-aux', required: get_option('x11'))
|
xcb_aux = dependency('xcb-aux', required: get_option('backend-x11'))
|
||||||
xcb_cursor = dependency('xcb-cursor', required: get_option('x11'))
|
xcb_cursor = dependency('xcb-cursor', required: get_option('backend-x11'))
|
||||||
xcb_event = dependency('xcb-event', required: get_option('x11'))
|
xcb_event = dependency('xcb-event', required: get_option('backend-x11'))
|
||||||
xcb_ewmh = dependency('xcb-ewmh', required: get_option('x11'))
|
xcb_ewmh = dependency('xcb-ewmh', required: get_option('backend-x11'))
|
||||||
xcb_randr = dependency('xcb-randr', required: get_option('x11'))
|
xcb_randr = dependency('xcb-randr', required: get_option('backend-x11'))
|
||||||
xcb_render = dependency('xcb-render', required: get_option('x11'))
|
xcb_render = dependency('xcb-render', required: get_option('backend-x11'))
|
||||||
cairo_xcb = dependency('cairo-xcb', required: get_option('x11'))
|
cairo_xcb = dependency('cairo-xcb', required: get_option('backend-x11'))
|
||||||
xcb_errors = dependency('xcb-errors', required: false)
|
xcb_errors = dependency('xcb-errors', required: false)
|
||||||
|
|
||||||
xcb_stuff = declare_dependency(
|
|
||||||
sources: ['xcb.c', 'xcb.h'],
|
|
||||||
dependencies: [xcb_aux, xcb_cursor, xcb_event, xcb_ewmh, xcb_randr,
|
|
||||||
xcb_render, cairo_xcb, xcb_errors],
|
|
||||||
compile_args: xcb_errors.found() ? '-DHAVE_XCB_ERRORS' : [])
|
|
||||||
|
|
||||||
if xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \
|
if xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \
|
||||||
xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \
|
xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \
|
||||||
cairo_xcb.found()
|
cairo_xcb.found()
|
||||||
|
|
||||||
enable_x11 = true
|
enable_x11 = true
|
||||||
add_project_arguments('-DENABLE_X11', language: 'c')
|
add_project_arguments('-DENABLE_X11', language: 'c')
|
||||||
else
|
else
|
||||||
|
@ -43,9 +37,9 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO: conditional on Wayland
|
# TODO: conditional on Wayland
|
||||||
wayland_client = dependency('wayland-client', required: get_option('wayland'))
|
wayland_client = dependency('wayland-client', required: get_option('backend-wayland'))
|
||||||
wayland_cursor = dependency('wayland-cursor', required: get_option('wayland'))
|
wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayland'))
|
||||||
wlroots = dependency('wlroots', required: get_option('wayland'))
|
wlroots = dependency('wlroots', required: get_option('backend-wayland'))
|
||||||
|
|
||||||
if wayland_client.found() and wayland_cursor.found() and wlroots.found()
|
if wayland_client.found() and wayland_cursor.found() and wlroots.found()
|
||||||
enable_wayland = true
|
enable_wayland = true
|
||||||
|
@ -54,6 +48,16 @@ else
|
||||||
enable_wayland = false
|
enable_wayland = false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if enable_x11
|
||||||
|
xcb_stuff_lib = static_library(
|
||||||
|
'xcb-stuff', 'xcb.c', 'xcb.h',
|
||||||
|
dependencies: [xcb_aux, xcb_cursor, xcb_event, xcb_ewmh, xcb_randr,
|
||||||
|
xcb_render, cairo_xcb, xcb_errors],
|
||||||
|
c_args: xcb_errors.found() ? '-DHAVE_XCB_ERRORS' : [],
|
||||||
|
pic: get_option('core-plugins-as-shared-libraries'))
|
||||||
|
xcb_stuff = declare_dependency(link_with: xcb_stuff_lib)
|
||||||
|
endif
|
||||||
|
|
||||||
subdir('bar')
|
subdir('bar')
|
||||||
subdir('decorations')
|
subdir('decorations')
|
||||||
subdir('particles')
|
subdir('particles')
|
||||||
|
@ -76,4 +80,5 @@ executable(
|
||||||
'yml.c', 'yml.h',
|
'yml.c', 'yml.h',
|
||||||
dependencies: [bar, cairo, cairo_ft, fontconfig, yaml, threads, dl] +
|
dependencies: [bar, cairo, cairo_ft, fontconfig, yaml, threads, dl] +
|
||||||
decorations + particles + modules,
|
decorations + particles + modules,
|
||||||
link_args: '-rdynamic')
|
build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles',
|
||||||
|
export_dynamic: true)
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
option('x11', type: 'feature', value: 'enabled', description: 'XCB (X11) backend')
|
option(
|
||||||
option('wayland', type: 'feature', value: 'enabled', description: 'Wayland backend')
|
'backend-x11', type: 'feature', value: 'enabled', description: 'XCB (X11) backend')
|
||||||
|
option(
|
||||||
|
'backend-wayland', type: 'feature', value: 'enabled', description: 'Wayland backend')
|
||||||
|
option(
|
||||||
|
'core-plugins-as-shared-libraries', type: 'boolean', value: false,
|
||||||
|
description: 'Compiles modules, particles and decorations as shared libraries, which are loaded on-demand')
|
||||||
|
|
|
@ -1,64 +1,124 @@
|
||||||
module_sdk = declare_dependency(dependencies: [cairo, cairo_ft, threads])
|
module_sdk = declare_dependency(dependencies: [cairo, cairo_ft, threads])
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
alsa_mod = static_library(
|
|
||||||
'module_alsa', 'alsa.c', dependencies: [module_sdk, dependency('alsa')])
|
alsa = dependency('alsa')
|
||||||
modules += [declare_dependency(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
link_with: alsa_mod, compile_args: '-DHAVE_PLUGIN_alsa')]
|
shared_module(
|
||||||
|
'alsa', 'alsa.c', dependencies: [module_sdk, alsa], name_prefix: 'module_')
|
||||||
|
else
|
||||||
|
alsa_mod = static_library(
|
||||||
|
'module_alsa', 'alsa.c', dependencies: [module_sdk, alsa])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: alsa_mod, compile_args: '-DHAVE_PLUGIN_alsa')]
|
||||||
|
endif
|
||||||
|
|
||||||
udev = dependency('libudev')
|
udev = dependency('libudev')
|
||||||
backlight_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_backlight', 'backlight.c', dependencies: [module_sdk, udev])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'backlight', 'backlight.c', dependencies: [module_sdk, udev], name_prefix: 'module_')
|
||||||
link_with: backlight_mod, compile_args: '-DHAVE_PLUGIN_backlight')]
|
else
|
||||||
|
backlight_mod = static_library(
|
||||||
|
'module_backlight', 'backlight.c', dependencies: [module_sdk, udev])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: backlight_mod, compile_args: '-DHAVE_PLUGIN_backlight')]
|
||||||
|
endif
|
||||||
|
|
||||||
battery_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_battery', 'battery.c', dependencies: [module_sdk, udev])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'battery', 'battery.c', dependencies: [module_sdk, udev], name_prefix: 'module_')
|
||||||
link_with: battery_mod, compile_args: '-DHAVE_PLUGIN_battery')]
|
else
|
||||||
|
battery_mod = static_library(
|
||||||
|
'module_battery', 'battery.c', dependencies: [module_sdk, udev])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: battery_mod, compile_args: '-DHAVE_PLUGIN_battery')]
|
||||||
|
endif
|
||||||
|
|
||||||
clock_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_clock', 'clock.c', dependencies: [module_sdk])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'clock', 'clock.c', dependencies: [module_sdk], name_prefix: 'module_')
|
||||||
link_with: clock_mod, compile_args: '-DHAVE_PLUGIN_clock')]
|
else
|
||||||
|
clock_mod = static_library(
|
||||||
|
'module_clock', 'clock.c', dependencies: [module_sdk])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: clock_mod, compile_args: '-DHAVE_PLUGIN_clock')]
|
||||||
|
endif
|
||||||
|
|
||||||
json = dependency('json-c')
|
json = dependency('json-c')
|
||||||
i3_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_i3', 'i3.c', 'i3-common.c', 'i3-common.h',
|
shared_module('module_i3', 'i3.c', 'i3-common.c', 'i3-common.h',
|
||||||
dependencies: [module_sdk, json, dynlist])
|
dependencies: [module_sdk, json, dynlist],
|
||||||
modules += [declare_dependency(
|
name_prefix: '')
|
||||||
link_with: i3_mod, compile_args: '-DHAVE_PLUGIN_i3')]
|
else
|
||||||
|
i3_mod = static_library(
|
||||||
|
'module_i3', 'i3.c', 'i3-common.c', 'i3-common.h',
|
||||||
|
dependencies: [module_sdk, json, dynlist])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: i3_mod, compile_args: '-DHAVE_PLUGIN_i3')]
|
||||||
|
endif
|
||||||
|
|
||||||
label_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_label', 'label.c', dependencies: [module_sdk])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'label', 'label.c', dependencies: [module_sdk], name_prefix: 'module_')
|
||||||
link_with: label_mod, compile_args: '-DHAVE_PLUGIN_label')]
|
else
|
||||||
|
label_mod = static_library(
|
||||||
|
'module_label', 'label.c', dependencies: [module_sdk])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: label_mod, compile_args: '-DHAVE_PLUGIN_label')]
|
||||||
|
endif
|
||||||
|
|
||||||
mpd = dependency('libmpdclient')
|
mpd = dependency('libmpdclient')
|
||||||
mpd_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_mpd', 'mpd.c', dependencies: [module_sdk, mpd])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'mpd', 'mpd.c', dependencies: [module_sdk, mpd], name_prefix: 'module_')
|
||||||
link_with: mpd_mod, compile_args: '-DHAVE_PLUGIN_mpd')]
|
else
|
||||||
|
mpd_mod = static_library(
|
||||||
|
'module_mpd', 'mpd.c', dependencies: [module_sdk, mpd])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: mpd_mod, compile_args: '-DHAVE_PLUGIN_mpd')]
|
||||||
|
endif
|
||||||
|
|
||||||
network_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_network', 'network.c', dependencies: [module_sdk])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'network', 'network.c', dependencies: [module_sdk], name_prefix: 'module_')
|
||||||
link_with: network_mod, compile_args: '-DHAVE_PLUGIN_network')]
|
else
|
||||||
|
network_mod = static_library(
|
||||||
|
'module_network', 'network.c', dependencies: [module_sdk])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: network_mod, compile_args: '-DHAVE_PLUGIN_network')]
|
||||||
|
endif
|
||||||
|
|
||||||
removables_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_removables', 'removables.c', dependencies: [module_sdk, udev, dynlist])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'removables', 'removables.c', dependencies: [module_sdk, udev, dynlist],
|
||||||
link_with: removables_mod, compile_args: '-DHAVE_PLUGIN_removables')]
|
name_prefix: 'module_')
|
||||||
|
else
|
||||||
|
removables_mod = static_library(
|
||||||
|
'module_removables', 'removables.c', dependencies: [module_sdk, udev, dynlist])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: removables_mod, compile_args: '-DHAVE_PLUGIN_removables')]
|
||||||
|
endif
|
||||||
|
|
||||||
if enable_x11
|
if enable_x11
|
||||||
xcb_xkb = dependency('xcb-xkb')
|
xcb_xkb = dependency('xcb-xkb')
|
||||||
xkb_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_xkb', 'xkb.c', dependencies: [module_sdk, xcb_stuff, xcb_xkb])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'xkb', 'xkb.c', dependencies: [module_sdk, xcb_stuff, xcb_xkb], name_prefix: 'module_')
|
||||||
link_with: xkb_mod, compile_args: '-DHAVE_PLUGIN_xkb')]
|
else
|
||||||
|
xkb_mod = static_library(
|
||||||
|
'module_xkb', 'xkb.c', dependencies: [module_sdk, xcb_stuff, xcb_xkb])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: xkb_mod, compile_args: '-DHAVE_PLUGIN_xkb')]
|
||||||
|
endif
|
||||||
|
|
||||||
xwindow_mod = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'module_xwindow', 'xwindow.c', dependencies: [module_sdk, xcb_stuff])
|
shared_module(
|
||||||
modules += [declare_dependency(
|
'xwindow', 'xwindow.c', dependencies: [module_sdk, xcb_stuff],
|
||||||
link_with: xwindow_mod, compile_args: '-DHAVE_MODULE_xwindow')]
|
name_prefix: 'module_')
|
||||||
|
else
|
||||||
|
xwindow_mod = static_library(
|
||||||
|
'module_xwindow', 'xwindow.c', dependencies: [module_sdk, xcb_stuff])
|
||||||
|
modules += [declare_dependency(
|
||||||
|
link_with: xwindow_mod, compile_args: '-DHAVE_MODULE_xwindow')]
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -2,14 +2,25 @@ particle_sdk = declare_dependency(dependencies: [cairo, cairo_ft])
|
||||||
|
|
||||||
particles = []
|
particles = []
|
||||||
foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string']
|
foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string']
|
||||||
lib = static_library(
|
if get_option('core-plugins-as-shared-libraries')
|
||||||
'particle_@0@'.format(particle), '@0@.c'.format(particle),
|
shared_module('@0@'.format(particle), '@0@.c'.format(particle),
|
||||||
dependencies: particle_sdk)
|
dependencies: particle_sdk,
|
||||||
particles += [declare_dependency(
|
name_prefix: 'particle_')
|
||||||
link_with: lib,
|
else
|
||||||
compile_args: '-DHAVE_PLUGIN_@0@'.format(particle.underscorify()))]
|
lib = static_library(
|
||||||
|
'particle_@0@'.format(particle), '@0@.c'.format(particle),
|
||||||
|
dependencies: particle_sdk)
|
||||||
|
|
||||||
|
particles += [declare_dependency(
|
||||||
|
link_with: lib,
|
||||||
|
compile_args: '-DHAVE_PLUGIN_@0@'.format(particle.underscorify()))]
|
||||||
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
dynlist_lib = static_library(
|
dynlist_lib = build_target(
|
||||||
'dynlist', 'dynlist.c', 'dynlist.h', dependencies: particle_sdk)
|
'dynlist', 'dynlist.c', 'dynlist.h', dependencies: particle_sdk,
|
||||||
|
target_type: (get_option('core-plugins-as-shared-libraries')
|
||||||
|
? 'shared_library' : 'static_library'),
|
||||||
|
override_options : ['b_lundef=false'])
|
||||||
|
|
||||||
dynlist = declare_dependency(link_with: dynlist_lib)
|
dynlist = declare_dependency(link_with: dynlist_lib)
|
||||||
|
|
Loading…
Add table
Reference in a new issue