summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2025-02-23 13:50:23 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2025-02-23 14:06:06 -0800
commitf34c717e9af0b1618699f4cf2f9aed277085c880 (patch)
tree616e31b32edad1018b5d0423f9e9763f4bbebcc3
parente1cde54538060c4fd3a3d02e3d2e2b7e5da7bff9 (diff)
meson: Add option to build with mesonHEADmaster
Also updates the gitlab CI config to test both build types and compare the generated output/installed files. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxv/-/merge_requests/9>
-rw-r--r--.gitlab-ci.yml91
-rw-r--r--Makefile.am2
-rw-r--r--meson.build121
-rw-r--r--meson.options2
-rw-r--r--xv.pc.in9
5 files changed, 216 insertions, 9 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 56b6669..35963f6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -30,8 +30,16 @@ variables:
# The tag should be updated each time the list of packages is updated.
# Changing a tag forces the associated image to be rebuilt.
# Note: the tag has no meaning, we use a date format purely for readability
- FDO_DISTRIBUTION_TAG: '2022-07-17.0'
- FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool make xorg-util-macros xorgproto libx11 libxext'
+ FDO_DISTRIBUTION_TAG: '2025-02-15.0'
+ # minimal set of packages required to build and install either way
+ BASE_PACKAGES: 'git gcc clang pkgconf xorgproto libx11 libxext'
+ # packages needed to build and install with each set of tools
+ AUTOTOOLS_PACKAGES: 'autoconf automake libtool make xorg-util-macros'
+ MESON_PACKAGES: 'meson ninja'
+ # extra packages we need for comparing autotools & meson builds
+ EXTRA_PACKAGES: 'diffoscope diffutils findutils jq'
+ FDO_DISTRIBUTION_PACKAGES: $BASE_PACKAGES $AUTOTOOLS_PACKAGES $MESON_PACKAGES $EXTRA_PACKAGES
+
#
@@ -81,9 +89,9 @@ container-prep:
#
-# The default build, runs on the image built above.
+# The autotools build, runs on the image built above.
#
-build:
+autotools:
stage: build
extends:
- .fdo.distribution-image@arch
@@ -95,4 +103,79 @@ build:
- make
- make check
- make distcheck
+ - mv libXv*.tar.gz ..
- popd > /dev/null
+ artifacts:
+ paths:
+ - libXv*.tar.gz
+
+#
+# The meson build, runs on the image built above.
+#
+.meson_build:
+ stage: build
+ extends:
+ - .fdo.distribution-image@arch
+ script:
+ - CC="${CC}" meson setup _builddir --prefix="$PWD/_install"
+ - meson compile -C _builddir
+ - meson test -C _builddir
+ - meson install -C _builddir
+
+# Run meson build with different compilers
+meson:
+ extends:
+ - .meson_build
+ parallel:
+ matrix:
+ - CC: ["gcc", "clang"]
+
+
+meson from tarball:
+ extends:
+ - .fdo.distribution-image@arch
+ stage: test
+ script:
+ - mkdir -p _tarball_build
+ - tar xf libXv-*.tar.gz -C _tarball_build
+ - cd _tarball_build/libXv-*
+ - meson setup _builddir
+ - meson compile -C _builddir
+ - meson test -C _builddir
+ needs:
+ - autotools
+
+compare meson and autotools:
+ extends:
+ - .fdo.distribution-image@arch
+ stage: test
+ script:
+ - mkdir -p $PWD/_meson_inst $PWD/_autotools_inst
+ - CFLAGS="-O2"
+ meson setup builddir --prefix=/usr --buildtype=plain
+ -Ddefault_library=shared
+ - meson compile -C builddir -v
+ - DESTDIR=$PWD/_meson_inst meson install -C builddir
+ - ./autogen.sh --prefix=/usr --enable-shared --disable-static
+ CFLAGS="-O2 -D_FILE_OFFSET_BITS=64"
+ - make V=1 && make install DESTDIR=$PWD/_autotools_inst
+ # get rid of expected differences between the two
+ - rm -f $PWD/_autotools_inst/usr/lib/lib*.la
+ - rm -f $PWD/_autotools_inst/usr/lib/libXv.so
+ - ln -s libXv.so.1 $PWD/_autotools_inst/usr/lib/libXv.so
+ - sed -i -e 's/{exec_prefix}/{prefix}/' -e '/exec_prefix/d'
+ _autotools_inst/usr/lib/pkgconfig/xv.pc
+ - find $PWD/_meson_inst $PWD/_autotools_inst
+ -exec touch -h -r $PWD/_meson_inst/ {} \+
+ - diffoscope --text-color=always _autotools_inst _meson_inst
+
+check versions are in sync:
+ extends:
+ - .fdo.distribution-image@arch
+ stage: test
+ script:
+ - autoreconf -ivf
+ - ./configure --version | head -n 1 | sed -e 's/libXv configure //' > autotools.version
+ - meson introspect meson.build --projectinfo | jq -r '.version' > meson.version
+ - diff -u autotools.version meson.version ||
+ (echo "ERROR - autotools and meson versions not in sync" && false)
diff --git a/Makefile.am b/Makefile.am
index defcc53..e67a539 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,4 +41,4 @@ lint:
(cd src && $(MAKE) $(MFLAGS) lint)
endif LINT
-EXTRA_DIST = README.md
+EXTRA_DIST = README.md meson.build meson.options
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..63360ef
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,121 @@
+# SPDX-License-Identifier: MIT
+#
+# Copyright (c) 2025, Oracle and/or its affiliates.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+project(
+ 'libXv',
+ 'c',
+ version: '1.0.13',
+ license: 'HPND',
+ license_files: 'COPYING',
+ meson_version: '>= 1.1.0',
+)
+
+# Replacement for XORG_DEFAULT_OPTIONS
+cc = meson.get_compiler('c')
+if cc.has_argument('-fno-strict-aliasing')
+ add_project_arguments('-fno-strict-aliasing', language: 'c')
+endif
+
+# Replacement for XORG_CHECK_MALLOC_ZERO
+add_project_arguments('-DMALLOC_0_RETURNS_NULL', language: 'c')
+
+# Obtain compiler/linker options for dependencies
+dep_libx11 = dependency('x11', required: true, version: '>= 1.6')
+dep_libxext = dependency('xext', required: true)
+dep_xextproto = dependency('xextproto', required: true)
+dep_videoproto = dependency('videoproto', required: true)
+
+lib = library(
+ 'Xv',
+ 'src/Xv.c',
+ include_directories: 'include',
+ dependencies: [dep_libx11, dep_libxext, dep_xextproto, dep_videoproto],
+ version: '1.0.0',
+ install: true,
+)
+
+install_headers(
+ 'include/X11/extensions/Xvlib.h',
+ subdir: 'X11/extensions',
+)
+
+pkg = import('pkgconfig')
+pkg.generate(
+ name: 'Xv',
+ description: 'The Xv Library',
+ filebase: 'xv',
+ libraries: '-L${libdir} -lXv',
+ requires: ['xproto', dep_videoproto],
+ requires_private: [dep_libx11, dep_libxext],
+ url: 'https://gitlab.freedesktop.org/xorg/lib/libxv/'
+)
+
+prog_sed = find_program('sed')
+
+libXv_manpages = [
+ 'Xv',
+ 'XvCreateImage',
+ 'XvFreeAdaptorInfo',
+ 'XvFreeEncodingInfo',
+ 'XvGetPortAttribute',
+ 'XvGetStill',
+ 'XvGetVideo',
+ 'XvGrabPort',
+ 'XvListImageFormats',
+ 'XvPortNotify',
+ 'XvPutImage',
+ 'XvPutStill',
+ 'XvPutVideo',
+ 'XvQueryAdaptors',
+ 'XvQueryBestSize',
+ 'XvQueryEncodings',
+ 'XvQueryExtension',
+ 'XvQueryPortAttributes',
+ 'XvSelectPortNotify',
+ 'XvSelectVideoNotify',
+ 'XvSetPortAttribute',
+ 'XvShmCreateImage',
+ 'XvShmPutImage',
+ 'XvStopVideo',
+ 'XvUngrabPort',
+ 'XvVideoNotify'
+]
+
+lib_man_suffix = get_option('lib_man_suffix')
+foreach man: libXv_manpages
+ custom_target(
+ f'@man@.man',
+ input: f'man/@man@.man',
+ output: f'@man@.@lib_man_suffix@',
+ command: [
+ prog_sed,
+ '-e', 's/__vendorversion__/"libXv @0@" "X Version 11"/'.format(meson.project_version()),
+ '-e', f's/__libmansuffix__/@lib_man_suffix@/g',
+ '@INPUT@',
+ ],
+ capture: true,
+ install: true,
+ install_dir: get_option('prefix') / get_option('mandir') / f'man@lib_man_suffix@',
+ )
+endforeach
diff --git a/meson.options b/meson.options
new file mode 100644
index 0000000..d33ae43
--- /dev/null
+++ b/meson.options
@@ -0,0 +1,2 @@
+option('lib_man_suffix', type : 'string', value : '3',
+ description : 'Suffix for library man pages')
diff --git a/xv.pc.in b/xv.pc.in
index 2edb41f..754e040 100644
--- a/xv.pc.in
+++ b/xv.pc.in
@@ -1,12 +1,13 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
-libdir=@libdir@
includedir=@includedir@
+libdir=@libdir@
Name: Xv
Description: The Xv Library
+URL: https://gitlab.freedesktop.org/xorg/lib/libxv/
Version: @PACKAGE_VERSION@
-Requires: xproto videoproto
-Requires.private: x11 xext
-Cflags: -I${includedir}
+Requires: xproto, videoproto
+Requires.private: x11 >= 1.6, xext
Libs: -L${libdir} -lXv
+Cflags: -I${includedir}