[glib/wip/3v1n0/support-can-fail-tests: 3/9] meson: Expose static build as global variable




commit 9e170db59bf620d75a4e1aa2e539ee025c6048fd
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Oct 20 00:51:34 2022 +0200

    meson: Expose static build as global variable
    
    Given that it can be computed using an error-prone string comparison, it
    is better to provide a variable everywhere

 docs/reference/meson.build                         | 10 +++++-----
 gio/tests/gdbus-object-manager-example/meson.build |  2 +-
 meson.build                                        |  3 ++-
 3 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index fb4b26bc96..04fbdcc7a2 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -45,12 +45,12 @@ if get_option('gtk_doc')
   dependency('gtk-doc', version : '>=1.32.1',
     fallback : ['gtk-doc', 'dummy_dep'],
     default_options : ['tests=false'])
-endif
 
-# We cannot built the API reference off of a static library,
-# as symbols might get dropped by the linker
-if get_option('gtk_doc') and get_option('default_library') == 'static'
-  error('The API reference can only be built against a shared library')
+  # We cannot built the API reference off of a static library,
+  # as symbols might get dropped by the linker
+  if glib_static_build
+    error('The API reference can only be built against a shared library')
+  endif
 endif
 
 subdir('gio')
diff --git a/gio/tests/gdbus-object-manager-example/meson.build 
b/gio/tests/gdbus-object-manager-example/meson.build
index c26238f5f9..819b570b72 100644
--- a/gio/tests/gdbus-object-manager-example/meson.build
+++ b/gio/tests/gdbus-object-manager-example/meson.build
@@ -39,7 +39,7 @@ gdbus_example_objectmanager_rst_gen = custom_target('objectmanager-rst-gen',
 )
 
 extra_c_args = []
-if get_option('default_library') == 'static'
+if glib_static_build
   extra_c_args = '-DGDBUS_OBJECT_MANAGER_EXAMPLE_STATIC_COMPILATION'
 endif
 
diff --git a/meson.build b/meson.build
index e37d18e091..ce1ad7c008 100644
--- a/meson.build
+++ b/meson.build
@@ -225,7 +225,8 @@ if get_option('default_library') == 'both' and (host_system == 'windows' or host
   error('On Windows default_library must be "shared" or "static" but not "both"')
 endif
 
-if get_option('default_library') == 'static'
+glib_static_build = get_option('default_library') == 'static'
+if glib_static_build
   glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1')
   glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1')
   glibconfig_conf.set('GIO_STATIC_COMPILATION', '1')


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