diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-02-23 17:28:28 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-02-23 18:12:17 -0800 |
commit | 61b84c2d424f363fb0983cb478937de87084ef54 (patch) | |
tree | 52a0335d06d6d06c2dbf6ae9d131a913020b8aa9 | |
parent | 8ae6cf61b18ecddf26f72a07bbfbd1ea9f022c36 (diff) |
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/libxcursor/-/merge_requests/24>
-rw-r--r-- | .gitlab-ci.yml | 92 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | meson.build | 247 | ||||
-rw-r--r-- | meson.options | 8 | ||||
-rw-r--r-- | xcursor.pc.in | 8 |
5 files changed, 349 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bffb9f1..f4819a7 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-04-03.0' - FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool make xorg-util-macros libxrender libxfixes libx11 xorgproto' + FDO_DISTRIBUTION_TAG: '2025-02-15.0' + # minimal set of packages required to build and install either way + BASE_PACKAGES: 'git gcc clang pkgconf libxrender libxfixes libx11 xorgproto' + # 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 libXcursor*.tar.gz .. - popd > /dev/null + artifacts: + paths: + - libXcursor*.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 libXcursor-*.tar.gz -C _tarball_build + - cd _tarball_build/libXcursor-* + - 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" XCURSOR_LIBS="-lXrender -lX11 -lXfixes" + - 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/libXcursor.so + - ln -s libXcursor.so.1 $PWD/_autotools_inst/usr/lib/libXcursor.so + - sed -i -e '/Generated from Xcursor.h.in by configure/d' + _autotools_inst/usr/include/X11/Xcursor/Xcursor.h + - sed -i -e 's/{exec_prefix}/{prefix}/' -e '/exec_prefix/d' + _autotools_inst/usr/lib/pkgconfig/xcursor.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/libXcursor 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 08b5958..5c954d6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,4 +44,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..e33e305 --- /dev/null +++ b/meson.build @@ -0,0 +1,247 @@ +# 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. +# + +# +# This is the package version number, not the shared library +# version. This version number will be substituted into Xcursor.h +# +project( + 'libXcursor', + 'c', + version: '1.2.3', + license: 'HPND-sell-variant', + license_files: 'COPYING', + meson_version: '>= 1.1.0', +) + +cc = meson.get_compiler('c') +conf = configuration_data() + +# Replaces AC_USE_SYSTEM_EXTENSIONS +if host_machine.system() == 'sunos' + system_extensions = '__EXTENSIONS__' +elif host_machine.system() == 'netbsd' + system_extensions = '_OPENBSD_SOURCE' +else + system_extensions = '_GNU_SOURCE' +endif +conf.set(system_extensions, 1, + description: 'Enable non-standardized system API extensions') + +# Replacement for XORG_DEFAULT_OPTIONS +if cc.has_argument('-fno-strict-aliasing') + add_project_arguments('-fno-strict-aliasing', language: 'c') +endif + +prog_sed = find_program('sed') + +# Set library version for Xcursor.h from package version set above +xcursor_version = meson.project_version() +xcursor_vers_components = xcursor_version.split('.') +conf.set('XCURSOR_LIB_MAJOR', xcursor_vers_components[0], + description: 'Major version of libXcursor') +conf.set('XCURSOR_LIB_MINOR', xcursor_vers_components[1], + description: 'Minor version of libXcursor') +conf.set('XCURSOR_LIB_REVISION', xcursor_vers_components[2], + description: 'Micro revision of libXcursor') +# Temporary solution to allow building with either autoconf or meson +# during the transition period - can be replaced by configure_file() +# and use of '#mesondefine' when configure.ac is removed. +xcursor_h = custom_target( + input: 'include/X11/Xcursor/Xcursor.h.in', + output: 'Xcursor.h', + command: [ + prog_sed, + '-e', f's/#undef XCURSOR_LIB_MAJOR/#define XCURSOR_LIB_MAJOR @0@/'.format(conf.get('XCURSOR_LIB_MAJOR')), + '-e', f's/#undef XCURSOR_LIB_MINOR/#define XCURSOR_LIB_MINOR @0@/'.format(conf.get('XCURSOR_LIB_MINOR')), + '-e', f's/#undef XCURSOR_LIB_REVISION/#define XCURSOR_LIB_REVISION @0@/'.format(conf.get('XCURSOR_LIB_REVISION')), + '@INPUT@', + ], + capture: true, + install: true, + install_dir: get_option('includedir') / 'X11/Xcursor' +) + +icondir = get_option('icondir') +if icondir == 'auto' + icondir = get_option('prefix') / get_option('datadir') / 'icons' +endif +conf.set_quoted('ICONDIR', icondir, description: 'Default icon directory') + +cursorpath = get_option('cursorpath') +if cursorpath == 'auto' + cursordirs = [ + '~/.local/share/icons', + '~/.icons', + get_option('prefix') / get_option('datadir') / 'icons', + get_option('prefix') / get_option('datadir') / 'pixmaps' + ] + if not cursordirs.contains(icondir) + cursordirs += icondir + endif + cursorpath = ':'.join(cursordirs) +endif +conf.set_quoted('XCURSORPATH', cursorpath, + description: 'Default search path for cursors') + +# Obtain compiler/linker options for dependencies +dep_xrender = dependency('xrender', required: true, version: '>= 0.8.2') +dep_libxfixes = dependency('xfixes', required: true) +dep_libx11 = dependency('x11', required: true) +dep_fixesproto = dependency('fixesproto', required: true) + +conf.set('HAVE_XFIXES', 1, description: 'Define to 1 if you have Xfixes') + +config_h = configure_file( + configuration : conf, + output : 'config.h', +) +add_project_arguments('-DHAVE_CONFIG_H', language: 'c') + +libXcursor_sources = [ + config_h, + xcursor_h, + 'src/xcursorint.h', + 'src/cursor.c', + 'src/display.c', + 'src/file.c', + 'src/library.c', + 'src/xlib.c' +] + +lib = library( + 'Xcursor', + libXcursor_sources, + include_directories: 'include', + dependencies: [dep_xrender, dep_libxfixes, dep_libx11, dep_fixesproto], + version: '1.0.2', + install: true, +) + +datarootdir = get_option('prefix') / get_option('datadir') +pc_datarootdir = datarootdir.replace(get_option('prefix'), '${prefix}') +pc_icondir = icondir.replace(datarootdir, '${datarootdir}') +pc_icondir = pc_icondir.replace(get_option('prefix'), '${prefix}') + +pkg = import('pkgconfig') +pkg.generate( + name: 'Xcursor', + description: 'X Cursor Library', + filebase: 'xcursor', + libraries: '-L${libdir} -lXcursor', + requires: ['xproto'], + requires_private: ['x11', 'xrender', 'xfixes'], + variables: [ + 'datarootdir=' + pc_datarootdir, + 'icondir=' + pc_icondir, + ], + url: 'https://gitlab.freedesktop.org/xorg/lib/libxcursor/' +) + +prog_sed = find_program('sed') + +libXcursor_manpages = [ + 'Xcursor', + 'XcursorAnimateCreate', + 'XcursorAnimateDestroy', + 'XcursorAnimateNext', + 'XcursorCommentCreate', + 'XcursorCommentDestroy', + 'XcursorCommentsCreate', + 'XcursorCommentsDestroy', + 'XcursorCursorsCreate', + 'XcursorCursorsDestroy', + 'XcursorFileLoad', + 'XcursorFileLoadAllImages', + 'XcursorFileLoadImage', + 'XcursorFileLoadImages', + 'XcursorFileSave', + 'XcursorFileSaveImages', + 'XcursorFilenameLoad', + 'XcursorFilenameLoadAllImages', + 'XcursorFilenameLoadCursor', + 'XcursorFilenameLoadCursors', + 'XcursorFilenameLoadImage', + 'XcursorFilenameLoadImages', + 'XcursorFilenameSave', + 'XcursorFilenameSaveImages', + 'XcursorGetDefaultSize', + 'XcursorGetTheme', + 'XcursorGetThemeCore', + 'XcursorImageCreate', + 'XcursorImageDestroy', + 'XcursorImageHash', + 'XcursorImageLoadCursor', + 'XcursorImagesCreate', + 'XcursorImagesDestroy', + 'XcursorImagesLoadCursor', + 'XcursorImagesLoadCursors', + 'XcursorImagesSetName', + 'XcursorLibraryLoadCursor', + 'XcursorLibraryLoadCursors', + 'XcursorLibraryLoadImage', + 'XcursorLibraryLoadImages', + 'XcursorLibraryPath', + 'XcursorLibraryShape', + 'XcursorNoticeCreateBitmap', + 'XcursorNoticePutBitmap', + 'XcursorSetDefaultSize', + 'XcursorSetTheme', + 'XcursorSetThemeCore', + 'XcursorShapeLoadCursor', + 'XcursorShapeLoadCursors', + 'XcursorShapeLoadImage', + 'XcursorShapeLoadImages', + 'XcursorSupportsARGB', + 'XcursorSupportsAnim', + 'XcursorTryShapeBitmapCursor', + 'XcursorTryShapeCursor', + 'XcursorXcFileLoad', + 'XcursorXcFileLoadAllImages', + 'XcursorXcFileLoadImage', + 'XcursorXcFileLoadImages', + 'XcursorXcFileSave' +] + +# Change ':' to a comma and a space to help path formatting +comma_cursorpath = cursorpath.replace(':', ', ') + +lib_man_suffix = get_option('lib_man_suffix') +foreach man: libXcursor_manpages + custom_target( + f'@man@.man', + input: f'man/@man@.man', + output: f'@man@.@lib_man_suffix@', + command: [ + prog_sed, + '-e', 's/__xorgversion__/"libXcursor @0@" "X Version 11"/'.format(meson.project_version()), + '-e', f's/__libmansuffix__/@lib_man_suffix@/g', + '-e', 's%__XCURSORPATH__%@0@%g'.format(comma_cursorpath), + '@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..e0e1672 --- /dev/null +++ b/meson.options @@ -0,0 +1,8 @@ +option('icondir', type : 'string', value : 'auto', + description : 'Default icon directory') + +option('cursorpath', type : 'string', value : 'auto', + description : 'Default search path for cursors') + +option('lib_man_suffix', type : 'string', value : '3', + description : 'Suffix for library man pages') diff --git a/xcursor.pc.in b/xcursor.pc.in index f55bed3..19480ba 100644 --- a/xcursor.pc.in +++ b/xcursor.pc.in @@ -1,14 +1,16 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@ includedir=@includedir@ +libdir=@libdir@ + datarootdir=@datarootdir@ icondir=@ICONDIR@ Name: Xcursor Description: X Cursor Library +URL: https://gitlab.freedesktop.org/xorg/lib/libxcursor/ Version: @VERSION@ Requires: xproto -Requires.private: x11 xrender xfixes -Cflags: -I${includedir} +Requires.private: x11, xrender, xfixes Libs: -L${libdir} -lXcursor +Cflags: -I${includedir} |