update meson format

This commit is contained in:
Aylur
2024-05-22 00:14:54 +02:00
parent f81468a398
commit 2f8354f134
7 changed files with 73 additions and 49 deletions

6
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1715266358, "lastModified": 1716293225,
"narHash": "sha256-doPgfj+7FFe9rfzWo1siAV2mVCasW+Bh8I1cToAXEE4=", "narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f1010e0469db743d14519a1efd37e23f8513d714", "rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -14,4 +14,9 @@ project(
# math # math
add_project_arguments(['-X', '-lm'], language: 'vala') add_project_arguments(['-X', '-lm'], language: 'vala')
assert(
get_option('lib') or get_option('cli'),
'Either lib or cli option must be set to true.',
)
subdir('src') subdir('src')

View File

@@ -1,2 +1,11 @@
option('typelib', type: 'boolean', value: true, description: 'Needed files for runtime bindings') option(
option('cli_client', type: 'boolean', value: true, description: 'Minimal cli client for Astal applications') 'lib',
type: 'boolean',
value: true,
)
option(
'cli',
type: 'boolean',
value: true,
)

View File

@@ -97,14 +97,13 @@ public class Application : Gtk.Application {
} }
try { try {
SocketAddress _;
service = new SocketService(); service = new SocketService();
service.add_address( service.add_address(
new UnixSocketAddress(socket), new UnixSocketAddress(socket),
SocketType.STREAM, SocketType.STREAM,
SocketProtocol.DEFAULT, SocketProtocol.DEFAULT,
null, null,
out _); null);
service.incoming.connect((conn) => { service.incoming.connect((conn) => {
_socket_request.begin(conn); _socket_request.begin(conn);
@@ -151,8 +150,7 @@ public errordomain WindowError {
public async string read_sock(SocketConnection conn) { public async string read_sock(SocketConnection conn) {
try { try {
var stream = new DataInputStream(conn.input_stream); var stream = new DataInputStream(conn.input_stream);
size_t size; return yield stream.read_upto_async("\x04", -1, Priority.DEFAULT, null, null);
return yield stream.read_upto_async("\x04", -1, Priority.DEFAULT, null, out size);
} catch (Error err) { } catch (Error err) {
critical(err.message); critical(err.message);
return err.message; return err.message;

6
src/config.vala.in Normal file
View File

@@ -0,0 +1,6 @@
namespace Astal {
public const int MAJOR_VERSION = @MAJOR_VERSION@;
public const int MINOR_VERSION = @MINOR_VERSION@;
public const int MICRO_VERSION = @MICRO_VERSION@;
public const string VERSION = "@VERSION@";
}

View File

@@ -1,8 +1,19 @@
version_split = meson.project_version().split('.') version_split = meson.project_version().split('.')
api_version = version_split[0] + '.' + version_split[1] api_version = version_split[0] + '.' + version_split[1]
astal_gir = 'Astal-' + api_version + '.gir' gir = 'Astal-' + api_version + '.gir'
astal_typelib = 'Astal-' + api_version + '.typelib' typelib = 'Astal-' + api_version + '.typelib'
astal_so = 'libastal.so.' + meson.project_version() so = 'libastal.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 = [ deps = [
dependency('glib-2.0'), dependency('glib-2.0'),
@@ -14,7 +25,8 @@ deps = [
dependency('gtk-layer-shell-0'), dependency('gtk-layer-shell-0'),
] ]
sources = files( sources = [
config,
'widget/box.vala', 'widget/box.vala',
'widget/button.vala', 'widget/button.vala',
'widget/centerbox.vala', 'widget/centerbox.vala',
@@ -27,58 +39,52 @@ sources = files(
'process.vala', 'process.vala',
'time.vala', 'time.vala',
'variable.vala', 'variable.vala',
) ]
libastal = library( if get_option('lib')
meson.project_name(), lib = library(
sources, meson.project_name(),
dependencies: deps, sources,
vala_header: meson.project_name() + '.h', dependencies: deps,
vala_vapi: meson.project_name() + '.vapi', vala_header: meson.project_name() + '.h',
vala_gir: astal_gir, vala_vapi: meson.project_name() + '.vapi',
version: meson.project_version(), vala_gir: gir,
install: true, version: meson.project_version(),
install_dir: [true, true, true, true], install: true,
) install_dir: [true, true, true, true],
)
import('pkgconfig').generate( import('pkgconfig').generate(
description: 'libastal', description: 'libastal-notifd',
libraries: libastal, libraries: lib,
name: meson.project_name(), name: meson.project_name(),
filebase: meson.project_name() + '-' + api_version, filebase: meson.project_name() + '-' + api_version,
version: meson.project_version(), version: meson.project_version(),
subdirs: meson.project_name(), subdirs: meson.project_name(),
requires: 'gio-2.0', requires: deps,
install_dir: get_option('libdir') / 'pkgconfig', install_dir: get_option('libdir') / 'pkgconfig',
) )
if get_option('typelib')
custom_target( custom_target(
astal_typelib, typelib,
command: [ command: [
find_program('g-ir-compiler'), find_program('g-ir-compiler'),
'--output', '@OUTPUT@', '--output', '@OUTPUT@',
'--shared-library', get_option('prefix') / get_option('libdir') / '@PLAINNAME@', '--shared-library', get_option('prefix') / get_option('libdir') / '@PLAINNAME@',
meson.current_build_dir() / astal_gir, meson.current_build_dir() / gir,
], ],
input: libastal, input: lib,
output: astal_typelib, output: typelib,
depends: libastal, depends: lib,
install: true, install: true,
install_dir: get_option('libdir') / 'girepository-1.0', install_dir: get_option('libdir') / 'girepository-1.0',
) )
endif endif
if get_option('cli_client') if get_option('cli')
executable( executable(
meson.project_name(), meson.project_name(),
configure_file( ['cli.vala', sources],
input: 'client.vala.in',
output: 'client.vala',
configuration: {
'VERSION': meson.project_version(),
},
),
dependencies: deps, dependencies: deps,
install: true, install: true,
) )