[gtk+/wip/meson: 100/135] meson: build input modules
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/meson: 100/135] meson: build input modules
- Date: Fri, 28 Apr 2017 22:21:48 +0000 (UTC)
commit f5e1a9a1cdd08dee1bb0c57538188b84dbae23a6
Author: Tim-Philipp Müller <tim centricular com>
Date: Thu Mar 23 15:54:58 2017 +0000
meson: build input modules
We have to work around some ordering problems here. We still
manage to keep most of the guts in modules/input/meson.build,
so it's not too ugly overall.
(The autotools build solves this with a 'make -C ../../input/modules'
inside gtk/Makefile, but that's not something we can or want to do.)
config.h.meson | 3 -
gdk/meson.build | 1 +
gsk/meson.build | 1 +
gtk/meson.build | 41 +++++++++++++++---
meson.build | 8 +++
meson_options.txt | 4 ++
modules/input/meson.build | 105 +++++++++++++++++++++++++++++++++++++++++++++
modules/meson.build | 2 +-
8 files changed, 155 insertions(+), 10 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 1200bd0..158907f 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -213,9 +213,6 @@
/* Define to 1 if you have the ANSI C header files. */
#mesondefine STDC_HEADERS
-/* Define to 1 if gmodule works and should be used */
-#mesondefine USE_GMODULE
-
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
diff --git a/gdk/meson.build b/gdk/meson.build
index 48d8a82..35cf05e 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -144,6 +144,7 @@ gdkinc = include_directories('.')
xinc = include_directories('x11')
wlinc = include_directories('.')
+gdk_gen_headers = [gdkenum_h, gdkmarshal_h, gdkconfig, gdkversionmacros]
gdk_deps = [
libm,
diff --git a/gsk/meson.build b/gsk/meson.build
index 0b87438..cbd6bdf 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -143,6 +143,7 @@ gskresources = gnome.compile_resources('gskresources',
c_name: '_gsk',
extra_args: '--manual-register')
+gsk_gen_headers = [gskenum_h]
gsk_deps = [
graphene_dep,
diff --git a/gtk/meson.build b/gtk/meson.build
index a843e81..6524de2 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -770,6 +770,8 @@ gtk_cargs = [
'-DGTK_DATA_PREFIX="'+ get_option('prefix') + '"',
]
+gtk_gen_headers = [gtkmarshal_h, gtktypebuiltins_h, gtkprivatetypebuiltins_h, gtkversion]
+
gtk_sources += [
gtk_dbus_src,
gtk_deprecated_sources,
@@ -840,11 +842,38 @@ if cc.has_header('langinfo.h')
endforeach
endif
-# check token HAVE__NL_MEASUREMENT_MEASUREMENT
-# check token HAVE__NL_PAPER_HEIGHT
-# check token HAVE__NL_PAPER_WIDTH
-# check token HAVE__NL_TIME_FIRST_WEEKDAY
+# Input methods
+
+gen_headers = [gtk_gen_headers, gsk_gen_headers, gdk_gen_headers]
+
+included_input_modules = []
+foreach m : inc_im_method_defs # populated in modules/input/meson.build
+ im_name = m[0]
+ im_srcs = m[1]
+ im_args = m[2]
+ im_libs = m[3]
+ included_input_modules += static_library('im-@0@'.format(im_name),
+ im_srcs, gen_headers,
+ c_args : im_args,
+ include_directories : [confinc, gdkinc, gtkinc],
+ dependencies : gtk_deps + im_libs)
+endforeach
+
+foreach m : dyn_im_method_defs # populated in modules/input/meson.build
+ im_name = m[0]
+ im_srcs = m[1]
+ im_args = m[2]
+ im_libs = m[3]
+
+ shared_module('im-@0@'.format(im_name), im_srcs, gen_headers,
+ c_args : im_args,
+ include_directories : [confinc, gdkinc, gtkinc],
+ dependencies : gtk_deps + im_libs,
+ name_prefix : '', # we want im-foo.so not libim-foo.so
+ install_dir : immodules_install_dir,
+ install : true)
+endforeach
# Library
@@ -853,7 +882,7 @@ libgtk = shared_library('gtk-4',
c_args: gtk_cargs,
include_directories: [confinc, gdkinc, gtkinc],
dependencies: gtk_deps + [libgdk_dep, libgsk_dep],
- link_with: [libgdk, libgsk],
+ link_with: [libgdk, libgsk, included_input_modules],
link_args: ['-Bsymbolic'],
install: true)
diff --git a/meson.build b/meson.build
index 5158c8b..5a46c8b 100644
--- a/meson.build
+++ b/meson.build
@@ -183,6 +183,8 @@ graphene_dep = dependency('graphene-1.0', version: graphene_req,
fontconfig_dep = [] # only used in x11 backend
atkbridge_dep = [] # only used in x11 backend
+backend_immodules = []
+
pc_gdk_extra_libs = []
cairo_backends = []
@@ -229,6 +231,8 @@ if x11_enabled
fontconfig_dep = dependency('fontconfig')
atkbridge_dep = dependency('atk-bridge-2.0', version: atk_req)
+ backend_immodules += ['xim']
+
x11_pkgs = ['fontconfig', 'x11', 'xext', 'xi', 'xrandr']
if xcursor_dep.found()
@@ -310,16 +314,19 @@ endif
if broadway_enabled
pc_gdk_extra_libs += ['-lz']
+ backend_immodules += ['broadway']
endif
if quartz_enabled
pc_gdk_extra_libs += ['-framework Cocoa', '-framework Carbon']
+ backend_immodules += ['quartz']
endif
if win32_enabled
pc_gdk_extra_libs += ['-lgdi32', '-limm32', '-lshell32', '-lole32',
'-Wl,-luuid', '-lwinmm', '-ldwmapi', '-lsetupapi',
'-lcfgmgr32']
+ backend_immodules += ['ime']
endif
# Check for bind_textdomain_codeset, including -lintl if GLib brings it in
@@ -346,6 +353,7 @@ else
message('Vulkan support explicitly disabled')
endif
+subdir('modules/input')
subdir('gdk')
subdir('gsk')
subdir('gtk')
diff --git a/meson_options.txt b/meson_options.txt
index bf80420..d23e319 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,3 +20,7 @@ option('enable-cloudprint-print-backend', type: 'combo', choices : ['yes', 'no',
description : 'Enable the cloudprint print backend')
option('enable-xinerama', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Enable support for the Xinerama extension')
+option('disable-modules', type: 'boolean', value : 'false',
+ description : 'Disable dynamic module loading')
+option('with-included-immodules', type: 'string', value : '',
+ description : 'Build the specified input methods into gtk (comma-separated list or "all" or "none")')
diff --git a/modules/input/meson.build b/modules/input/meson.build
new file mode 100644
index 0000000..90be67f
--- /dev/null
+++ b/modules/input/meson.build
@@ -0,0 +1,105 @@
+# Note: this file is included from the top-level before gtk/meson.build.
+# The actual input modules are then built in gtk/meson.build based on the
+# defs we provide here. It has to be that way because included input methods
+# need to be built before libgtk-4.so is built, so before gtk/meson.build, but
+# all input methods also rely on gtk generated headers to be created first, so
+# there is a bit of an ordering problem which we solve by collecting all the
+# information here but moving the actual build definitions to gtk/meson.build.
+build_dynamic_modules = false
+disable_modules = get_option('disable-modules')
+if not disable_modules
+ runcmd = run_command('pkg-config', '--variable=gmodule_supported', 'gmodule-no-export-2.0')
+ if runcmd.returncode() == 0
+ gmodule_supported = runcmd.stdout().strip()
+ if gmodule_supported == 'true'
+ build_dynamic_modules = true
+ else
+ message('Modules are not supported according to gmodule-no-export-2.0.pc')
+ endif
+ else
+ message('WARNING: failed to query if modules are supported!')
+ endif
+endif
+
+all_immodules = ['am-et', 'cedilla', 'cyrillic-translit', 'inuktitut',
+ 'ipa', 'multipress', 'thai', 'ti-er', 'ti-et', 'viqr']
+
+all_immodules += backend_immodules
+
+# Allow building some or all immodules included
+included_immodules = get_option('with-included-immodules')
+if included_immodules == 'none'
+ included_immodules = ''
+elif included_immodules == 'all' or included_immodules == 'yes'
+ included_immodules = ','.join(all_immodules)
+endif
+
+if included_immodules == ''
+ have_included_immodules = false
+ included_immodules = []
+else
+ have_included_immodules = true
+ included_immodules = included_immodules.split(',')
+endif
+
+foreach im : included_immodules
+ if not all_immodules.contains(im)
+ error('The specified input method "@0@" is not available (available methods: @1@)'.format(im, ',
'.join(all_immodules)))
+ endif
+endforeach
+
+immodules_subdir = 'gtk-4.0/@0@/immodules'.format(gtk_binary_version)
+immodules_install_dir = join_paths(get_option('libdir'), immodules_subdir)
+
+sysconfdir = join_paths(get_option('prefix'),get_option('sysconfdir'))
+mp_confdir = join_paths(sysconfdir, 'gtk-4.0')
+mp_cargs = [
+ '-DMULTIPRESS_LOCALEDIR=""', # FIXME: where is $(mplocaledir) ever set?
+ '-DMULTIPRESS_CONFDIR="@0@"'.format(mp_confdir),
+]
+install_data('im-multipress.conf', install_dir : mp_confdir)
+
+method_defs = [
+ ['am-et', files('imam-et.c')],
+ ['cedilla', files('imcedilla.c')],
+ ['cyrillic-translit', files('imcyrillic-translit.c')],
+ ['ti-er', files('imti-er.c')],
+ ['ti-et', files('imti-et.c')],
+ ['thai', files('thai-charprop.c', 'gtkimcontextthai.c', 'imthai.c')],
+ ['viqr', files('imviqr.c')],
+ ['inuktitut', files('iminuktitut.c')],
+ ['ipa', files('imipa.c')],
+ # backend modules
+ ['broadway', files('imbroadway.c')],
+ ['multipress', files('gtkimcontextmultipress.c', 'immultipress.c'), [], mp_cargs],
+ ['quartz', ('imquartz.c'), [], ('-xobjective-c')],
+ ['xim', files('gtkimcontextxim.c', 'imxim.c')],
+ ['ime', files('gtkimcontextime.c', 'imime.c'), ['imm32']],
+]
+
+inc_im_method_defs = []
+dyn_im_method_defs = []
+
+foreach m : method_defs
+ im = m.get(0)
+ srcs = m.get(1)
+ cargs = m.get(3, [])
+ libs = []
+
+ # only use backend-specific input methods for backends that are enabled
+ if all_immodules.contains(im)
+ # check for extra libs lazily
+ foreach libname : m.get(2, [])
+ libs += [cc.find_library(libname)]
+ endforeach
+
+ if included_immodules.contains(im)
+ cdata.set('INCLUDE_IM_@0@'.format(im.underscorify()), true)
+ inc_im_method_defs += [[im, srcs, cargs, libs]]
+ elif build_dynamic_modules
+ dyn_im_method_defs += [[im, srcs, cargs, libs]]
+ endif
+ endif
+endforeach
+
+# TODO: post-install gtk4-query-immodules run to create immodules.c
diff --git a/modules/meson.build b/modules/meson.build
index b855765..d0c4adc 100644
--- a/modules/meson.build
+++ b/modules/meson.build
@@ -1,4 +1,4 @@
-#subdir('input')
+# Note: 'input' subdir has already been included from top-level.
if os_unix
subdir('printbackends')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]