Skip to content

Instantly share code, notes, and snippets.

@Angelmmiguel
Last active February 17, 2025 14:54
Show Gist options
  • Save Angelmmiguel/2413730122fc9e0d91c490b2f199ce4d to your computer and use it in GitHub Desktop.
Save Angelmmiguel/2413730122fc9e0d91c490b2f199ce4d to your computer and use it in GitHub Desktop.
Glib meson.build patch
diff --git a/gio/meson.build b/gio/meson.build
index c75847175..6a572104b 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -18,7 +18,7 @@ gnetworking_h_conf = configuration_data()
gnetworking_h_nameser_compat_include = ''
-if host_system not in ['windows', 'android']
+if host_system not in ['windows', 'android', 'emscripten']
# Don't check for C_IN on Android since it does not define it in public
# headers, we define it ourselves wherever necessary
if not cc.compiles('''#include <sys/types.h>
diff --git a/glib/meson.build b/glib/meson.build
index 5820817b7..86a9ed060 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -257,11 +257,11 @@ if host_system == 'windows'
endif
glib_deprecated_sources = files(
- 'deprecated/gallocator.c',
- 'deprecated/gcache.c',
- 'deprecated/gcompletion.c',
- 'deprecated/grel.c',
- 'deprecated/gthread-deprecated.c'
+ # 'deprecated/gallocator.c',
+ # 'deprecated/gcache.c',
+ # 'deprecated/gcompletion.c',
+ # 'deprecated/grel.c',
+ # 'deprecated/gthread-deprecated.c'
)
glib_sources += files(
diff --git a/meson.build b/meson.build
index 4c28ab367..17d7834da 100644
--- a/meson.build
+++ b/meson.build
@@ -1559,6 +1559,16 @@ else
long_long_size = 0
endif
sizet_size = cc.sizeof('size_t')
+
+message('SHORT_SIZE')
+message(short_size)
+message('INT_SIZE')
+message(int_size)
+message('LONG_SIZE')
+message(long_size)
+message('CHAR_SIZE')
+message(char_size)
+
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
ssizet_size = cc.sizeof('SSIZE_T', prefix : '#include <BaseTsd.h>')
else
@@ -1667,7 +1677,7 @@ glibconfig_conf.set_quoted('gint32_modifier', gint32_modifier)
glibconfig_conf.set_quoted('gint32_format', gint32_format)
glibconfig_conf.set_quoted('guint32_format', guint32_format)
-if int_size == 8
+if int_size == 8 or cc.get_id() == 'emscripten' or cc.get_id() == 'emcc'
gint64 = 'int'
gint64_modifier=''
gint64_format='i'
@@ -1733,7 +1743,7 @@ g_sizet_compatibility = {
# Do separate checks for gcc/clang/emscripten (and ignore other compilers for now),
# since we need to explicitly pass -Werror to the compilers.
# FIXME: https://github.com/mesonbuild/meson/issues/5399
-if cc.get_id() == 'gcc' or cc.get_id() == 'clang' or cc.get_id() == 'emscripten'
+if cc.get_id() == 'gcc' or cc.get_id() == 'clang' or cc.get_id() == 'emscripten' or cc.get_id() == 'emcc'
foreach type_name, size_compatibility : g_sizet_compatibility
g_sizet_compatibility += { type_name: size_compatibility and
cc.compiles(
@@ -1756,7 +1766,7 @@ if g_sizet_compatibility['short']
glibconfig_conf.set_quoted('gsize_format', 'hu')
glibconfig_conf.set_quoted('gssize_format', 'hi')
glibconfig_conf.set('glib_msize_type', 'SHRT')
-elif g_sizet_compatibility['int']
+elif g_sizet_compatibility['int'] or cc.get_id() == 'emcc' or cc.get_id() == 'emscripten'
glibconfig_conf.set('glib_size_type_define', 'int')
glibconfig_conf.set_quoted('gsize_modifier', '')
glibconfig_conf.set_quoted('gssize_modifier', '')
@@ -1806,9 +1816,9 @@ else
error('Could not determine size of void *')
endif
-if long_size != 8 and long_long_size != 8 and int_size != 8
- error('GLib requires a 64-bit type. You might want to consider using the GNU C compiler.')
-endif
+# if (long_size != 8 and long_long_size != 8 and int_size != 8) or cc.get_id('emcc') or cc.get_id('emscripten')
+# error('GLib requires a 64-bit type. You might want to consider using the GNU C compiler.')
+# endif
glibconfig_conf.set('gintbits', int_size * 8)
glibconfig_conf.set('glongbits', long_size * 8)
@@ -1880,29 +1890,29 @@ endif
glibconfig_conf.set('glib_vacopy', glib_vacopy)
# check for flavours of varargs macros
-g_have_iso_c_varargs = cc.compiles('''
- void some_func (void) {
- int a(int p1, int p2, int p3);
- #define call_a(...) a(1,__VA_ARGS__)
- call_a(2,3);
- }''', name : 'ISO C99 varargs macros in C')
-
-if not g_have_iso_c_varargs
- error('GLib requires a C compiler with support for C99 __VA_ARG__ in macros.')
-endif
-
-if have_cxx
- g_have_iso_cxx_varargs = cxx.compiles('''
- void some_func (void) {
- int a(int p1, int p2, int p3);
- #define call_a(...) a(1,__VA_ARGS__)
- call_a(2,3);
- }''', name : 'ISO C99 varargs macros in C++')
-
- if not g_have_iso_cxx_varargs
- error('GLib requires a C++ compiler with support for C99 __VA_ARG__ in macros.')
- endif
-endif
+# g_have_iso_c_varargs = cc.compiles('''
+# void some_func (void) {
+# int a(int p1, int p2, int p3);
+# #define call_a(...) a(1,__VA_ARGS__)
+# call_a(2,3);
+# }''', name : 'ISO C99 varargs macros in C')
+
+# if not g_have_iso_c_varargs
+# error('GLib requires a C compiler with support for C99 __VA_ARG__ in macros.')
+# endif
+
+# if have_cxx
+# g_have_iso_cxx_varargs = cxx.compiles('''
+# void some_func (void) {
+# int a(int p1, int p2, int p3);
+# #define call_a(...) a(1,__VA_ARGS__)
+# call_a(2,3);
+# }''', name : 'ISO C99 varargs macros in C++')
+
+# if not g_have_iso_cxx_varargs
+# error('GLib requires a C++ compiler with support for C99 __VA_ARG__ in macros.')
+# endif
+# endif
g_have_gnuc_varargs = cc.compiles('''
void some_func (void) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment