diff options
-rw-r--r-- | .gitlab-ci.yml | 92 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | meson.build | 139 | ||||
-rw-r--r-- | meson.options | 2 | ||||
-rw-r--r-- | xrandr.pc.in | 5 |
5 files changed, 233 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e9155ad..9e73f88 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,8 +30,15 @@ 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 libxrender' + 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 libxrender' + # 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 +88,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 +102,81 @@ build: - make - make check - make distcheck + - mv libXrandr*.tar.gz .. - popd > /dev/null + artifacts: + paths: + - libXrandr*.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 libXrandr-*.tar.gz -C _tarball_build + - cd _tarball_build/libXrandr-* + - 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/libXrandr.so + - ln -s libXrandr.so.2 $PWD/_autotools_inst/usr/lib/libXrandr.so + - sed -i -e 's/{exec_prefix}/{prefix}/' -e '/exec_prefix/d' + -e 's/\( xproto\) /\1, /' + -e 's/\(Requires\.private:\) x11 xext xrender/\1 xext, xextproto, xrender, renderproto, x11 >= 1.6/' + _autotools_inst/usr/lib/pkgconfig/xrandr.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/libXrandr 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 c8ff7ad..64e9a71 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,4 +36,4 @@ ChangeLog: dist-hook: ChangeLog INSTALL -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..98dcb2e --- /dev/null +++ b/meson.build @@ -0,0 +1,139 @@ +# 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. +# + +# +# Version should match the current Randr version. XRRQueryVersion +# returns the version from randr.h, NOT the version we set here. But we +# try to keep these the same. Note that the library has an extra +# digit in the version number to track changes which don't affect the +# protocol, so Xrandr version l.n.m corresponds to protocol version l.n +# +project( + 'libXrandr', + 'c', + version: '1.5.4', + license: 'HPND-sell-variant', + 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') + +# Check randr configuration, strip extra digits from package version to +# find the required protocol version +libXrandr_version = meson.project_version() +libXrandr_vers_components = libXrandr_version.split('.') +randrext_version = '.'.join(libXrandr_vers_components[0], + libXrandr_vers_components[1]) + +# Obtain compiler/linker options for dependencies +dep_libx11 = dependency('x11', required: true, version: '>= 1.6') +dep_randrproto = dependency('randrproto', required: true, + version: '>=' + randrext_version) +dep_libxext = dependency('xext', required: true) +dep_xextproto = dependency('xextproto', required: true) +dep_libxrender = dependency('xrender', required: true) +dep_renderproto = dependency('renderproto', required: true) + +libXrandr_sources = [ + 'src/Xrandr.c', + 'src/XrrConfig.c', + 'src/XrrCrtc.c', + 'src/XrrMode.c', + 'src/XrrOutput.c', + 'src/XrrProperty.c', + 'src/XrrScreen.c', + 'src/XrrProvider.c', + 'src/XrrProviderProperty.c', + 'src/XrrMonitor.c' +] + +lib = library( + 'Xrandr', + libXrandr_sources, + include_directories: 'include/X11/extensions', + dependencies: [dep_randrproto, dep_libxext, dep_xextproto, + dep_libxrender, dep_renderproto, dep_libx11], + version: '2.2.0', + install: true, +) + +install_headers( + 'include/X11/extensions/Xrandr.h', + subdir: 'X11/extensions', +) + +pkg = import('pkgconfig') +pkg.generate( + lib, + description: 'X RandR Library', + filebase: 'xrandr', + requires: ['xproto', 'randrproto'], + url: 'https://gitlab.freedesktop.org/xorg/lib/libxrandr/' +) + +prog_sed = find_program('sed') + +libXrandr_manpages = [ + 'Xrandr', + 'XRRQueryExtension', + 'XRRQueryVersion', + 'XRRGetScreenInfo', + 'XRRFreeScreenConfigInfo', + 'XRRSetScreenConfig', + 'XRRSetScreenConfigAndRate', + 'XRRConfigRotations', + 'XRRConfigTimes', + 'XRRConfigSizes', + 'XRRConfigRates', + 'XRRConfigCurrentConfiguration', + 'XRRConfigCurrentRate', + 'XRRRootToScreen', + 'XRRSelectInput' +] + +lib_man_suffix = get_option('lib_man_suffix') +foreach man: libXrandr_manpages + custom_target( + f'@man@.man', + input: f'man/@man@.man', + output: f'@man@.@lib_man_suffix@', + command: [ + prog_sed, + '-e', 's/__vendorversion__/"libXrandr @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/xrandr.pc.in b/xrandr.pc.in index c691d17..1aef6b1 100644 --- a/xrandr.pc.in +++ b/xrandr.pc.in @@ -1,12 +1,13 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@ includedir=@includedir@ +libdir=@libdir@ Name: Xrandr Description: X RandR Library +URL: https://gitlab.freedesktop.org/xorg/lib/libxrandr/ Version: @VERSION@ Requires: xproto randrproto >= @RANDR_VERSION@ Requires.private: x11 xext xrender -Cflags: -I${includedir} Libs: -L${libdir} -lXrandr +Cflags: -I${includedir} |