diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 236df00020bb682007966f0113d1eac5a945396d..d76d8987535c7e5bef27dba96b73082585e84b3d 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 libxaw libxmu libxt' + 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 libxaw libxmu libxt' + # 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 viewres-*.tar.gz .. - popd > /dev/null + artifacts: + paths: + - viewres-*.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 viewres-*.tar.gz -C _tarball_build + - cd _tarball_build/viewres-* + - 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 + # VIEWRES_LIBS are specified in the same order as meson links them + - ./autogen.sh --prefix=/usr + CFLAGS="-O2 -D_FILE_OFFSET_BITS=64" + VIEWRES_LIBS="-lXaw -lXt -lX11 -lXmu" + - 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/viewres 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 959d138d1689d5b0a01ef58ed0878ff51c299069..fa4dbc6e267559e15b3787a526d1b8a8aeca16eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,4 +50,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 0000000000000000000000000000000000000000..94b4799916366c121dfde146ddcc1e254601a010 --- /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( + 'viewres', + '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())) +config_h = configure_file(output: 'config.h', configuration: conf) +add_project_arguments('-DHAVE_CONFIG_H', language: ['c']) + +# Replacement for XORG_DEFAULT_OPTIONS +if cc.has_argument('-fno-strict-aliasing') + add_project_arguments('-fno-strict-aliasing', language: 'c') +endif + +# Checks for pkg-config packages +dep_libxaw = dependency('xaw7', required: true) +dep_libxmu = dependency('xmu', required: true) +dep_libxt = dependency('xt', required: true) +dep_xproto = dependency('xproto', required: true, version: '>= 7.0.22') + +add_project_arguments('-D_CONST_X_STRING', language: ['c']) + +executable( + 'viewres', + [config_h, 'viewres.c'], + dependencies: [dep_libxaw, dep_libxmu, dep_libxt, dep_xproto], + install: true +) + +# Find directory for installing app-defaults files +appdefaultdir = get_option('appdefaultdir') +if appdefaultdir == '' + appdefaultdir = dep_libxt.get_variable('appdefaultdir') +endif +summary('appdefaultdir', appdefaultdir) + +# App default files +appdefaults = [ + 'app-defaults/Viewres', + 'app-defaults/Viewres-color' +] +install_data(appdefaults, install_dir: appdefaultdir) + +prog_sed = find_program('sed') + +custom_target( + 'viewres.man', + input: 'man/viewres.man', + output: 'viewres.1', + command: [ + prog_sed, + '-e', 's/__xorgversion__/"viewres @0@" "X Version 11"/'.format(meson.project_version()), + '-e', 's/__appmansuffix__/1/g', + '-e', 's/__miscmansuffix__/7/g', + '@INPUT@', + ], + capture: true, + install: true, + install_dir: get_option('mandir') / 'man1', +) diff --git a/meson.options b/meson.options new file mode 100644 index 0000000000000000000000000000000000000000..2b5929123deeead9f0319e75e4e4ac4fc7865897 --- /dev/null +++ b/meson.options @@ -0,0 +1,5 @@ +option( + 'appdefaultdir', + type: 'string', + description: 'directory for app-defaults files (default is autodetected)', +)