mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
Split meson up to be more modular
This also explicitly constructs reusable library components to make it easier to extend the project over time. Notably we make less assumptions about the host system and use pkgconfig where appropriate to give us system details, such as the systemd system unit directory for packaging. This can be overriden with the meson option. Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
parent
2bbaab129b
commit
1328e07f86
@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
# Echo the rest so it's obvious
|
# Echo the rest so it's obvious
|
||||||
set -x
|
set -x
|
||||||
meson --prefix=/usr build
|
meson --prefix=/usr build -Dwith-systemd-user-unit-dir=/etc/systemd/user
|
||||||
cd build
|
cd build
|
||||||
ninja
|
ninja
|
||||||
|
|
||||||
|
47
daemon/meson.build
Normal file
47
daemon/meson.build
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Convenience library for the duplicated logging functionality
|
||||||
|
common_sources = [
|
||||||
|
'logging.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
daemon_common = static_library(
|
||||||
|
'daemon-common',
|
||||||
|
sources: common_sources,
|
||||||
|
install: false,
|
||||||
|
)
|
||||||
|
|
||||||
|
link_daemon_common = declare_dependency(
|
||||||
|
link_with: daemon_common,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Main daemon
|
||||||
|
daemon_sources = [
|
||||||
|
'main.c',
|
||||||
|
'gamemode.c',
|
||||||
|
'daemonize.c',
|
||||||
|
'dbus_messaging.c',
|
||||||
|
'governors.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
executable(
|
||||||
|
'gamemoded',
|
||||||
|
sources: daemon_sources,
|
||||||
|
dependencies: [
|
||||||
|
link_daemon_common,
|
||||||
|
dep_systemd,
|
||||||
|
],
|
||||||
|
install: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Small target util to get and set cpu governors
|
||||||
|
cpugovctl_sources = [
|
||||||
|
'cpugovctl.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
cpugovctl = executable(
|
||||||
|
'cpugovctl',
|
||||||
|
sources: cpugovctl_sources,
|
||||||
|
dependencies: [
|
||||||
|
link_daemon_common,
|
||||||
|
],
|
||||||
|
install: true,
|
||||||
|
)
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Allow cpugovctl to control the governors
|
# Allow cpugovctl to control the governors
|
||||||
chmod +4555 ${MESON_INSTALL_PREFIX}/bin/cpugovctl
|
PREFIX=${MESON_INSTALL_PREFIX:-/usr}
|
||||||
|
chmod +4555 ${DESTDIR}${PREFIX}/bin/cpugovctl
|
||||||
|
8
data/meson.build
Normal file
8
data/meson.build
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Install the service file
|
||||||
|
install_data('gamemoded.service', install_dir: path_systemd_unit_dir)
|
||||||
|
|
||||||
|
# Give cpugovctl the permissions it needs
|
||||||
|
meson.add_install_script(
|
||||||
|
'cpugovctl_perms.sh',
|
||||||
|
dependencies: cpugovctl,
|
||||||
|
)
|
11
example/meson.build
Normal file
11
example/meson.build
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# An example game
|
||||||
|
executable(
|
||||||
|
'example',
|
||||||
|
sources: [
|
||||||
|
'main.c',
|
||||||
|
],
|
||||||
|
include_directories: libgamemode_includes,
|
||||||
|
dependencies: [
|
||||||
|
libdl,
|
||||||
|
],
|
||||||
|
)
|
34
lib/meson.build
Normal file
34
lib/meson.build
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Main client library to message the daemon
|
||||||
|
shared_library(
|
||||||
|
'gamemode',
|
||||||
|
sources: [
|
||||||
|
'client_impl.c',
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
dep_systemd,
|
||||||
|
],
|
||||||
|
install: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
libgamemode_includes = [
|
||||||
|
include_directories('.'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Small library to automatically use gamemode
|
||||||
|
shared_library(
|
||||||
|
'gamemodeauto',
|
||||||
|
sources: [
|
||||||
|
'client_loader.c',
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
libdl,
|
||||||
|
],
|
||||||
|
install: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install the gamemode_client header
|
||||||
|
gamemode_headers = [
|
||||||
|
'gamemode_client.h',
|
||||||
|
]
|
||||||
|
|
||||||
|
install_headers(gamemode_headers)
|
87
meson.build
87
meson.build
@ -1,54 +1,49 @@
|
|||||||
project('gamemode', 'c',
|
project(
|
||||||
default_options : ['c_std=c11'],
|
'gamemode',
|
||||||
version : '0.2',
|
'c',
|
||||||
license : 'BSD' )
|
default_options : ['c_std=c11'],
|
||||||
|
version: '0.2',
|
||||||
|
license: 'BSD',
|
||||||
|
)
|
||||||
|
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
libsystemd = cc.find_library('systemd')
|
path_prefix = get_option('prefix')
|
||||||
libdl = cc.find_library('dl')
|
path_bindir = join_paths(path_prefix, get_option('bindir'))
|
||||||
|
path_datadir = join_paths(path_prefix, get_option('datadir'))
|
||||||
|
path_includedir = join_paths(path_prefix, get_option('includedir'))
|
||||||
|
path_libdir = join_paths(path_prefix, get_option('libdir'))
|
||||||
|
|
||||||
executable( 'gamemoded',
|
# Find systemd via pkgconfig
|
||||||
'daemon/main.c',
|
dep_systemd = dependency('libsystemd')
|
||||||
'daemon/gamemode.c',
|
|
||||||
'daemon/logging.c',
|
|
||||||
'daemon/daemonize.c',
|
|
||||||
'daemon/dbus_messaging.c',
|
|
||||||
'daemon/governors.c',
|
|
||||||
dependencies: libsystemd,
|
|
||||||
install: true )
|
|
||||||
|
|
||||||
# Main client library to message the daemon
|
# On non glibc systems this might be a stub, i.e. for musl
|
||||||
shared_library( 'gamemode',
|
libdl = cc.find_library('dl', required: false)
|
||||||
'lib/client_impl.c',
|
|
||||||
dependencies: libsystemd,
|
|
||||||
install : true )
|
|
||||||
|
|
||||||
# install the service file
|
# If the path isn't explicitly set, ask systemd for the systemd user unit directory
|
||||||
install_data( 'data/gamemoded.service', install_dir: '/etc/systemd/user' )
|
path_systemd_unit_dir = get_option('with-systemd-user-unit-dir')
|
||||||
|
if path_systemd_unit_dir == ''
|
||||||
|
message('Asking pkg-config for systemd\'s directories')
|
||||||
|
pkgconfig_systemd = dependency('systemd')
|
||||||
|
path_systemd_unit_dir = pkgconfig_systemd.get_pkgconfig_variable('systemduserunitdir')
|
||||||
|
endif
|
||||||
|
|
||||||
# Small target util to get and set cpu governors
|
subdir('lib')
|
||||||
executable( 'cpugovctl',
|
subdir('daemon')
|
||||||
'daemon/cpugovctl.c',
|
subdir('example')
|
||||||
'daemon/logging.c',
|
subdir('data')
|
||||||
install : true )
|
|
||||||
|
|
||||||
# Give cpugovctl the permissions it needs
|
report = [
|
||||||
meson.add_install_script( 'data/cpugovctl_perms.sh',
|
' Build configuration:',
|
||||||
dependencies : 'cpugovctl' )
|
' ====================',
|
||||||
|
'',
|
||||||
# Small library to automatically use gamemode
|
' prefix: @0@'.format(path_prefix),
|
||||||
shared_library( 'gamemodeauto',
|
' bindir: @0@'.format(path_bindir),
|
||||||
'lib/client_loader.c',
|
' datadir: @0@'.format(path_datadir),
|
||||||
dependencies : libdl,
|
' libdir: @0@'.format(path_libdir),
|
||||||
install : true )
|
' includedir: @0@'.format(path_includedir),
|
||||||
|
' systemd user unit directory: @0@'.format(path_systemd_unit_dir),
|
||||||
# Install the gamemode_client header
|
]
|
||||||
install_headers( 'lib/gamemode_client.h' )
|
|
||||||
|
|
||||||
# An example game
|
|
||||||
libdir = include_directories('lib')
|
|
||||||
executable( 'example',
|
|
||||||
'example/main.c',
|
|
||||||
dependencies : libdl,
|
|
||||||
include_directories : libdir )
|
|
||||||
|
|
||||||
|
# Output some stuff to validate the build config
|
||||||
|
message('\n\n\n' + '\n'.join(report) + '\n\n')
|
||||||
|
1
meson_options.txt
Normal file
1
meson_options.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
option('with-systemd-user-unit-dir', type: 'string', description: 'Explicitly set the systemd user unit directory')
|
Loading…
x
Reference in New Issue
Block a user