diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-09-04 12:37:04 +1000 |
---|---|---|
committer | Sergey Udaltsov <sergey.udaltsov@gmail.com> | 2020-06-19 21:46:51 +0000 |
commit | 7095744237eeb7eccfd72d9958191d990587f1d5 (patch) | |
tree | 80b3d7cce6b2487fae6cdd8c4bdcc2621f1c8929 | |
parent | 3e39f931e39a81870f966f8e9fe24e1dd447e51b (diff) | |
download | xkeyboard-config-7095744237eeb7eccfd72d9958191d990587f1d5.tar.gz |
Add support for the meson build system
This produces virtually the same installed tree as the autotools builds with
the following exceptions:
- rules symlinks is no longer supported. This option is 16y old and likely
hasn't been used in the last decade or so
- the xkeyboard-config.pc file uses expanded paths now, e.g.
xkb_base=/usr/share/X11/xkb
vs autotools'
xkb_base=${datarootdir}/X11/xkb
The values are the same for both so this is not a functional change.
- substitutions in the man page are hardcoded since we can't use the m4
XORG_MACROS. This appears to only matter for the miscmansuffix and there
only for solaris up to including 11.3. so... meh?
- the .mo files differ, but it's hard to say why since they're generated
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | .gitlab-ci.yml | 37 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | meson.build | 63 | ||||
-rw-r--r-- | meson_options.txt | 8 | ||||
-rw-r--r-- | po/meson.build | 2 | ||||
-rwxr-xr-x | rules/compat/map-variants.py | 7 | ||||
-rw-r--r-- | rules/compat/meson.build | 84 | ||||
-rw-r--r-- | rules/meson.build | 174 |
8 files changed, 374 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b008e5..6f26f3b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: # minimal set of packages required to build xkeyboard-config. extra packages # will be installed in the tests where required. - ARCH_PKGS: 'xorg-util-macros autoconf automake make gettext pkg-config gcc grep m4 python' + ARCH_PKGS: 'xorg-util-macros autoconf automake make gettext pkg-config gcc grep m4 python meson ninja git' BUILDDIR: '_build' # installation directory must be inside $CI_PROJECT_DIR to allow for artifact caching INSTDIR: '$CI_PROJECT_DIR/_inst' @@ -33,6 +33,15 @@ variables: - make - if test x"$MAKE_EXTRA_COMMAND" != "x"; then make $MAKE_EXTRA_COMMAND; fi + +.meson_build: + extends: .default_setup + script: + - meson "$BUILDDIR" -Dprefix="$INSTDIR" + - meson configure "$BUILDDIR" + - ninja -C "$BUILDDIR" + - if test x"$NINJA_EXTRA_COMMAND" != "x"; then ninja -C "$BUILDDIR" $NINJA_EXTRA_COMMAND; fi + make_install: extends: .default_build stage: build @@ -59,6 +68,32 @@ make_distcheck: variables: MAKE_EXTRA_COMMAND: "distcheck" +meson_build: + extends: .meson_build + stage: build + variables: + NINJA_EXTRA_COMMAND: "install" + after_script: + - pacman -S --noconfirm tree + - tree $INSTDIR + artifacts: + name: installed files + expire_in: 20 min + paths: + - $INSTDIR/ + +meson_test: + extends: .meson_build + stage: build + variables: + NINJA_EXTRA_COMMAND: "test" + +meston_dist: + extends: .meson_build + stage: build + variables: + NINJA_EXTRA_COMMAND: "dist" + xmllint: image: archlinux/base dependencies: ['make_install'] diff --git a/configure.ac b/configure.ac index 720158c..ec918c4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(xkeyboard-config, 2.30) +AC_INIT(xkeyboard-config, 2.30) # change version in meson.build as well AC_CONFIG_SRCDIR(rules/base.xml) AM_INIT_AUTOMAKE([foreign dist-bzip2]) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..c388a44 --- /dev/null +++ b/meson.build @@ -0,0 +1,63 @@ +project('xkeyboard-config', 'c', + version: '2.30', # change version in configure.ac as well + license: 'MIT/Expat', + meson_version: '>= 0.54.0') + +dir_data = join_paths(get_option('prefix'), get_option('datadir')) +dir_xkb_base = join_paths(dir_data, 'X11', 'xkb') +dir_xkb_rules = join_paths(dir_xkb_base, 'rules') +dir_man7 = join_paths(get_option('prefix'), get_option('mandir'), 'man7') +dir_pkgconfig = join_paths(dir_data, 'pkgconfig') + +i18n = import('i18n') + +pkgconfig = import('pkgconfig') +pkgconfig.generate( + filebase: 'xkeyboard-config', + name: 'XKeyboardConfig', + description: 'X Keyboard configuration data', + version: meson.project_version(), + variables: [ + 'datadir=@0@'.format(dir_data), + 'xkb_base=@0@'.format(dir_xkb_base), + ], + install_dir: dir_pkgconfig, + dataonly: true, +) + +# KcGST only need to be installed as-is +foreach dir: ['compat', 'geometry', 'keycodes', 'symbols', 'types'] + install_subdir(dir, + exclude_files: ['Makefile.am'], + install_dir: dir_xkb_base) +endforeach + +# Rules are a bit more complicated +subdir('rules') + +# man page +xsltproc = find_program('xsltproc', required: false) +if xsltproc.found() + man_substs = configuration_data() + man_substs.set('xkb_base', dir_xkb_base) + # emulating what the macros do for vendorversion, hardcoding the man + # suffixes + man_substs.set('vendorversion', '"@0@ @1@" "X Version 11"'.format(meson.project_name(), meson.project_version())) + man_substs.set('appmansuffix', '1') + man_substs.set('miscmansuffix', '7') + xsl = configure_file(input: 'man/man.xsl', + output: 'man.xsl', + configuration: man_substs, + install: false) + # evdev_ruleset is set by rules/meson.build + manpage = custom_target('man page', + output: 'xkeyboard-config.7', + build_by_default: true, + command: [xsltproc, '-nonet', xsl, evdev_ruleset], + capture: true, + install:true, + install_dir: dir_man7) + +endif + +subdir('po') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..1bee74b --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,8 @@ +option('xkb-base', + type: 'string', + value: '', + description: 'XKB base path [default=$datadir/X11/xkb]') +option('compat-rules', + type: 'boolean', + value: true, + description: 'create compatibility rules [default=true]') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..0521810 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,2 @@ +i18n = import('i18n') +i18n.gettext('xkeyboard-config', preset: 'glib') diff --git a/rules/compat/map-variants.py b/rules/compat/map-variants.py index 2162d65..92d3a80 100755 --- a/rules/compat/map-variants.py +++ b/rules/compat/map-variants.py @@ -2,6 +2,7 @@ import argparse import re +import sys class Layout(object): @@ -132,5 +133,9 @@ if __name__ == '__main__': parser.add_argument('files', nargs='+', type=str) ns = parser.parse_args() - with open(ns.dest, 'w') as fd: + dest = None + if ns.dest == '-': + dest = sys.stdout + + with dest or open(ns.dest, 'w') as fd: map_variant(fd, ns.files, ns.want, ns.number) diff --git a/rules/compat/meson.build b/rules/compat/meson.build new file mode 100644 index 0000000..8510a3e --- /dev/null +++ b/rules/compat/meson.build @@ -0,0 +1,84 @@ +# generated files +rules_compat_generated = [] + +layout_mappings = files('layoutsMapping.lst') +variant_mappings = files('variantsMapping.lst') +map_variants_py = find_program('map-variants.py') + +ml_s_file = 'base.ml_s.part' +ml_s = custom_target(ml_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mls', + '@OUTPUT@', + layout_mappings, + variant_mappings, + ], + output: ml_s_file, + install: false) +rules_compat_generated += [ml_s] + +# base.mlv_s.part and friends +mlv_s_file = 'base.mlv_s.part' +mlv_s = custom_target(mlv_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mlvs', + '@OUTPUT@', + variant_mappings, + ], + output: mlv_s_file, + install: false) +rules_compat_generated += [mlv_s] + +foreach lvl: [1, 2, 3, 4] + # base.ml1_s.part and friends + ml_s_file = 'base.ml@0@_s.part'.format(lvl) + ml_s = custom_target(ml_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mls', + '--number=@0@'.format(lvl), + '@OUTPUT@', + layout_mappings, + variant_mappings, + ], + output: ml_s_file, + install: false) + rules_compat_generated += [ml_s] + + # base.ml1v1_s.part and friends + mlv_s_file = 'base.ml@0@v@0@_s.part'.format(lvl) + mlv_s = custom_target(mlv_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mlvs', + '--number=@0@'.format(lvl), + '@OUTPUT@', + variant_mappings, + ], + output: mlv_s_file, + install: false) + rules_compat_generated += [mlv_s] +endforeach + +# Non-generated files +others = [ + 'base.lists.part', + 'base.lv_c.part', + 'base.l1v1_c.part', + 'base.l2v2_c.part', + 'base.l3v3_c.part', + 'base.l4v4_c.part', + 'base.o_s.part', +] +foreach o: others + configure_file(output: o, + input: o, + copy: true, + install: false) +endforeach diff --git a/rules/meson.build b/rules/meson.build new file mode 100644 index 0000000..c992f2e --- /dev/null +++ b/rules/meson.build @@ -0,0 +1,174 @@ +# And some files that are a straight install +install_data('README', 'xkb.dtd', 'xfree98', + install_dir: dir_xkb_rules) + +# the actual rules files are generated from a list of parts in a very +# specific order +parts = [ + '0000-hdr.part', + '0001-lists.part', + '0002-@0@.lists.part', + '0004-@0@.m_k.part', + '0005-l1_k.part', + '0006-l_k.part', + '0007-o_k.part', + '0008-ml_g.part', + '0009-m_g.part', + '0011-mlv_s.part', + '0013-ml_s.part', + '0015-ml1_s.part', + '0018-ml2_s.part', + '0020-ml3_s.part', + '0022-ml4_s.part', + '0026-@0@.m_s.part', + '0027-@0@.ml_s1.part', + '0033-ml_c.part', + '0034-ml1_c.part', + '0035-m_t.part', + '0036-lo_s.part', + '0037-l1o_s.part', + '0038-l2o_s.part', + '0039-l3o_s.part', + '0040-l4o_s.part', + '0042-o_s.part', + '0043-o_c.part', + '0044-o_t.part', +] + +# generated compat parts +rules_compat_generated = [] + +if get_option('compat-rules') + # non-generated compat parts + parts += [ + 'compat/0003-lists.part', + 'compat/0028-lv_c.part', + 'compat/0029-l1v1_c.part', + 'compat/0030-l2v2_c.part', + 'compat/0031-l3v3_c.part', + 'compat/0032-l4v4_c.part', + 'compat/0041-o_s.part', + ] + + layout_mappings = files('compat/layoutsMapping.lst') + variant_mappings = files('compat/variantsMapping.lst') + map_variants_py = find_program('compat/map-variants.py') + + # two sets of files are generated: ml_s.part and mlv_s.part + # each with the level name in the filename + lvl_ml_s = { + '0': '0012-ml_s.part', + '1': '0014-ml1_s.part', + '2': '0017-ml2_s.part', + '3': '0019-ml3_s.part', + '4': '0021-ml4_s.part', + } + + lvl_mlv_s = { + '0': '0010-mlv_s.part', + '1': '0016-ml1v1_s.part', + '2': '0023-ml2v2_s.part', + '3': '0024-ml3v3_s.part', + '4': '0025-ml4v4_s.part', + } + + foreach lvl: [0, 1, 2, 3, 4] + ml_s_file = lvl_ml_s['@0@'.format(lvl)] + ml_s = custom_target(ml_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mls', + '--number=@0@'.format(lvl), + '@OUTPUT@', + layout_mappings, + variant_mappings, + ], + output: ml_s_file, + install: false) + rules_compat_generated += [ml_s] + + mlv_s_file = lvl_mlv_s['@0@'.format(lvl)] + mlv_s = custom_target(mlv_s_file, + build_by_default: true, + command: [ + map_variants_py, + '--want=mlvs', + '--number=@0@'.format(lvl), + '@OUTPUT@', + variant_mappings, + ], + output: mlv_s_file, + install: false) + rules_compat_generated += [mlv_s] + endforeach +endif # compat-rules + +merge_py = find_program('merge.py') +perl = find_program('perl') +xml2lst = find_program('xml2lst.pl') +foreach ruleset: ['base', 'evdev'] + # generate the "evdev" and "base" rules files + # + # First: copy all the parts over to the build directory, replacing + # RULESET with the rulename (evdev or base) and prefix it with the + # ruleset name. So 0000-hdr.part becomes 0000-hdr.part.evdev and + # 0000-hdr.part.base + rules_parts = [] + foreach part: parts + infile = part.format(ruleset) + p = configure_file(output: '@PLAINNAME@.@0@'.format(ruleset), + input: infile, + copy: true, + install: false) + rules_parts += p + endforeach + + # Second: merge those parts together into the actual rules file + custom_target('rules-@0@'.format(ruleset), + build_by_default: true, + command: [ + merge_py, + rules_parts + rules_compat_generated, + ], + depends: rules_compat_generated, + output: ruleset, + capture: true, + install: true, + install_dir: dir_xkb_rules) + + # Third: the xml files, simply copied from the base*.xml files + ruleset_xml = configure_file(output: '@0@.xml'.format(ruleset), + input: 'base.xml', + copy: true, + install: true, + install_dir: dir_xkb_rules) + + # This is used by the man page's meson.build + if ruleset == 'evdev' + evdev_ruleset = ruleset_xml + endif + + configure_file(output: '@0@.extras.xml'.format(ruleset), + input: 'base.extras.xml', + copy: true, + install: true, + install_dir: dir_xkb_rules) + + # Fourth: generate the evdev.lst and base.lst files + lst_file = '@0@.lst'.format(ruleset) + custom_target(lst_file, + build_by_default: true, + command: [xml2lst, ruleset_xml], + capture: true, + output: lst_file, + install: true, + install_dir: dir_xkb_rules) +endforeach + +# Copy the DTD to the build directory, the man page generation expects it in +# the same directory as the input XML file. +configure_file(output: 'xkb.dtd', + input: 'xkb.dtd', + copy: true, + install: false) |