Skip to content

Commit

Permalink
Use meson build system
Browse files Browse the repository at this point in the history
  • Loading branch information
infirit committed Sep 9, 2019
1 parent c6db853 commit f3fd862
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ Makefile

# Local execution
/blueman/**/*.pyc

# meson build files
/build*/
4 changes: 2 additions & 2 deletions data/blueman-adapters.desktop.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
_Name=Bluetooth Adapters
_Comment=Set Bluetooth Adapter Properties
Name=Bluetooth Adapters
Comment=Set Bluetooth Adapter Properties
Exec=blueman-adapters
Icon=blueman-device
Terminal=false
Expand Down
4 changes: 2 additions & 2 deletions data/blueman-manager.desktop.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
_Name=Bluetooth Manager
_Comment=Blueman Bluetooth Manager
Name=Bluetooth Manager
Comment=Blueman Bluetooth Manager
Icon=blueman
Exec=blueman-manager
Terminal=false
Expand Down
4 changes: 2 additions & 2 deletions data/blueman.desktop.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
_Name=Blueman Applet
_Comment=Blueman Bluetooth Manager
Name=Blueman Applet
Comment=Blueman Bluetooth Manager
Icon=blueman
Exec=blueman-applet
Terminal=false
Expand Down
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gnome.compile_schemas(build_by_default: true)
2 changes: 1 addition & 1 deletion data/thunar-sendto-blueman.desktop.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Version=1.0
_Name=Bluetooth Device
Name=Bluetooth Device
Icon=blueman
Exec=blueman-sendto %F
316 changes: 316 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
project(
'blueman', 'c',
version: '2.1-alpha2',
license: 'GPL3'
)

package_name = 'blueman'

# Import needed modules
python = import('python3')
gnome = import('gnome')
i18n = import('i18n')

# Make sure Python is installed and found
if not python.find_python().found()
error('No valid python3 binary found')
endif

# Setup all directories we install in
prefix = get_option('prefix')
datadir = join_paths([prefix, get_option('datadir')])
pkgdatadir = join_paths([prefix, get_option('datadir'), package_name])
bindir = join_paths([prefix, get_option('bindir')])
libexecdir = join_paths([prefix, get_option('libexecdir')])
schemadir = join_paths([datadir, 'glib-2.0', 'schemas'])
pythondir = join_paths([prefix, python.sysconfig_path('purelib')])

if get_option('policykit')
have_polkit = 'yes'
else
have_polkit = 'no'
endif

# Setup congfiguration
conf_data = configuration_data()
conf_data.set('BINDIR', bindir)
conf_data.set('LIBEXECDIR', libexecdir)
conf_data.set('VERSION', meson.project_version())
conf_data.set('PACKAGE', package_name)
conf_data.set('prefix', prefix)
conf_data.set('pkgdatadir', pkgdatadir)
conf_data.set('LOCALEDIR', join_paths(prefix, get_option('localedir')))
conf_data.set('icondir', join_paths(datadir, 'icons'))
conf_data.set('dhconfig', get_option('dhcp-config-path'))
conf_data.set('have_polkit', have_polkit)
conf_data.set('GETTEXT_PACKAGE', package_name)


# Check for build dependencies
pythonlib = dependency('python-' + python.language_version(), required: true)
pygobject = dependency('pygobject-3.0', required: true)
bluez = dependency('bluez', version: '>= 5.0', required: true)
gthread = dependency('gthread-2.0', version: '>= 2.32', required: true)

# Check for systemd to get unit file dirs
systemd = dependency('systemd', required: false)

# Check for runtime deps and when not found fail based on runtime_deps_check
do_runtime_checks = get_option('runtime_deps_check')

gtk = dependency('gtk+-3.0', version: '>= 3.10.', required: do_runtime_checks)
dbus_python = dependency('dbus-python', required: do_runtime_checks)

# handle icons slightly differently
gnome_icons = dependency('gnome-icon-theme', required: false)
mate_icons = dependency('mate-icon-theme', required: false)
adwaita_icons = dependency('adwaita-icon-theme', required: false)
faenza_icons = dependency('faenza-icon-theme', required: false)

icon_theme_found = gnome_icons.found() or mate_icons.found() or adwaita_icons.found() or faenza_icons.found()
icon_msg = 'No icon theme found, blueman requires an icon theme'
if not icon_theme_found and do_runtime_checks
error(icon_msg)
elif not icon_theme_found
warning(icon_msg)
endif


# Install our scripts in the proper location
install_data(
'apps/blueman-adapters',
'apps/blueman-applet',
'apps/blueman-assistant',
'apps/blueman-manager',
'apps/blueman-report',
'apps/blueman-sendto',
'apps/blueman-services',
'apps/blueman-tray',
install_dir: bindir,
install_mode: 'rwxr-xr-x'
)

