diff options
author | zhuyaliang <[email protected]> | 2023-06-01 20:38:12 +0800 |
---|---|---|
committer | Luke from DC <[email protected]> | 2023-06-01 19:26:53 +0000 |
commit | aa2e7876d6c1518e2a2419755e9d618e9be61ec6 (patch) | |
tree | ac47aa394bf7f4e30b8c41b6f21f460b9a9c397e | |
parent | bcbcc533539f7d27910f35e01f17240e8c72cdad (diff) | |
download | libmatekbd-aa2e7876d6c1518e2a2419755e9d618e9be61ec6.tar.bz2 libmatekbd-aa2e7876d6c1518e2a2419755e9d618e9be61ec6.tar.xz |
Add meson compilation support
-rw-r--r-- | libmatekbd/meson.build | 160 | ||||
-rw-r--r-- | meson.build | 59 | ||||
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | po/meson.build | 3 | ||||
-rw-r--r-- | test/meson.build | 17 |
5 files changed, 245 insertions, 0 deletions
diff --git a/libmatekbd/meson.build b/libmatekbd/meson.build new file mode 100644 index 0000000..675920e --- /dev/null +++ b/libmatekbd/meson.build @@ -0,0 +1,160 @@ +pkg_data_dir = get_option('prefix') / get_option('datadir') / 'libmatekbd' +ui_dir = pkg_data_dir / 'ui' +pkg = import('pkgconfig') + +install_data( + 'show-layout.ui', + install_dir: ui_dir +) + +gsettings_cfg = configuration_data() +gsettings_cfg.set('GETTEXT_PACKAGE', gettext_domain) + +configure_file( + input: 'org.mate.peripherals-keyboard-xkb.gschema.xml.in', + output: 'org.mate.peripherals-keyboard-xkb.gschema.xml', + configuration: gsettings_cfg, + install: true, + install_dir: get_option('prefix') / get_option('datadir') / 'glib-2.0' / 'schemas' +) + +gresource_files = gnome.compile_resources('matekbd-keyboard-drawing-resources', 'org.mate.peripherals.keyboard.gresource.xml', c_name : 'matekbd') + +libmatekbd_deps = [ + glib_dep, + gobject_dep, + gio_dep, + gdk_dep, + gtk_dep, + x11_dep, + libxklavier_dep, +] + +libmatekbd_sources = files( + 'matekbd-desktop-config.c', + 'matekbd-keyboard-config.c', + 'matekbd-util.c', +) + +libmatekbd_headers = files( + 'matekbd-desktop-config.h', + 'matekbd-keyboard-config.h', + 'matekbd-util.h', +) + +libmatekbd_lib = library( + 'matekbd', + libmatekbd_sources, + config_h, + dependencies: libmatekbd_deps, + include_directories: root_include, + version: library_version, + install: true, +) + +pkg.generate( + libmatekbd_lib, + name: 'libmatekbd', + description: 'MATE keyboard shared library', + version: meson.project_version(), +) + +libmatekbd_dep = declare_dependency( + link_with: libmatekbd_lib, + include_directories: root_include, + dependencies: libmatekbd_deps, + sources: config_h, +) + +libmatekbdui_sources = files( + 'matekbd-indicator-config.c', + 'matekbd-indicator.c', + 'matekbd-status.c', + 'matekbd-keyboard-drawing.c', +) + +libmatekbdui_headers = files( + 'matekbd-indicator.h', + 'matekbd-status.h', + 'matekbd-indicator-config.h', + 'matekbd-keyboard-drawing.h', +) +matekbd_indicator_marshal = gnome.genmarshal( + 'matekbd-indicator-marshal', + prefix: 'matekbd_indicator', + sources: 'matekbd-indicator-marshal.list', +) + +matekbd_keyboard_drawing_marshal = gnome.genmarshal( + 'matekbd-keyboard-drawing-marshal', + prefix: 'matekbd_keyboard_drawing', + sources: 'matekbd-keyboard-drawing-marshal.list', +) + + +libmatekbdui_deps = [ + libmatekbd_dep, + m_dep, +] + +libmatekbdui_lib = library( + 'matekbdui', + libmatekbdui_sources, + gresource_files, + config_h, + matekbd_indicator_marshal, + matekbd_keyboard_drawing_marshal, + dependencies: libmatekbdui_deps, + include_directories: root_include, + version: library_version, + c_args: [ + '-DUIDIR="@0@"'.format(ui_dir), + '-DDATADIR="@0@"'.format(pkg_data_dir), + ], + install: true, +) + +pkg.generate( + libmatekbdui_lib, + name: 'libmatekbdui', + description: 'MATE keyboard shared library', + version: meson.project_version(), +) + +libmatekbdui_dep = declare_dependency( + link_with: libmatekbdui_lib, + include_directories: root_include, + dependencies: libmatekbdui_deps, + sources: [config_h, matekbd_indicator_marshal, matekbd_keyboard_drawing_marshal], +) + +install_headers( + libmatekbd_headers, + libmatekbdui_headers, + subdir: 'libmatekbd', +) + +if get_option('gir') + gir_dir = join_paths(get_option('prefix') / get_option('datadir'), '@0@-@1@'.format('gir', matekbd_gir_version)) + typelib_dir = join_paths(get_option('prefix') / get_option('libdir'), '@0@-@1@'.format('girepository', matekbd_gir_version)) + + gnome.generate_gir( + libmatekbd_lib, libmatekbdui_lib, + sources: [ + libmatekbd_sources, + libmatekbdui_sources, + libmatekbd_headers, + libmatekbdui_headers, + matekbd_indicator_marshal, + matekbd_keyboard_drawing_marshal, + ], + dependencies: [ libmatekbd_deps, m_dep ], + include_directories: root_include, + namespace: 'Matekbd', + nsversion: '3.0', + includes: ['GObject-2.0', 'Gtk-3.0', 'xlib-2.0', 'Xkl-1.0'], + install: true, + install_dir_gir: gir_dir, + install_dir_typelib: typelib_dir, + ) +endif diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..95aec76 --- /dev/null +++ b/meson.build @@ -0,0 +1,59 @@ +project('libmatekbd', 'c', + version: '1.27.0', + default_options: [ + 'buildtype=debugoptimized', + 'warning_level=1', + # We only need c99, but glib needs GNU-specific features + # https://github.com/mesonbuild/meson/issues/2289 + 'c_std=gnu99', + ], + meson_version : '>= 0.55', + license: 'LGPL-2.1-or-later') + +library_version = '6.0.2' +matekbd_gir_version = '1.0' +gettext_domain = 'libmatekbd' +prefix = get_option('prefix') + +gnome = import('gnome') +i18n = import('i18n') + +cc = meson.get_compiler('c') + +glib_req = '>= 2.45.0' +gio_req = '>= 2.25.0' +gdk_req = '>= 3.22.0' +gtk_req = '>= 3.22.0' +libxklavier_req = '>= 5.2' + +glib_dep = dependency('glib-2.0', version: glib_req) +gobject_dep = dependency('gobject-2.0', version: glib_req) +gio_dep = dependency('gio-2.0', version: gio_req) +gdk_dep = dependency('gdk-3.0', version: gdk_req) +gtk_dep = dependency('gtk+-3.0', version: gtk_req) +x11_dep = dependency('x11') +libxklavier_dep = dependency('libxklavier', version: libxklavier_req) +m_dep = cc.find_library('m', required : false) + +add_project_arguments('-DGETTEXT_PACKAGE="@0@"'.format(gettext_domain), language: 'c') +add_project_arguments('-DHAVE_CONFIG_H=1', language: 'c') + + +config_cfg = configuration_data() +config_cfg.set_quoted('VERSION', meson.project_version()) +config_cfg.set_quoted('MATELOCALEDIR', join_paths(prefix, get_option('localedir'))) + +config_h = configure_file( + output: 'config.h', + configuration: config_cfg, +) + +root_include = include_directories('.') + +subdir('libmatekbd') + +subdir('po') + +if get_option('tests') + subdir('test') +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..3ed7f5f --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option('gir', + type: 'boolean', value: true, + description: 'Generate gir data (requires gobject-introspection)') +option('tests', + type : 'boolean', value : true, + description: 'Enable tests') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..9d25185 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,3 @@ +i18n = import('i18n') + +i18n.gettext(gettext_domain, preset : 'glib')
\ No newline at end of file diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..f207073 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,17 @@ +test_names = [ + 'matekbd-indicator-test', + 'matekbd-keyboard-drawing-test', + 'matekbd-status-test', +] + +foreach test_name : test_names + test_exec = executable( + test_name, + test_name + '.c', + dependencies: libmatekbdui_dep, + c_args: [ + '-DGNOMELOCALEDIR="@0@"'.format (get_option('prefix') / get_option('datadir') / 'locale'), + ], + build_by_default: true, + ) +endforeach |