Commit 21395797 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller Committed by Matthias Clasen

meson: Fix glib, add gobject, gio, gthread, gmodule, etc

Several small fixes to the build files.

Lots of tests have also been added, and glib tests pass now.
parent 98e64142
This diff is collapsed.
#!/usr/bin/env python3
# This is in its own file rather than inside meson.build
# because a) mixing the two is ugly and b) trying to
# make special characters such as \n go through all
# backends is a fool's errand.
import sys, os, shutil, subprocess
ofilename = sys.argv[1]
template_file_dir = sys.argv[2]
template_file_path = template_file_dir + '/' + ofilename + '.template'
headers = sys.argv[3:]
arg_array = ['--template', template_file_path ]
# FIXME: should use $top_builddir/gobject/glib-mkenums
cmd = [shutil.which('perl'), shutil.which('glib-mkenums')]
pc = subprocess.Popen(cmd + arg_array + headers, stdout=subprocess.PIPE)
(stdo, _) = pc.communicate()
if pc.returncode != 0:
sys.exit(pc.returncode)
open(ofilename, 'wb').write(stdo)
inotify_sources = [
'inotify-kernel.c',
'inotify-sub.c',
'inotify-path.c',
'inotify-missing.c',
'inotify-helper.c',
'ginotifyfilemonitor.c',
]
inotify_lib = static_library('inotify',
sources : inotify_sources,
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
kqueue_sources = [
'gkqueuefilemonitor.c',
'kqueue-helper.c',
'kqueue-thread.c',
'kqueue-sub.c',
'kqueue-missing.c',
'kqueue-utils.c',
'kqueue-exclusions.c',
'dep-list.c',
]
kqueue_lib = static_library('kqueue',
sources : kqueue_sources,
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
This diff is collapsed.
# Test programs buildable on all platforms
gio_tests = [
'appmonitor',
'async-close-output-stream',
'async-splice-output-stream',
'buffered-input-stream',
'buffered-output-stream',
'cancellable',
'contexts',
'contenttype',
'converter-stream',
'credentials',
'data-input-stream',
'data-output-stream',
#'defaultvalue', # FIXME: needs giotypefuncs.c generated
'fileattributematcher',
'filter-streams',
'giomodule',
'gsubprocess',
'g-file',
'g-file-info',
'g-icon',
'gdbus-addresses',
'gdbus-message',
'inet-address',
'io-stream',
'memory-input-stream',
'memory-output-stream',
'monitor',
'network-address',
'network-monitor',
'permission',
'pollable',
'proxy-test',
'readwrite',
'simple-async-result',
'simple-proxy',
'sleepy-stream',
'socket',
'socket-listener',
'socket-service',
'srvtarget',
'task',
'vfs',
'volumemonitor',
'glistmodel',
'testfilemonitor',
]
gio_tests += [
'thumbnail-verification',
]
# Test programs buildable on UNIX only
if host_machine.system() != 'windows'
gio_tests += [
'file',
'gdbus-peer-object-manager',
'gdbus-unix-addresses',
'live-g-file',
'socket-address',
'stream-rw_all',
'unix-fd',
'unix-streams',
]
endif
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
gio_tests += [ 'autoptr' ]
endif
test_env = [
'G_TEST_SRCDIR=' + meson.current_source_dir(),
'G_TEST_BUILDDIR=' + meson.current_build_dir(),
]
test_c_args = [
'-DHAVE_CONFIG_H=1',
'-DG_LOG_DOMAIN="GLib-GIO"',
'-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
]
foreach test_name : gio_tests
src_file = '@0@.c'.format(test_name)
# conflicts with glib/tests/autoptr, can't have two targets with same name
if test_name == 'autoptr'
test_name = 'autoptr-gio'
endif
exe = executable(test_name, src_file,
include_directories : inc_dirs,
install : false,
c_args : test_c_args,
link_with : [ libgio, libgmodule, libglib ],
dependencies : deps,
)
if test_name == 'testfilemonitor'
test(test_name, exe, env : test_env, timeout : 45)
else
test(test_name, exe, env : test_env)
endif
endforeach
uninstalled_test_extra_programs = [
'gio-du',
'echo-server',
'filter-cat',
'gapplication-example-actions',
'gapplication-example-cmdline',
'gapplication-example-cmdline2',
'gapplication-example-cmdline3',
'gapplication-example-dbushooks',
'gapplication-example-open',
'gdbus-example-export',
'gdbus-example-own-name',
'gdbus-example-peer',
'gdbus-example-proxy-subclass',
'gdbus-example-server',
'gdbus-example-subtree',
'gdbus-example-watch-name',
'gdbus-example-watch-proxy',
'gsubprocess-testprog',
'httpd',
'proxy',
'resolver',
'send-data',
'socket-server',
]
foreach extra_program : uninstalled_test_extra_programs
exe = executable(extra_program, '@0@.c'.format(extra_program),
include_directories : inc_dirs,
install : false,
c_args : test_c_args,
link_with : [ libgio, libgmodule, libglib ],
dependencies : deps,
)
endforeach
test_extra_programs = [
'gdbus-connection-flush-helper',
'gdbus-testserver',
]
exe = executable('tls-certificate', 'tls-certificate.c', 'gtesttlsbackend.c',
include_directories : inc_dirs,
c_args : test_c_args,
link_with : [ libgio, libgmodule, libglib ],
dependencies : deps,
)
test('tls-certificate', exe, env : test_env)
exe = executable('socket-client', 'socket-client.c', 'gtlsconsoleinteraction.c',
include_directories : inc_dirs,
c_args : test_c_args,
link_with : [ libgio, libgmodule, libglib ],
dependencies : deps,
)
#exe = executable('gdbus-daemon', 'gdbus-daemon.c', '../gdbusdaemon.c',
# #meson.build_root() + '/gio/gdbus-daemon-generated.c', # FIXME
# include_directories : inc_dirs,
# c_args : test_c_args,
# link_with : [ libgio, libgmodule, libglib ],
# dependencies : deps,
#)
#test('gdbus-daemon', exe, env : test_env)
foo = '''
c_args_atomic = [ ]
if cc.get_id() == 'gcc'
c_args_atomic += [ '-Wstrict-aliasing=2' ]
endif
# FIXME: consolidate all of these into the array
exe = executable('overflow-fallback', 'overflow.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-D_GLIB_TEST_OVERFLOW_FALLBACK' ],
link_with : libglib,
dependencies : deps,
)
test('overflow-fallback', exe, env : test_env)
exe = executable('642026-ec', '642026.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DG_ERRORCHECK_MUTEXES' ],
link_with : libglib,
dependencies : deps,
)
test('642026-ec', exe, env : test_env)
exe = executable('1bit-emufutex', '1bit-mutex.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EMULATED_FUTEX' ],
link_with : libglib,
dependencies : deps,
)
test('1bit-emufutex', exe, env : test_env)
if glib_conf.has('HAVE_EVENTFD')
exe = executable('gwakeup-fallback', 'gwakeuptest.c', '../gwakeup.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EVENTFD_FALLBACK' ],
link_with : libglib,
dependencies : deps,
)
test('gwakeup-fallback', exe, env : test_env)
endif
# test-spawn-echo helper binary required by the spawn tests
executable('test-spawn-echo', 'test-spawn-echo.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
link_with : libglib,
dependencies : deps,
)
'''
subdir('modules')
libtestmodulea = shared_library('testmodulea', 'test-module-a.c',
install : false,
include_directories : inc_dirs,
link_with : [ libglib, libgobject, libgmodule, libgio ],
c_args : [ ]
)
libtestmoduleb = shared_library('testmoduleb', 'test-module-b.c',
install : false,
include_directories : inc_dirs,
link_with : [ libglib, libgobject, libgmodule, libgio ],
c_args : [ ]
)
giowin32_sources = [
'gwin32fsmonitorutils.c',
'gwin32filemonitor.c',
'gwinhttpvfs.c',
'gwinhttpfile.c',
'gwinhttpfileinputstream.c',
'gwinhttpfileoutputstream.c',
]
giowin32_lib = static_library('giowin32',
sources : giowin32_sources,
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
xdgmime_sources = [
'xdgmime.c',
'xdgmimealias.c',
'xdgmimecache.c',
'xdgmimeglob.c',
'xdgmimeicon.c',
'xdgmimeint.c',
'xdgmimemagic.c',
'xdgmimeparent.c',
]
xdgmime_lib = static_library('xdgmime',
sources : xdgmime_sources,
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H', '-DXDG_PREFIX=_gio_xdg', '-fPIC' ])
......@@ -8,12 +8,9 @@
#include <glib/gmacros.h>
@INC_LIMITS_H@
@INC_FLOAT_H@
@INC_VALUES_H@
#include <limits.h>
#include <float.h>
#mesondefine GLIB_HAVE_ALLOCA_H
#mesondefine GLIB_HAVE_SYS_POLL_H
/* Specifies that GLib's g_print*() functions wrap the
* system printf functions. This is useful to know, for example,
......@@ -23,21 +20,20 @@
G_BEGIN_DECLS
#define G_MINFLOAT @glib_mf@
#define G_MAXFLOAT @glib_Mf@
#define G_MINDOUBLE @glib_md@
#define G_MAXDOUBLE @glib_Md@
#define G_MINSHORT @glib_ms@
#define G_MAXSHORT @glib_Ms@
#define G_MAXUSHORT @glib_Mus@
#define G_MININT @glib_mi@
#define G_MAXINT @glib_Mi@
#define G_MAXUINT @glib_Mui@
#define G_MINLONG @glib_ml@
#define G_MAXLONG @glib_Ml@
#define G_MAXULONG @glib_Mul@
/* this should always be true in a modern C/C++ compiler */
#define G_MINFLOAT FLT_MIN
#define G_MAXFLOAT FLT_MAX
#define G_MINDOUBLE DBL_MIN
#define G_MAXDOUBLE DBL_MAX
#define G_MINSHORT SHRT_MIN
#define G_MAXSHORT SHRT_MAX
#define G_MAXUSHORT USHRT_MAX
#define G_MININT INT_MIN
#define G_MAXINT INT_MAX
#define G_MAXUINT UINT_MAX
#define G_MINLONG LONG_MIN
#define G_MAXLONG LONG_MAX
#define G_MAXULONG ULONG_MAX
typedef signed char gint8;
typedef unsigned char guint8;
......@@ -73,12 +69,14 @@ typedef unsigned @gint32@ guint32;
#define GLIB_SIZEOF_VOID_P @glib_void_p@
#define GLIB_SIZEOF_LONG @glib_long@
#define GLIB_SIZEOF_SIZE_T @glib_size_t@
#define GLIB_SIZEOF_SSIZE_T @glib_ssize_t@
typedef signed @glib_size_type_define@ gssize;
typedef unsigned @glib_size_type_define@ gsize;
#define G_GSIZE_MODIFIER @gsize_modifier@
#define G_GSSIZE_FORMAT @gssize_format@
#define G_GSSIZE_MODIFIER @gssize_modifier@
#define G_GSIZE_FORMAT @gsize_format@
#define G_GSSIZE_FORMAT @gssize_format@
#define G_MAXSIZE G_MAXU@glib_msize_type@
#define G_MINSSIZE G_MIN@glib_msize_type@
......@@ -92,6 +90,8 @@ typedef gint64 goffset;
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
#define G_POLLFD_FORMAT @g_pollfd_format@
#define GPOINTER_TO_INT(p) ((gint) @glib_gpi_cast@ (p))
#define GPOINTER_TO_UINT(p) ((guint) @glib_gpui_cast@ (p))
......@@ -105,33 +105,22 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
#define G_GINTPTR_FORMAT @gintptr_format@
#define G_GUINTPTR_FORMAT @guintptr_format@
@glib_atexit@
@glib_memmove@
@glib_defines@
#ifndef G_DISABLE_DEPRECATED
#define g_ATEXIT(proc) (atexit (proc))
#define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
#endif
#define GLIB_MAJOR_VERSION @GLIB_MAJOR_VERSION@
#define GLIB_MINOR_VERSION @GLIB_MINOR_VERSION@
#define GLIB_MICRO_VERSION @GLIB_MICRO_VERSION@
@glib_os@
@glib_static_compilation@
@glib_vacopy@
#ifdef __cplusplus
#define G_HAVE_INLINE 1
#else /* !__cplusplus */
@glib_inline@
#endif /* !__cplusplus */
#ifdef __cplusplus
#define G_CAN_INLINE 1
#else /* !__cplusplus */
#mesondefine G_CAN_INLINE
#endif
#ifndef __cplusplus
#mesondefine G_HAVE_ISO_VARARGS
#endif
#ifdef __cplusplus
#mesondefine G_HAVE_ISO_VARARGS
#endif
@g_have_iso_c_varargs@
@g_have_iso_cxx_varargs@
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
* is passed ISO vararg support is turned off, and there is no work
......@@ -145,13 +134,7 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
#mesondefine G_HAVE_GROWING_STACK
/* On some systems, like SunOS and NetBSD, EILSEQ is not defined.
* The correspondence between this and the corresponding definition
* in libiconv is essential.
*/
#mesondefine EILSEQ
#mesondefine G_HAVE_GNUC_VISIBILITY
#define G_HAVE_GNUC_VISIBILITY 1
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
......
charset_lib = shared_library('charset', 'localcharset.c',
charset_lib = static_library('charset', 'localcharset.c',
include_directories : inc_dirs,
c_args : [ '-DLIBDIR="lib"' ])
c_args : [ '-DLIBDIR="lib"', '-fPIC' ])
......@@ -2,7 +2,101 @@ configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h', configuration
subdir('libcharset')
if host.name() == 'windows'
glib_headers = [
'glib.h',
'glib-unix.h',
'glib-object.h',
]
install_headers(glib_headers, subdir : 'glib-2.0/')
glib_deprecated_headers = [
'deprecated/gallocator.h',
'deprecated/gcache.h',
'deprecated/gcompletion.h',
'deprecated/gmain.h',
'deprecated/grel.h',
'deprecated/gthread.h',
]
install_headers(glib_deprecated_headers, subdir : 'glib-2.0/deprecated/')
glib_sub_headers = [
'glib-autocleanups.h',
'galloca.h',
'garray.h',
'gasyncqueue.h',
'gatomic.h',
'gbacktrace.h',
'gbase64.h',
'gbitlock.h',
'gbookmarkfile.h',
'gbytes.h',
'gcharset.h',
'gchecksum.h',
'gconvert.h',
'gdataset.h',
'gdate.h',
'gdatetime.h',
'gdir.h',
'genviron.h',
'gerror.h',
'gfileutils.h',
'ggettext.h',
'ghash.h',
'ghmac.h',
'ghook.h',
'ghostutils.h',
'gi18n.h',
'gi18n-lib.h',
'giochannel.h',
'gkeyfile.h',
'glist.h',
'gmacros.h',
'gmain.h',
'gmappedfile.h',
'gmarkup.h',
'gmem.h',
'gmessages.h',
'gnode.h',
'goption.h',
'gpattern.h',
'gpoll.h',
'gprimes.h',
'gqsort.h',
'gquark.h',
'gqueue.h',
'grand.h',
'gregex.h',
'gscanner.h',
'gsequence.h',
'gshell.h',
'gslice.h',
'gslist.h',
'gspawn.h',
'gstdio.h',
'gstrfuncs.h',
'gtestutils.h',
'gstring.h',
'gstringchunk.h',
'gthread.h',
'gthreadpool.h',
'gtimer.h',
'gtimezone.h',
'gtrashstack.h',
'gtree.h',
'gtypes.h',
'gunicode.h',
'gurifuncs.h',
'gutils.h',
'gvarianttype.h',
'gvariant.h',
'gversion.h',
'gversionmacros.h',
'gwin32.h',
'gprintf.h',
]
install_headers(glib_sub_headers, subdir : 'glib-2.0/glib/')
if host_machine.system() == 'windows'
thread_src = ['gthread-win32.c']
plat_src = []
else
......@@ -70,11 +164,13 @@ glib_sources = [
'gstrfuncs.c',
'gstring.c',
'gstringchunk.c',
'gtester.c',
'gtestutils.c',
'gthread.c',
'gthreadpool.c',
'gtimer.c',
'gtimezone.c',
'gtranslit.c',
'gtrashstack.c',
'gtree.c',
'guniprop.c',
......@@ -96,11 +192,17 @@ glib_sources = [
extra_src = ['gspawn.c', 'giounix.c']
#'gspawn-win32.c', # FIXME
#'gspawn-win32-helper.c', # FIXME
libglib = shared_library('glib',
sources : [deprecated_sources, glib_sources, thread_src, plat_src, extra_src],
version : glib_version,
soversion : interface_version,
include_dirs : inc_dirs,
install : true,
include_directories : inc_dirs,
link_with : charset_lib,
deps : [pcre, thread_lib],
dependencies : [ pcre, thread_dep, libiconv, librt ],
c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC'])
subdir('tests')
......@@ -180,6 +180,7 @@ atomic_CFLAGS += -Wstrict-aliasing=2
endif
overflow_fallback_SOURCES = overflow.c
# FIXME: FLAGS?
overflow_fallback_FALGS = $(AM_CFLAGS) -D_GLIB_TEST_OVERFLOW_FALLBACK
test_programs += 642026-ec
......
glib_tests = [
'array-test',
'asyncqueue',
'base64',
'bitlock',
'bookmarkfile',
'bytes',
'cache',
'checksum',
'collate',
'cond',
'convert',
'dataset',
'date',
'dir',
'environment',
'error',
'fileutils',
'gdatetime',
'gvariant',
'hash',
'hmac',
'hook',
'hostutils',
'keyfile',
'list',
'logging',
'mainloop',
'mappedfile',
'markup',
'markup-parse',
'markup-collect',
'markup-escape',
'markup-subparser',
'mem-overflow',
'mutex',
'node',
'once',
'option-context',
'option-argv0',
'overflow',
'pattern',
'private',
'protocol',
'queue',
'rand',
'rec-mutex',
'regex',
'rwlock',
'scannerapi',
'search-utils',
'sequence',
'shell',
'slice',
'slist',
'sort',
'spawn-multithreaded',
'spawn-singlethread',
'strfuncs',
'string',
'testing',
'test-printf',
'thread',
'timeout',
'timer',
'tree',
'utf8-performance',
'utf8-pointer',
'utf8-validate',
'utf8-misc',
'utils',
'unicode',
'uri',
'1bit-mutex',
'642026',
]
if host_machine.system() != 'windows'
glib_tests += [ 'unix', 'include' ]
endif
if cc.get_id() == 'gcc'
glib_tests += [ 'autoptr' ]
endif
test_env = [
'G_TEST_SRCDIR=' + meson.current_source_dir(),
'G_TEST_BUILDDIR=' + meson.current_build_dir(),
]
foreach test_name : glib_tests
deps = [ libm, thread_dep ]
if test_name == 'regex'
deps += [ pcre ]
endif
exe = executable(test_name, '@0@.c'.format(test_name),
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
link_with : libglib,
dependencies : deps,
install : false,
)
test(test_name, exe, env : test_env)
endforeach
c_args_atomic = [ ]
if cc.get_id() == 'gcc'
c_args_atomic += [ '-Wstrict-aliasing=2' ]
endif
exe = executable('atomic', 'atomic.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1' ] + c_args_atomic,
link_with : libglib,
dependencies : deps,
)
test('atomic', exe, env : test_env)
# FIXME: consolidate all of these into the array
exe = executable('overflow-fallback', 'overflow.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-D_GLIB_TEST_OVERFLOW_FALLBACK' ],
link_with : libglib,
dependencies : deps,
install : false,
)
test('overflow-fallback', exe, env : test_env)
exe = executable('642026-ec', '642026.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DG_ERRORCHECK_MUTEXES' ],
link_with : libglib,
dependencies : deps,
install : false,
)
test('642026-ec', exe, env : test_env)
exe = executable('1bit-emufutex', '1bit-mutex.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EMULATED_FUTEX' ],
link_with : libglib,
dependencies : deps,
install : false,
)
test('1bit-emufutex', exe, env : test_env)
if glib_conf.has('HAVE_EVENTFD')
exe = executable('gwakeup-fallback', 'gwakeuptest.c', '../gwakeup.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EVENTFD_FALLBACK' ],
link_with : libglib,
dependencies : deps,
install : false,
)
test('gwakeup-fallback', exe, env : test_env)
endif
# test-spawn-echo helper binary required by the spawn tests
executable('test-spawn-echo', 'test-spawn-echo.c',
include_directories : inc_dirs,
c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
link_with : libglib,
dependencies : deps,
install : false,
)
gmoduleconf_conf = configuration_data()
g_module_need_uscore = 0
g_module_broken_rtld_global = 0
g_module_have_dlerror = 0
libdl_dep = [ ]
g_module_lib_args = [ ]
g_module_impl = ''
dlopen_dlsym_test_code = '''
#include <dlfcn.h>
int glib_underscore_test (void) { return 42; }
int main (int argc, char ** argv) {
void *f1 = (void*)0, *f2 = (void*)0, *handle;