install_data(
'apps/blueman-mechanism',
'apps/blueman-rfcomm-watcher',
install_dir: libexecdir,
install_mode: 'rwxr-xr-x'
)


# Install all the artwork and icons
# FIXME use strip_directory when meson 0.45.0 is mainstream
install_data(
'data/icons/pixmaps/blueman-lq-10.png',
'data/icons/pixmaps/blueman-lq-20.png',
'data/icons/pixmaps/blueman-lq-30.png',
'data/icons/pixmaps/blueman-lq-40.png',
'data/icons/pixmaps/blueman-lq-50.png',
'data/icons/pixmaps/blueman-lq-60.png',
'data/icons/pixmaps/blueman-lq-70.png',
'data/icons/pixmaps/blueman-lq-80.png',
'data/icons/pixmaps/blueman-lq-90.png',
'data/icons/pixmaps/blueman-lq-100.png',
'data/icons/pixmaps/blueman-rssi-10.png',
'data/icons/pixmaps/blueman-rssi-20.png',
'data/icons/pixmaps/blueman-rssi-30.png',
'data/icons/pixmaps/blueman-rssi-40.png',
'data/icons/pixmaps/blueman-rssi-50.png',
'data/icons/pixmaps/blueman-rssi-60.png',
'data/icons/pixmaps/blueman-rssi-70.png',
'data/icons/pixmaps/blueman-rssi-80.png',
'data/icons/pixmaps/blueman-rssi-90.png',
'data/icons/pixmaps/blueman-rssi-100.png',
'data/icons/pixmaps/blueman-tpl-10.png',
'data/icons/pixmaps/blueman-tpl-20.png',
'data/icons/pixmaps/blueman-tpl-30.png',
'data/icons/pixmaps/blueman-tpl-40.png',
'data/icons/pixmaps/blueman-tpl-50.png',
'data/icons/pixmaps/blueman-tpl-60.png',
'data/icons/pixmaps/blueman-tpl-70.png',
'data/icons/pixmaps/blueman-tpl-80.png',
'data/icons/pixmaps/blueman-tpl-90.png',
'data/icons/pixmaps/blueman-tpl-100.png',
install_dir: join_paths([datadir, 'pixmaps', package_name])
)

install_subdir(
'data/icons/hicolor',
install_dir: join_paths([datadir, 'icons'])
)


# GtkBuilder UI files
install_subdir(
'data/ui',
install_dir: pkgdatadir
)


# Gsettings and pin database
install_data('data/org.blueman.gschema.xml', install_dir: schemadir)
install_data('data/pin-code-database.xml', install_dir: pkgdatadir)

# FIXME when polkit 0.114 is in stable releases use i18n.merge_file, until then use intltool
# Merge translation into policy file
intltool_merge = find_program('intltool-merge')
podir = join_paths('@CURRENT_SOURCE_DIR@', 'po')

custom_target('org.blueman.policy',
input: 'data/configs/org.blueman.policy.in',
output: 'org.blueman.policy',
install: true,
command: [intltool_merge, '--xml-style', podir, '@INPUT@', '@OUTPUT@'],
install_dir: join_paths(datadir, 'polkit-1', 'actions'),
)

# Merge translations into desktop files
i18n.merge_file(
input: 'data/blueman.desktop.in',
output: 'blueman.desktop',
type: 'desktop',
po_dir: 'po',
install: true,
install_dir: join_paths([get_option('sysconfdir'), 'xdg', 'autostart']),
)

i18n.merge_file(
input: 'data/blueman-adapters.desktop.in',
output: 'blueman-adapters.desktop',
type: 'desktop',
po_dir: 'po',
install: true,
install_dir: join_paths([datadir,'applications']),
)

i18n.merge_file(
input: 'data/blueman-manager.desktop.in',
output: 'blueman-manager.desktop',
type: 'desktop',
po_dir: 'po',
install: true,
install_dir: join_paths([datadir,'applications']),
)

i18n.merge_file(
input: 'data/thunar-sendto-blueman.desktop.in',
output: 'thunar-sendto-blueman.desktop',
type: 'desktop',
po_dir: 'po',
install: get_option('thunar-sendto'),
install_dir: join_paths([datadir,'Thunar', 'sendto']),
)


# install manpages
install_man(
'data/man/blueman-adapters.1',
'data/man/blueman-applet.1',
'data/man/blueman-assistant.1',
'data/man/blueman-manager.1',
'data/man/blueman-report.1',
'data/man/blueman-sendto.1',
'data/man/blueman-services.1',
'data/man/blueman-tray.1'
)


# Gather all configurable files
configurable_files = [
['blueman/Constants.py.in',
'Constants.py',
join_paths(pythondir, package_name)],
['data/configs/org.blueman.Applet.service.in',
'org.blueman.Applet.service',
join_paths(datadir, 'dbus-1', 'services')],
['data/configs/org.blueman.Mechanism.service.in',
'org.blueman.Mechanism.service',
join_paths(datadir, 'dbus-1', 'system-services')]
]

