Skip to content

Commit

Permalink
appmenu-gtk-module: meson as functional as CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Apr 25, 2019
1 parent f8edda2 commit 8867008
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 0 deletions.
15 changes: 15 additions & 0 deletions subprojects/appmenu-gtk-module/data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
install_data([
'org.appmenu.gtk-module.gschema.xml'
], install_dir: schema_dir)

systemd = dependency('systemd', required: false)

if systemd.found()
userunitdir = systemd.get_pkgconfig_variable('systemduserunitdir')
configure_file(
input: 'appmenu-gtk-module.service.in',
output: 'appmenu-gtk-module.service',
install_dir: userunitdir,
configuration: {'CMAKE_INSTALL_FULL_BINDIR': join_paths(prefix,get_option('bindir'))}
)
endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<SECTION>
<FILE>unity-gtk-action-group</FILE>
UnityGtkActionGroup
UnityGtkActionGroupClass
unity_gtk_action_group_new
unity_gtk_action_group_connect_shell
unity_gtk_action_group_disconnect_shell
unity_gtk_action_group_set_debug
<SUBSECTION Standard>
UNITY_GTK_ACTION_GROUP
UNITY_GTK_ACTION_GROUP_CLASS
UNITY_GTK_ACTION_GROUP_GET_CLASS
UNITY_GTK_IS_ACTION_GROUP
UNITY_GTK_IS_ACTION_GROUP_CLASS
UNITY_GTK_TYPE_ACTION_GROUP
unity_gtk_action_group_get_type
</SECTION>

<SECTION>
<FILE>unity-gtk-menu-shell</FILE>
UnityGtkMenuShell
UnityGtkMenuShellClass
unity_gtk_menu_shell_new
unity_gtk_menu_shell_set_debug
<SUBSECTION Standard>
UNITY_GTK_IS_MENU_SHELL
UNITY_GTK_IS_MENU_SHELL_CLASS
UNITY_GTK_MENU_SHELL
UNITY_GTK_MENU_SHELL_CLASS
UNITY_GTK_MENU_SHELL_GET_CLASS
UNITY_GTK_TYPE_MENU_SHELL
unity_gtk_menu_shell_get_type
</SECTION>

<SECTION>
<FILE>appmenu-gtk-parser</FILE>

</SECTION>
2 changes: 2 additions & 0 deletions subprojects/appmenu-gtk-module/docs/appmenu-gtk-parser.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unity_gtk_action_group_get_type
unity_gtk_menu_shell_get_type
28 changes: 28 additions & 0 deletions subprojects/appmenu-gtk-module/docs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ent_dict = {
'CMAKE_PROJECT_NAME' : meson.project_name(),
'PACKAGE_BUGREPORT': 'https://github.com/rilian-la-te/vala-panel-appmenu/issues',
'PACKAGE_STRING' : 'appmenu-gtk-parser',
'CPACK_SOURCE_PACKAGE_FILE_NAME': '@0@-@1@.tar.xz'.format(meson.project_name(),meson.project_version()),
'PACKAGE_URL' : 'https://github.com/rilian-la-te/vala-panel-appmenu',
'VERSION': meson.project_version(),
'PACKAGE_API_VERSION': meson.project_version()
}
ent = configure_file(
input: 'gtkdocentities.ent.in',
output: 'gtkdocentities.ent',
configuration: ent_dict
)

if build_gtk3
gnome.gtkdoc(
'appmenu-gtk-parser',
content_files: ent,
src_dir: 'lib',
gobject_typesfile: 'appmenu-gtk-parser.types',
dependencies: gtk3_parser_dep,
ignore_headers: lib_private_headers,
install: true,
main_sgml: 'appmenu-gtk-parser-docs.sgml'
)

endif
70 changes: 70 additions & 0 deletions subprojects/appmenu-gtk-module/lib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
lib_sources = files(
'unity-gtk-action-group.c',
'unity-gtk-action.c',
'unity-gtk-menu-shell.c',
'unity-gtk-menu-section.c',
'unity-gtk-menu-item.c',
)
lib_private_headers = [
'unity-gtk-action-group-private.h',
'unity-gtk-action-private.h',
'unity-gtk-menu-shell-private.h',
'unity-gtk-menu-section-private.h',
'unity-gtk-menu-item-private.h',
]
lib_headers = files(
'appmenu-gtk-action-group.h',
'appmenu-gtk-menu-shell.h',
'appmenu-gtk-parser.h'
)

parser_inc = include_directories('.')
parser_kwargs = {
'sources': lib_sources+lib_headers+lib_private_headers,
'install': true,
'version': meson.project_version(),
'soversion': '0'
}
pc_kwargs = {
'description': 'GtkMenuShell to GMenuModel parser',
'variables': ['exec_prefix=@0@'.format(join_paths(prefix,get_option('libexecdir')))],
'extra_cflags': ['-I${includedir}/appmenu-gtk-parser']
}

if build_gtk2
gtk2_parser_lib = shared_library(
'appmenu-gtk2-parser',
dependencies: gtk2,
kwargs: parser_kwargs
)
pkgconfig.generate(gtk2_parser_lib,
requires: gtk2,
kwargs: pc_kwargs
)
gtk2_parser_dep = declare_dependency(
include_directories: parser_inc,
link_with: gtk2_parser_lib,
dependencies: gtk2
)
endif

