diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-10-20 00:51:34 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-10-31 14:08:31 +0100 |
commit | b9e085537d8c72373bd40d31edd592bfe9d172aa (patch) | |
tree | 44bf9304ce772a614ee03ee85874f45557cd34b5 | |
parent | 914bb06ab43f38e9edc6df2bd95fe26f39bdf7e8 (diff) | |
download | glib-b9e085537d8c72373bd40d31edd592bfe9d172aa.tar.gz |
meson: Expose library build type as global variables
Given that it can be computed using an error-prone strings comparisons it
is better to provide a variable everywhere, so that we don't have the
risk of comparing values that are always false.
-rw-r--r-- | docs/reference/meson.build | 10 | ||||
-rw-r--r-- | gio/meson.build | 2 | ||||
-rw-r--r-- | gio/tests/gdbus-object-manager-example/meson.build | 2 | ||||
-rw-r--r-- | gio/tests/meson.build | 6 | ||||
-rw-r--r-- | glib/meson.build | 2 | ||||
-rw-r--r-- | glib/tests/meson.build | 2 | ||||
-rw-r--r-- | gmodule/tests/meson.build | 2 | ||||
-rw-r--r-- | gobject/meson.build | 2 | ||||
-rw-r--r-- | meson.build | 20 |
9 files changed, 32 insertions, 16 deletions
diff --git a/docs/reference/meson.build b/docs/reference/meson.build index fb4b26bc9..c417ffecb 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 not glib_build_shared + error('The API reference can only be built against a shared library') + endif endif subdir('gio') diff --git a/gio/meson.build b/gio/meson.build index d16fc5230..a51926fcf 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -601,7 +601,7 @@ gio_sources = files( 'gliststore.c', ) -if get_option('default_library') != 'static' +if glib_build_shared gio_sources += files ('../glib/gtrace.c') endif diff --git a/gio/tests/gdbus-object-manager-example/meson.build b/gio/tests/gdbus-object-manager-example/meson.build index c26238f5f..ac5e6d4df 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_build_static_only extra_c_args = '-DGDBUS_OBJECT_MANAGER_EXAMPLE_STATIC_COMPILATION' endif diff --git a/gio/tests/meson.build b/gio/tests/meson.build index c894f12e0..f000907d8 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -223,7 +223,7 @@ if host_machine.system() != 'windows' } # LD_PRELOAD modules don't work so well with AddressSanitizer - if have_rtld_next and get_option('default_library') != 'static' and get_option('b_sanitize') == 'none' + if have_rtld_next and glib_build_shared and get_option('b_sanitize') == 'none' gio_tests += { 'gsocketclient-slow' : { 'depends' : [ @@ -652,7 +652,7 @@ if meson.can_run_host_binaries() compiler_type = '--compiler=@0@'.format(cc.get_id()) - if get_option('default_library') != 'static' + if glib_build_shared plugin_resources_c = custom_target('plugin-resources.c', input : 'test4.gresource.xml', output : 'plugin-resources.c', @@ -983,6 +983,6 @@ endif subdir('services') -if get_option('default_library') != 'static' +if glib_build_shared subdir('modules') endif diff --git a/glib/meson.build b/glib/meson.build index ad1a61aff..4130b1ba6 100644 --- a/glib/meson.build +++ b/glib/meson.build @@ -348,7 +348,7 @@ glib_sources += files( platform_deps = [] if host_system == 'windows' - if get_option('default_library') == 'shared' + if glib_build_shared glib_win_rc = configure_file( input: 'glib.rc.in', output: 'glib.rc', diff --git a/glib/tests/meson.build b/glib/tests/meson.build index 82f28dd52..270269596 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -205,7 +205,7 @@ else 'include' : {}, 'unix' : {}, } - if have_rtld_next and get_option('default_library') != 'static' + if have_rtld_next and glib_build_shared glib_tests += { 'gutils-user-database' : { 'depends' : [ diff --git a/gmodule/tests/meson.build b/gmodule/tests/meson.build index 29b76b1b8..004df2bf3 100644 --- a/gmodule/tests/meson.build +++ b/gmodule/tests/meson.build @@ -38,7 +38,7 @@ if ['darwin', 'ios'].contains(host_machine.system()) module_suffix = 'so' endif -if get_option('default_library') != 'static' +if glib_build_shared foreach module : ['moduletestplugin_a', 'moduletestplugin_b'] shared_module(module + '_plugin', 'lib@0@.c'.format(module), dependencies : [libglib_dep, libgmodule_dep], diff --git a/gobject/meson.build b/gobject/meson.build index 0dd955f66..565f22875 100644 --- a/gobject/meson.build +++ b/gobject/meson.build @@ -62,7 +62,7 @@ gobject_sources += files( 'gvaluetypes.c', ) -if host_system == 'windows' and get_option('default_library') == 'shared' +if host_system == 'windows' and glib_build_shared gobject_win_rc = configure_file( input: 'gobject.rc.in', output: 'gobject.rc', diff --git a/meson.build b/meson.build index bc2aa19c9..e395d8c65 100644 --- a/meson.build +++ b/meson.build @@ -221,11 +221,27 @@ if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang- glib_conf.set('_FILE_OFFSET_BITS', 64) endif -if get_option('default_library') == 'both' and (host_system == 'windows' or host_system == 'cygwin') +glib_build_shared = false +glib_build_static = false +if get_option('default_library') == 'both' + glib_build_static = true + glib_build_shared = true +elif get_option('default_library') == 'static' + glib_build_static = true +elif get_option('default_library') == 'shared' + glib_build_shared = true +endif + +glib_build_both = glib_build_static and glib_build_shared +glib_build_static_only = glib_build_static and not glib_build_shared +glib_build_shared_only = glib_build_shared and not glib_build_static + +if glib_build_shared and glib_build_static and ( + host_system == 'windows' or host_system == 'cygwin') error('On Windows default_library must be "shared" or "static" but not "both"') endif -if get_option('default_library') == 'static' +if glib_build_static_only glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1') glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1') glibconfig_conf.set('GIO_STATIC_COMPILATION', '1') |