systemd_user_dir = get_option('systemduserunitdir')
if systemd_user_dir != ''
systemd_user_path = join_paths(prefix, systemd_user_dir)
elif systemd.found()
systemd_user_path = join_paths(prefix, systemd.get_pkgconfig_variable('systemduserunitdir'))
else
systemd_user_path = ''
endif

if systemd_user_path != ''
configurable_files += [['data/configs/blueman-applet.service.in',
'blueman-applet.service',
systemd_user_path]]
endif

systemd_system_dir = get_option('systemdsystemunitdir')
if systemd_system_dir != ''
systemd_system_path = join_paths(prefix, systemd_system_dir)
elif systemd.found()
systemd_system_path = join_paths(prefix, systemd.get_pkgconfig_variable('systemdsystemunitdir'))
else
systemd_system_path = ''
endif

if systemd_system_path != ''
configurable_files += [['data/configs/blueman-mechanism.service.in',
'blueman-mechanism.service',
systemd_system_path]]
endif

# Generate all configurable files based on conf_data
foreach conf_file: configurable_files
configure_file(
input: conf_file[0],
output: conf_file[1],
install_dir: conf_file[2],
configuration: conf_data
)
endforeach

install_data(
'data/configs/org.blueman.Mechanism.conf',
install_dir: join_paths(get_option('sysconfdir'), 'dbus-1', 'system.d')
)


# Install blueman subdir and exclude files based on configure options
blueman_exclude_files = ['Constants.py.in']
pulseaudio = get_option('pulseaudio')
if not pulseaudio
blueman_exclude_files += 'plugins/manager/PulseAudioProfile.py'
endif

appindicator = get_option('appindicator')
if not appindicator
blueman_exclude_files += 'plugins/applet/AppIndicator.py'
endif

install_subdir(
'blueman',
install_dir: pythondir,
exclude_files: blueman_exclude_files
)


# Install nautilus (plus clones) python plugins for blueman-sendto
foreach name: get_option('sendto-plugins')
dep = dependency('@0@-python'.format(name.to_lower()), required: false)
if not dep.found()
warning('@0@-python not found which is required for @0@_blueman_sendto to work.'.format(name.to_lower()))
endif

sendto_conf = configuration_data()
sendto_conf.set('FILEMANAGER', name)
configure_file(
input: 'sendto/blueman_sendto.py.in',
output: '@0@_blueman_sendto.py'.format(name.to_lower()),
configuration: sendto_conf,
install_dir: join_paths(prefix, datadir, '@0@-python'.format(name.to_lower()), 'extensions')
)
endforeach

# Add data as custom_target does not work in subdirectory
subdir('data')
subdir('po')
subdir('module')
9 changes: 9 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
option('runtime_deps_check', type: 'boolean', value: true, description: 'Disable runtime dependency check (for package maintainers)')
option('dhcp-config-path', type: 'string', value: '/etc/dhcp3/dhcpd.conf', description: 'Set dhcp3 server configuration path')
option('policykit', type: 'boolean', value: true, description: 'Enable policykit support')
option('pulseaudio', type: 'boolean', value: true, description: 'Enable PulseAudio support')
option('appindicator', type: 'boolean', value: true, description: 'Enable Libappindicator support')
option('systemdsystemunitdir', type: 'string', description: 'Path to systemd system unit dir relative to ${prefix}')
option('systemduserunitdir', type: 'string', description: 'Path to systemd user unit dir relative to ${prefix}')
option('sendto-plugins', type: 'array', choices: ['Caja', 'Nemo', 'Nautilus'], value: ['Caja', 'Nemo', 'Nautilus'], description: 'Install sendto plugins for various filemanagers')
option('thunar-sendto', type: 'boolean', value: true, description: 'Install Thunar sendto plugin')
26 changes: 26 additions & 0 deletions module/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cython = find_program('cython', required: true)

blueman_c = custom_target(
'blueman_c',
output: '_blueman.c',
input: '_blueman.pyx',
command: [cython, '--output-file', '@OUTPUT@', '@INPUT@'])

sources = [
blueman_c,
'libblueman.c',
'libblueman.h',
'modem-prober.c',
'modem-prober.h'
]

deps = [pygobject, pythonlib, gthread, bluez]

bluemanlib = shared_library(
'_blueman', sources,
name_prefix: '',
dependencies : deps,
c_args: ['-DSN_API_NOT_YET_FROZEN'],
install: true,
install_dir: pythondir,
)
1 change: 1 addition & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i18n.gettext(package_name, preset: 'glib')

0 comments on commit f3fd862

Please sign in to comment.