diff options
author | Aylur <[email protected]> | 2024-05-22 00:06:27 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-05-22 00:06:27 +0200 |
commit | cf9125cf31fb5b58be273395726c21041517d64f (patch) | |
tree | 4476119fa5be377b585bd86d46f9d98493924f99 | |
parent | 81c4e3a12d05a3550f1d8c942f0d919b4688c3bc (diff) |
refactor meson
into a reusable format that can easily be copied
-rw-r--r-- | flake.lock | 6 | ||||
-rw-r--r-- | meson.build | 5 | ||||
-rw-r--r-- | meson_options.txt | 13 | ||||
-rw-r--r-- | src/cli.vala (renamed from src/cli.vala.in) | 4 | ||||
-rw-r--r-- | src/config.vala.in | 6 | ||||
-rw-r--r-- | src/meson.build | 89 | ||||
-rw-r--r-- | src/proxy.vala | 1 |
7 files changed, 74 insertions, 50 deletions
@@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1715961556, - "narHash": "sha256-+NpbZRCRisUHKQJZF3CT+xn14ZZQO+KjxIIanH3Pvn4=", + "lastModified": 1716137900, + "narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4a6b83b05df1a8bd7d99095ec4b4d271f2956b64", + "rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1", "type": "github" }, "original": { diff --git a/meson.build b/meson.build index 17ba93e..8fabdb4 100644 --- a/meson.build +++ b/meson.build @@ -11,4 +11,9 @@ project( ], ) +assert( + get_option('lib') or get_option('cli'), + 'Either lib or cli option must be set to true.', +) + subdir('src') diff --git a/meson_options.txt b/meson_options.txt index 0966cdf..f110242 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,11 @@ -option('typelib', type: 'boolean', value: true, description: 'Needed files for runtime bindings') -option('cli_client', type: 'boolean', value: true, description: 'cli client for notifd') +option( + 'lib', + type: 'boolean', + value: true, +) + +option( + 'cli', + type: 'boolean', + value: true, +) diff --git a/src/cli.vala.in b/src/cli.vala index f49a056..e9001f5 100644 --- a/src/cli.vala.in +++ b/src/cli.vala @@ -6,7 +6,7 @@ static string invoke; static int close_n; static int get_n; -private const OptionEntry[] options = { +const OptionEntry[] options = { { "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref version, null, null }, { "help", 'h', OptionFlags.NONE, OptionArg.NONE, ref help, null, null }, { "daemon", 'd', OptionFlags.NONE, OptionArg.NONE, ref daemonize, null, null }, @@ -48,7 +48,7 @@ int main(string[] argv) { var notifd = new AstalNotifd.Notifd(); if (version) { - print("@VERSION@"); + print(AstalNotifd.VERSION); return 0; } diff --git a/src/config.vala.in b/src/config.vala.in new file mode 100644 index 0000000..7db3963 --- /dev/null +++ b/src/config.vala.in @@ -0,0 +1,6 @@ +namespace AstalNotifd { + const int MAJOR_VERSION = @MAJOR_VERSION@; + const int MINOR_VERSION = @MINOR_VERSION@; + const int MICRO_VERSION = @MICRO_VERSION@; + const string VERSION = "@VERSION@"; +} diff --git a/src/meson.build b/src/meson.build index e965647..b1d326c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,8 +1,19 @@ version_split = meson.project_version().split('.') api_version = version_split[0] + '.' + version_split[1] -notifd_gir = 'AstalNotifd-' + api_version + '.gir' -notifd_typelib = 'AstalNotifd-' + api_version + '.typelib' -notifd_so = 'libastal-notifd.so.' + meson.project_version() +gir = 'AstalNotifd-' + api_version + '.gir' +typelib = 'AstalNotifd-' + api_version + '.typelib' +so = 'libastal-notifd.so.' + meson.project_version() + +config = configure_file( + input: 'config.vala.in', + output: 'config.vala', + configuration: { + 'VERSION': meson.project_version(), + 'MAJOR_VERSION': version_split[0], + 'MINOR_VERSION': version_split[1], + 'MICRO_VERSION': version_split[2], + }, +) deps = [ dependency('glib-2.0'), @@ -12,64 +23,58 @@ deps = [ dependency('gdk-pixbuf-2.0'), ] -sources = files( +sources = [ + config, 'daemon.vala', 'notifd.vala', - 'proxy.vala', 'notification.vala', -) + 'proxy.vala', +] -libnotifd = library( - meson.project_name(), - sources, - dependencies: deps, - vala_header: meson.project_name() + '.h', - vala_vapi: meson.project_name() + '.vapi', - vala_gir: notifd_gir, - version: meson.project_version(), - install: true, - install_dir: [true, true, true, true], -) +if get_option('lib') + lib = library( + meson.project_name(), + sources, + dependencies: deps, + vala_header: meson.project_name() + '.h', + vala_vapi: meson.project_name() + '.vapi', + vala_gir: gir, + version: meson.project_version(), + install: true, + install_dir: [true, true, true, true], + ) -import('pkgconfig').generate( - description: 'libastal-notifd', - libraries: libnotifd, - name: meson.project_name(), - filebase: meson.project_name() + '-' + api_version, - version: meson.project_version(), - subdirs: meson.project_name(), - requires: 'gio-2.0', - install_dir: get_option('libdir') / 'pkgconfig', -) + import('pkgconfig').generate( + description: 'libastal-notifd', + libraries: lib, + name: meson.project_name(), + filebase: meson.project_name() + '-' + api_version, + version: meson.project_version(), + subdirs: meson.project_name(), + requires: deps, + install_dir: get_option('libdir') / 'pkgconfig', + ) -if get_option('typelib') custom_target( - notifd_typelib, + typelib, command: [ find_program('g-ir-compiler'), '--output', '@OUTPUT@', '--shared-library', get_option('prefix') / get_option('libdir') / '@PLAINNAME@', - meson.current_build_dir() / notifd_gir, + meson.current_build_dir() / gir, ], - input: libnotifd, - output: notifd_typelib, - depends: libnotifd, + input: lib, + output: typelib, + depends: lib, install: true, install_dir: get_option('libdir') / 'girepository-1.0', ) endif -if get_option('cli_client') - cli = configure_file( - input: 'cli.vala.in', - output: 'cli.vala', - configuration: { - 'VERSION': meson.project_version(), - }, - ) +if get_option('cli') executable( meson.project_name(), - [cli, sources], + ['cli.vala', sources], dependencies: deps, install: true, ) diff --git a/src/proxy.vala b/src/proxy.vala index 1f5870d..b5686fe 100644 --- a/src/proxy.vala +++ b/src/proxy.vala @@ -9,7 +9,6 @@ internal interface IDaemon : Object { public signal void notified(uint id); public signal void resolved(uint id, ClosedReason reason); - public signal void action_invoked(uint id, string action); public abstract void emit_notified(uint id); public abstract void emit_resolved(uint id, ClosedReason reason); |