Skip to content

Commit

Permalink
Merge pull request #270 from ebassi/meson-update
Browse files Browse the repository at this point in the history
Build system updates
  • Loading branch information
ebassi authored Aug 12, 2024
2 parents f1575a9 + cba394a commit 0885352
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msvc-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
action: test
directory: _build
options: "--verbose"
meson-version: "0.55.3"
meson-version: "1.0.0"
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-clang-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-gcc-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
10 changes: 5 additions & 5 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions include/graphene-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions include/graphene-version-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 26 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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')

Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 + [
Expand Down

0 comments on commit 0885352

Please sign in to comment.