From b297a7738a02b3fb7a8842e054c4068195038c38 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 7 Apr 2024 13:58:13 -0700 Subject: meson: Add a meson build system Signed-off-by: Alan Coopersmith Part-of: --- .editorconfig | 17 ++++++++++++++++ .gitlab-ci.yml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- Makefile.am | 2 +- meson.build | 40 +++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 meson.build diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f15786 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = tab +indent_size = 8 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{meson.build, meson_options.txt}] +indent_size = 2 +indent_style = space + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 558b234..53867d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,8 +30,9 @@ 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-03.0' - FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake make xorg-util-macros xorgproto libx11 libxt' + FDO_DISTRIBUTION_TAG: '2023-04-07.0' + # jq is only needed for meson-vs-autoconf version check + FDO_DISTRIBUTION_PACKAGES: 'git meson ninja gcc pkgconf jq autoconf automake make xorg-util-macros xorgproto libx11 libxt' # @@ -83,7 +84,19 @@ container-prep: # # The default build, runs on the image built above. # -build: + +meson: + extends: + - .fdo.distribution-image@arch + stage: build + script: + - mkdir -p ../_inst + - meson setup builddir --prefix="$PWD/../_inst" $MESON_OPTIONS + - meson configure builddir + - ninja -C builddir test + - ninja -C builddir install + +autotools: stage: build extends: - .fdo.distribution-image@arch @@ -96,3 +109,46 @@ build: - make check - make distcheck - popd > /dev/null + +# +# Unlike the xproto version this was copied from, this just compares +# the ls output to make sure the same files were installed, since +# comparing file contents lists mismatches with the ELF binaries and +# in the generated pkg-config files that are not issues here. +# +compare meson and autotools: + extends: + - .fdo.distribution-image@arch + stage: test + script: + - mkdir -p $PWD/_meson_inst + - mkdir -p $PWD/_autotools_inst + # Use a symlink to have the same --prefix for meson and autotools + - ln -sf $PWD/_meson_inst $PWD/_inst + - meson builddir + - meson configure builddir --prefix=$PWD/_inst + - ninja -C builddir install + - ls -R _inst > _meson_inst.ls + - rm $PWD/_inst + - ln -sf $PWD/_autotools_inst $PWD/_inst + - autoreconf -ivf + - ./configure --prefix=$PWD/_inst + - make && make install + - rm -f $PWD/_inst/lib/lib*.la + - ls -R _inst > _autotools_inst.ls + - diff -u $PWD/_meson_inst.ls $PWD/_autotools_inst.ls + - diff -u $PWD/_{autotools,meson}_inst/share/man + +check versions are in sync: + extends: + - .fdo.distribution-image@arch + stage: test + script: + - autoreconf -ivf + - ./configure --version | head -n 1 | sed -e 's/appres configure //' > autotools.version + - | + meson builddir + pushd builddir + meson introspect --projectinfo | jq -r '.version' > ../meson.version + popd + - 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 1a3a7fa..95b38cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,4 +40,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..9d27cb9 --- /dev/null +++ b/meson.build @@ -0,0 +1,40 @@ +project('appres', 'c', + version : '1.0.6', + license : 'MIT', + default_options: ['warning_level=3'], +) + +cc = meson.get_compiler('c') + +prefix = get_option('prefix') + +package_string = '@0@ @1@'.format(meson.project_name(), meson.project_version()) + +conf_data = configuration_data() +conf_data.set('PACKAGE_STRING', '"@0@"'.format(package_string)) +configure_file(output : 'config.h', configuration : conf_data) +add_global_arguments('-DHAVE_CONFIG_H', language : 'c') + +x11_dep = dependency('x11', required: true) +xmuu_dep = dependency('xt', required: true) +xproto_dep = dependency('xproto', required: true, version: '>= 7.0.17') + +sources = ['appres.c'] +executable('appres', sources, + dependencies: [x11_dep, xmuu_dep, xproto_dep], + install: true) + +man = join_paths(prefix, get_option('mandir')) + +man_conf = configuration_data() +man_conf.set('PACKAGE_STRING', package_string) +man_conf.set('APP_MAN_SUFFIX', '1') +man_conf.set('MISC_MAN_SUFFIX', '7') +man_conf.set('XORG_MAN_PAGE', 'X Version 11') + +install_man(configure_file( + input: 'man/appres.man', + output: 'appres.1', + install_dir: join_paths(man, 'man1'), + configuration: man_conf +)) -- cgit v1.2.3