[cairo-commit] 2 commits - .gitlab-ci.yml src/make-cairo-def.sh src/meson.build src/meson-check-def.sh

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 2 12:57:33 UTC 2023


 .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(-)

New commits:
commit 47645dd674d9df4c72a10125abfb7966f59efabc
Merge: 7f83c3094 e8b622ebe
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Jan 2 12:57:31 2023 +0000

    Merge branch 'tests' into 'master'
    
    Support check-def.sh in meson build
    
    See merge request cairo/cairo!248

commit e8b622ebe63e8e1000ba2b7c60f54143a5376363
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Aug 30 07:27:44 2021 +0930

    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

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 <def-filename> <cairo-features-file> <cairo-headers>..."
+    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 <def-filename> <cairo-library>"
+    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.*\\<cairo"; ) | sed "s/.* //"'
+else
+	get_cairo_syms='nm "$so" | grep " [BCDGINRSTVW] " | cut -d" " -f3'
+fi
+
+echo Checking that $so has the same symbol list as $def
+
+{
+    echo EXPORTS
+    eval $get_cairo_syms | c++filt --no-params | grep -v '^_cairo_test_\|^_fini\|^_init\|^_save[fg]pr\|^_rest[fg]pr\|^_Z\|^__gnu\|^__bss\|^_edata\|^_end' | sort -u
+} | diff "$def" - >&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,


More information about the cairo-commit mailing list