diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-03-02 11:42:44 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2025-03-02 11:57:17 -0800 |
commit | 16a6c58d0cde64a32f3c17a64649799f629ac6f4 (patch) | |
tree | 201fa617a7e4a15a4a3f4acd0c04630c0548b3d1 | |
parent | d5652ea6df2007cff03f5d8edb6fb1b9a0599ba9 (diff) |
meson: Add option to build with meson
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/app/smproxy/-/merge_requests/4>
-rw-r--r-- | .gitlab-ci.yml | 86 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | meson.build | 92 |
3 files changed, 175 insertions, 5 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4bdbe0b..12a4bb6 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: '2021-12-04.0' - FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake make xorg-util-macros xorgproto libsm libxt libice libxmu' + FDO_DISTRIBUTION_TAG: '2025-03-02.0' + # minimal set of packages required to build and install either way + BASE_PACKAGES: 'git gcc clang pkgconf xorgproto libsm libxt libice libxmu' + # packages needed to build and install with each set of tools + AUTOTOOLS_PACKAGES: 'autoconf automake 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,75 @@ build: - make - make check - make distcheck + - mv smproxy-*.tar.gz .. - popd > /dev/null + artifacts: + paths: + - smproxy-*.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 smproxy-*.tar.gz -C _tarball_build + - cd _tarball_build/smproxy-* + - 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 + - meson compile -C builddir -v + - DESTDIR=$PWD/_meson_inst meson install -C builddir + # SMPROXY_LIBS are specified in the same order as meson links them + - ./autogen.sh --prefix=/usr + CFLAGS="-O2 -D_FILE_OFFSET_BITS=64" + SMPROXY_LIBS="-lSM -lICE -lXt -lX11 -lXmuu" + - make V=1 && make install DESTDIR=$PWD/_autotools_inst + # get rid of expected differences between the two + - 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/smproxy 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 d3902b2..2d98381 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,4 +42,4 @@ ChangeLog: dist-hook: ChangeLog INSTALL -EXTRA_DIST = README.md +EXTRA_DIST = README.md meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..54e75ca --- /dev/null +++ b/meson.build @@ -0,0 +1,92 @@ +# 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( + 'smproxy', + 'c', + version: '1.0.7', + license: 'MIT-Open-Group', + license_files: 'COPYING', + meson_version: '>= 1.1.0', +) + +cc = meson.get_compiler('c') + +conf = configuration_data() +conf.set_quoted('PACKAGE_STRING', + ' '.join(meson.project_name(), meson.project_version())) + +# Replaces AC_USE_SYSTEM_EXTENSIONS +if host_machine.system() == 'sunos' + system_extensions = '__EXTENSIONS__' +elif host_machine.system() == 'netbsd' + system_extensions = '_NETBSD_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 + +# Checks for library functions. +conf.set('HAVE_ASPRINTF', cc.has_function('asprintf') ? '1' : false) +conf.set('HAVE_MKSTEMP', cc.has_function('mkstemp') ? '1' : false) +conf.set('HAVE_MKTEMP', cc.has_function('mktemp') ? '1' : false) + +# Checks for pkg-config packages +dep_libsm = dependency('sm', required: true) +dep_libice = dependency('ice', required: true) +dep_libxt = dependency('xt', required: true) +dep_libxmuu = dependency('xmuu', required: true) + +config_h = configure_file(output: 'config.h', configuration: conf) +add_project_arguments('-DHAVE_CONFIG_H', language: ['c']) + +executable( + 'smproxy', + [config_h, 'save.c', 'smproxy.c', 'smproxy.h'], + dependencies: [dep_libsm, dep_libice, dep_libxt, dep_libxmuu], + install: true +) + +prog_sed = find_program('sed') + +custom_target( + 'smproxy.man', + input: 'man/smproxy.man', + output: 'smproxy.1', + command: [ + prog_sed, + '-e', 's/__xorgversion__/"smproxy @0@" "X Version 11"/'.format(meson.project_version()), + '-e', 's/__appmansuffix__/1/g', + '@INPUT@', + ], + capture: true, + install: true, + install_dir: get_option('mandir') / 'man1', +) |