From e8b622ebe63e8e1000ba2b7c60f54143a5376363 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 30 Aug 2021 07:27:44 +0930 Subject: [PATCH] Support check-def.sh in meson build The original check-def.sh called make. In meson, check-def.sh is replaced by two shell scripts, one for generating cairo.def, the other for comparing with the library symbols. The library filename appended to the cairo.def has been omitted as this is only reqired in autotools builds where the cairo.def is also to generate cairo.dll in the windows build. make-cairo-def.sh is based on the cairo.def target in Makefile.am. meson-check-def.sh is based on check-def.sh --- .gitlab-ci.yml | 1 - src/make-cairo-def.sh | 26 ++++++++++++++++++++++++++ src/meson-check-def.sh | 38 ++++++++++++++++++++++++++++++++++++++ src/meson.build | 21 +++++++++++++++++---- 4 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 src/make-cairo-def.sh create mode 100644 src/meson-check-def.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ee5f5681..83a9d5c00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -235,7 +235,6 @@ fedora meson build: - ninja -C builddir # Run test scripts - #- (cd builddir/src && srcdir=../../src bash "$srcdir/check-def.sh") This script calls "make cairo.def" and thus does not work with meson - mkdir builddir/src/.libs - touch builddir/src/.libs/libfoo.so # Run all the tests, except for the big test executable which diff --git a/src/make-cairo-def.sh b/src/make-cairo-def.sh new file mode 100644 index 000000000..664df0887 --- /dev/null +++ b/src/make-cairo-def.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +if [ $# -lt 3 ]; +then + echo "Generate cairo def file" + echo "Usage: $0 ..." + exit 1 +fi + +def_file="$1" +cairo_features_h="$2" +shift 2 + +echo Generating $def_file +(echo EXPORTS; \ + (cat $* || echo 'cairo_ERROR ()' ) | \ + egrep -v '^# *include' | \ + ( cat "$cairo_features_h" - | cpp -D__cplusplus - || echo 'cairo_ERROR ()' ) | \ + egrep '^cairo_.* \(' | \ + sed -e 's/[ ].*//' | \ + sort; \ + ) > "$def_file" +grep -q -v cairo_ERROR "$def_file" || (rm "$def_file"; false) diff --git a/src/meson-check-def.sh b/src/meson-check-def.sh new file mode 100644 index 000000000..550cf337f --- /dev/null +++ b/src/meson-check-def.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +if [ $# -lt 2 ]; +then + echo "Check that cairo library has same exported symbols as cairo.def" + echo "Usage: $0 " + exit 1 +fi + +def="$1" +so="$2" + +if which nm 2>/dev/null >/dev/null; then + : +else + echo "'nm' not found; skipping test" + exit 0 +fi + +stat=0 + +if [ "`uname -s`" = "Linux" ]; then + get_cairo_syms='( objdump -t "$so" | grep "^[^ ]* [^l.*]*[.]"; objdump -t "$so" | grep "[.]hidden.*\\&2 || stat=1 + +exit $stat diff --git a/src/meson.build b/src/meson.build index f8e2290f2..abb04e1ff 100644 --- a/src/meson.build +++ b/src/meson.build @@ -278,7 +278,8 @@ libcairo = library('cairo', cairo_sources, include_directories: incbase, ) -cairo_headers += [configure_file(output: 'cairo-features.h', configuration: feature_conf)] +cairo_features_file = configure_file(output: 'cairo-features.h', configuration: feature_conf) +cairo_headers += [cairo_features_file] libcairo_dep = declare_dependency(link_with: libcairo, dependencies: deps, @@ -298,9 +299,6 @@ install_headers(cairo_headers, subdir: 'cairo') shell = find_program('sh', required: false) if shell.found() test_scripts = [ - # This script calls back into make to generate cairo.def - # TODO: Make this work, somehow - #'check-def.sh', 'check-doc-syntax.sh', 'check-headers.sh', 'check-preprocessor-syntax.sh', @@ -316,6 +314,21 @@ if shell.found() env = environment() env.set('CAIRO_HAS_HIDDEN_SYMBOLS', '1') + cairo_def = custom_target('make-cairo-def', + input : cairo_headers, + output : 'cairo.def', + command : [ shell, + meson.current_source_dir()/'make-cairo-def.sh', + '@OUTPUT@', + cairo_features_file, + '@INPUT@' + ]) + + test('check-def', shell, + args: ['meson-check-def.sh', cairo_def, libcairo ], + env: env, + workdir: meson.current_source_dir()) + test('check-plt.sh', shell, args: ['check-plt.sh', libcairo ], env: env,