[glib/wip/3v1n0/more-unix-oses: 5/5] meson: Cleanup computation of glib OS and their definition




commit 09ef8cc5030c1ac6bedde671a88e4eed6309ea36
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Oct 19 16:40:15 2022 +0200

    meson: Cleanup computation of glib OS and their definition

 meson.build | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)
---
diff --git a/meson.build b/meson.build
index d636d7f0b0..4218028c72 100644
--- a/meson.build
+++ b/meson.build
@@ -230,30 +230,35 @@ endif
 # This makes G_PLATFORM_WIN32 a synonym for
 # G_OS_WIN32.
 if host_system == 'windows'
-  glib_os = '''#define G_OS_WIN32
-#define G_PLATFORM_WIN32'''
-elif host_system == 'linux'
-  glib_os = '''#define G_OS_UNIX
-#define G_OS_LINUX'''
-elif host_system == 'cygwin'
-  glib_os = '''#define G_OS_UNIX
-#define G_WITH_CYGWIN'''
-elif host_system == 'darwin'
-  glib_os = '''#define G_OS_UNIX
-#define G_OS_DARWIN'''
-elif host_system == 'freebsd'
-  glib_os = '''#define G_OS_UNIX
-#define G_OS_FREEBSD'''
-elif host_system == 'openbsd'
-  glib_os = '''#define G_OS_UNIX
-#define G_OS_OPENBSD'''
+  glib_os = [
+    'G_OS_WIN32',
+    'G_PLATFORM_WIN32',
+  ]
 else
-  glib_os = '#define G_OS_UNIX'
-endif
-if host_system == 'darwin' or host_system.to_lower().endswith('bsd')
-  glib_os += '\n#define G_OS_BSD'
+  glib_os = ['G_OS_UNIX']
+
+  if host_system == 'linux'
+    glib_os += 'G_OS_LINUX'
+  elif host_system == 'cygwin'
+    glib_os += 'G_WITH_CYGWIN'
+  elif host_system == 'darwin'
+    glib_os += 'G_OS_DARWIN'
+    glib_os += 'G_OS_BSD'
+  elif host_system == 'freebsd'
+    glib_os += 'G_OS_FREEBSD'
+  elif host_system == 'openbsd'
+    glib_os += 'G_OS_OPENBSD'
+  endif
+
+  if host_system.to_lower().endswith('bsd')
+    glib_os += 'G_OS_BSD'
+  endif
 endif
-glibconfig_conf.set('glib_os', glib_os)
+glib_os_defines = []
+foreach os : glib_os
+  glib_os_defines += '#define @0@'.format(os)
+endforeach
+glibconfig_conf.set('glib_os', '\n'.join(glib_os_defines))
 
 # We need to know the CRT being used to determine what .lib files we need on
 # Visual Studio for dependencies that don't normally come with pkg-config files


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]