if build_gtk3
gtk3_parser_lib = shared_library(
'appmenu-gtk3-parser',
dependencies: gtk3,
kwargs: parser_kwargs
)
pkgconfig.generate(gtk3_parser_lib,
requires: gtk3,
kwargs: pc_kwargs
)
gtk3_parser_dep = declare_dependency(
include_directories: parser_inc,
link_with: gtk3_parser_lib,
dependencies: gtk3
)
endif

if build_gtk2 or build_gtk3
install_headers(lib_headers, subdir: 'appmenu-gtk-parser')
endif
64 changes: 64 additions & 0 deletions subprojects/appmenu-gtk-module/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
project('appmenu-gtk-module', 'c',
meson_version: '>=0.49.0',
version: '0.7',
license: ['LGPL-3.0'],
default_options: [
'c_std=gnu11',
'buildtype=debugoptimized',
'warning_level=1'
])

##################
# Module imports #
##################

gnome = import('gnome')
i18n = import('i18n')
pkgconfig = import('pkgconfig')

###############
# Directories #
###############
prefix = get_option('prefix')
datadir = get_option('datadir')
localedir = get_option('localedir')
schema_dir = join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
docdir = join_paths(prefix,datadir, 'doc')

################
# Dependencies #
################
glib_ver = '>=2.52.0'
giounix = dependency('gio-unix-2.0', version: glib_ver)

gtk_versions = get_option('gtk')
gtk2_requested = '2' in gtk_versions
gtk3_requested = '3' in gtk_versions

gtk2_ver = '>=2.24.0'
gtk3_ver = '>=3.22.0'

gtk2 = dependency('gtk+-2.0', version: gtk2_ver, required: gtk2_requested)
gtk3 = dependency('gtk+-3.0', version: gtk3_ver, required: gtk3_requested)

build_gtk2 = gtk2.found()
build_gtk3 = gtk3.found()

#################
# Configuration #
#################

readmes = [
'README.md',
'LICENSE',
'TODO',
'AUTHORS'
]
install_data(readmes, install_dir : join_paths(get_option('datadir'), meson.project_name(), 'doc'))


subdir('lib')
subdir('src')
subdir('data')
subdir('docs')
subdir('tests')
2 changes: 2 additions & 0 deletions subprojects/appmenu-gtk-module/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('gtk', type: 'array', choices : ['2','3'], value: ['2','3'], description: 'Supported GTK versions')
option('tests', type : 'boolean', value : false, description: 'Parser tests')
6 changes: 6 additions & 0 deletions subprojects/appmenu-gtk-module/src/gtk-2.0/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gtk2_module = shared_module(
'appmenu-gtk-module', module_sources,
dependencies: gtk2_parser_dep,
install: true,
install_dir: join_paths(gtk2.get_pkgconfig_variable('libdir'),'gtk-2.0','modules')
)
6 changes: 6 additions & 0 deletions subprojects/appmenu-gtk-module/src/gtk-3.0/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gtk3_module = shared_module(
'appmenu-gtk-module', module_sources,
dependencies: gtk3_parser_dep,
install: true,
install_dir: join_paths(gtk3.get_pkgconfig_variable('libdir'),'gtk-3.0','modules')
)
25 changes: 25 additions & 0 deletions subprojects/appmenu-gtk-module/src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module_sources = files(
'appmenu-gtk-module.c',
'datastructs.c',
'datastructs.h',
'datastructs-private.h',
'hijack.c',
'hijack.h',
'support.c',
'support.h',
'blacklist.c',
'blacklist.h',
'platform.c',
'platform.h',
'consts.h'
)

module_subdirs = ['gtk-2.0','gtk-3.0']

if build_gtk2
subdir('gtk-2.0')
endif

if build_gtk3
subdir('gtk-3.0')
endif
36 changes: 36 additions & 0 deletions subprojects/appmenu-gtk-module/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if build_gtk3 and get_option('tests')
client_sources = files (
join_paths('demos','altgrabber.h'),
join_paths('demos','altgrabber.c'),
join_paths('demos','altmonitor.h'),
join_paths('demos','altmonitor.c'),
join_paths('demos','menusource.h'),
join_paths('demos','menusource.c'),
join_paths('demos','client.c'))

wnck_ver = '>=3.4.8'
wnck = dependency('libwnck-3.0',version: wnck_ver, required: false)
x11 = dependency('x11', required: false)
if(wnck.found() and x11.found())
client = executable('menumodel-client',client_sources,
dependencies: [gtk3_parser_dep, wnck, x11]
)
# test('client', client)
endif
tester = executable('tester',join_paths('demos','unity-gtk-menu-tester.c'), dependencies: gtk3)
# test('tester',tester)
radio = executable('radio',join_paths('demos','test-radio.c'), dependencies: gtk3)
# test('radio',radio)
hello = executable('hello',join_paths('demos','hello.c'), dependencies: gtk3)
# test('hello',hello)
vala_found = add_languages('vala', required: false)
if vala_found
black = executable('black',join_paths('demos','black.vala'), dependencies: gtk3)
# test('black',black)
endif
endif

#TODO: fix autopilot
run_target('autopilot',
command: ['autopilot/test.sh'],
)

0 comments on commit 8867008

Please sign in to comment.