From f2689502b7a65fb2df9e93f84cd58b33ad7be478 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Aug 2024 14:08:42 +0100 Subject: [PATCH 1/3] build: Require Meson 1.0.0 Meson 1.0 was released in December 2022. --- .github/workflows/msvc-env.yml | 2 +- .github/workflows/ubuntu-clang-latest.yml | 2 +- .github/workflows/ubuntu-gcc-latest.yml | 2 +- meson.build | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/msvc-env.yml b/.github/workflows/msvc-env.yml index b462135..5cbe0dc 100644 --- a/.github/workflows/msvc-env.yml +++ b/.github/workflows/msvc-env.yml @@ -20,4 +20,4 @@ jobs: action: test directory: _build options: "--verbose" - meson-version: "0.55.3" + meson-version: "1.0.0" diff --git a/.github/workflows/ubuntu-clang-latest.yml b/.github/workflows/ubuntu-clang-latest.yml index 5d9807c..732597b 100644 --- a/.github/workflows/ubuntu-clang-latest.yml +++ b/.github/workflows/ubuntu-clang-latest.yml @@ -16,7 +16,7 @@ jobs: - name: set up environment run: | sudo apt-get install clang gir1.2-glib-2.0 gobject-introspection gtk-doc-tools libgirepository1.0-dev libglib2.0-dev ninja-build python3-setuptools python3-wheel - sudo pip3 install meson==0.55.3 + sudo pip3 install meson==1.0.0 - name: default build run: | diff --git a/.github/workflows/ubuntu-gcc-latest.yml b/.github/workflows/ubuntu-gcc-latest.yml index 22fe9f3..3c96b68 100644 --- a/.github/workflows/ubuntu-gcc-latest.yml +++ b/.github/workflows/ubuntu-gcc-latest.yml @@ -16,7 +16,7 @@ jobs: - name: set up environment run: | sudo apt-get install gcc gir1.2-glib-2.0 gobject-introspection gtk-doc-tools libgirepository1.0-dev libglib2.0-dev ninja-build python3-setuptools python3-wheel - sudo pip3 install meson==0.55.3 + sudo pip3 install meson==1.0.0 - name: default build run: | diff --git a/meson.build b/meson.build index 7dcb9e6..37da128 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('graphene', 'c', version: '1.11.1', license: 'MIT', - meson_version: '>= 0.55.3', + meson_version: '>= 1.0', default_options: [ 'buildtype=debugoptimized', 'c_std=c99', From f3af6793ab257f8b1935f74fc3d3bca4c9fb2452 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Aug 2024 14:09:44 +0100 Subject: [PATCH 2/3] build: Rework the public symbol macros and flags Use a similar approach as GLib, with an export/import pair of macros determined at inclusion time, instead of generating the extern marker at build configuration time. We also add a way to specify a static build with no markers, and we use Meson's support for GCC's symbol visibility instead of rolling our own. --- include/graphene-macros.h | 4 ---- include/graphene-version-macros.h | 19 ++++++++++++++++++ meson.build | 32 ++++++++++++++++++++++++------- src/meson.build | 1 + 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/include/graphene-macros.h b/include/graphene-macros.h index 4f2bb38..7df898c 100644 --- a/include/graphene-macros.h +++ b/include/graphene-macros.h @@ -29,10 +29,6 @@ #error "Only graphene.h can be included directly." #endif -#ifndef _GRAPHENE_PUBLIC -#define _GRAPHENE_PUBLIC extern -#endif - #ifdef GRAPHENE_COMPILATION # define GRAPHENE_PRIVATE_FIELD(type,name) type name #else diff --git a/include/graphene-version-macros.h b/include/graphene-version-macros.h index 0844996..acc00eb 100644 --- a/include/graphene-version-macros.h +++ b/include/graphene-version-macros.h @@ -31,6 +31,25 @@ #include "graphene-version.h" +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(GRAPHENE_STATIC_COMPILATION) +# define _GRAPHENE_EXPORT __declspec(dllexport) +# define _GRAPHENE_IMPORT __declspec(dllimport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define _GRAPHENE_EXPORT __attribute__((visibility("default"))) +# define _GRAPHENE_IMPORT +#else +# define _GRAPHENE_EXPORT +# define _GRAPHENE_IMPORT +#endif + +#ifdef GRAPHENE_COMPILATION +# define _GRAPHENE_API _GRAPHENE_EXPORT +#else +# define _GRAPHENE_API _GRAPHENE_IMPORT +#endif + +#define _GRAPHENE_PUBLIC _GRAPHENE_API extern + /** * GRAPHENE_ENCODE_VERSION: * @major: a major version diff --git a/meson.build b/meson.build index 37da128..d989905 100644 --- a/meson.build +++ b/meson.build @@ -202,13 +202,6 @@ extra_args = [] if get_option('default_library') != 'static' if host_system == 'windows' conf.set('DLL_EXPORT', true) - conf.set('_GRAPHENE_PUBLIC', '__declspec(dllexport) extern') - if cc.get_id() != 'msvc' - extra_args += ['-fvisibility=hidden'] - endif - else - conf.set('_GRAPHENE_PUBLIC', '__attribute__((visibility("default"))) extern') - extra_args += ['-fvisibility=hidden'] endif endif @@ -414,6 +407,31 @@ endif # Scalar is always available as a fallback graphene_simd += [ 'scalar' ] +graphene_build_shared = false +graphene_build_static = false +if get_option('default_library') == 'both' + graphene_build_static = true + graphene_build_shared = true +elif get_option('default_library') == 'static' + graphene_build_static = true +elif get_option('default_library') == 'shared' + graphene_build_shared = true +endif + +graphene_build_both = graphene_build_static and graphene_build_shared +graphene_build_static_only = graphene_build_static and not graphene_build_shared +graphene_build_shared_only = graphene_build_shared and not graphene_build_static + +if graphene_build_shared and graphene_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 graphene_build_static_only + graphene_conf.set('GRAPHENE_STATIC_COMPILATION', '1') +endif + + python = import('python') gnome = import('gnome') diff --git a/src/meson.build b/src/meson.build index 29c1920..8303fc8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -45,6 +45,7 @@ libgraphene = library( version: libversion, soversion: soversion, darwin_versions: darwin_versions, + gnu_symbol_visibility: 'hidden', install: true, dependencies: [ mathlib, threadlib ] + platform_deps, c_args: extra_args + common_cflags + debug_flags + [ From cba394af9c88aad7415991125c12e78c6821eb96 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 12 Aug 2024 14:35:21 +0100 Subject: [PATCH 3/3] build: Do not use deprecated functionality The get_pkgconfig_variable() method was replaced by get_variable(). --- doc/meson.build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/meson.build b/doc/meson.build index 193d075..7f1d946 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -20,9 +20,9 @@ html_images = [ 'triangle-barycentric.png', ] -glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix') -glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') -docpath = join_paths(graphene_datadir, 'gtk-doc', 'html') +glib_prefix = dependency('glib-2.0').get_variable(pkgconfig: 'prefix') +glib_docpath = glib_prefix / 'share' / 'gtk-doc' / 'html' +docpath = graphene_datadir / 'gtk-doc' / 'html' gnome.gtkdoc('graphene', main_xml: 'graphene-docs.xml', @@ -42,8 +42,8 @@ gnome.gtkdoc('graphene', ], fixxref_args: [ '--html-dir=@0@'.format(docpath), - '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')), - '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')), + '--extra-dir=@0@'.format(glib_docpath / 'glib'), + '--extra-dir=@0@'.format(glib_docpath / 'gobject'), ], html_assets: html_images, install: true,