meson.build revision 46185892
1# And some files that are a straight install
2install_data('README', 'xkb.dtd', 'xfree98',
3             install_dir: dir_xkb_rules)
4
5# the actual rules files are generated from a list of parts in a very
6# specific order
7parts = [
8    '0000-hdr.part',
9    '0001-lists.part',
10    '0002-@0@.lists.part',
11    '0004-@0@.m_k.part',
12    '0005-l1_k.part',
13    '0006-l_k.part',
14    '0007-o_k.part',
15    '0008-ml_g.part',
16    '0009-m_g.part',
17    '0011-mlv_s.part',
18    '0013-ml_s.part',
19    '0015-ml1_s.part',
20    '0018-ml2_s.part',
21    '0020-ml3_s.part',
22    '0022-ml4_s.part',
23    '0026-@0@.m_s.part',
24    '0027-@0@.ml_s1.part',
25    '0033-ml_c.part',
26    '0034-ml1_c.part',
27    '0035-m_t.part',
28    '0036-lo_s.part',
29    '0037-l1o_s.part',
30    '0038-l2o_s.part',
31    '0039-l3o_s.part',
32    '0040-l4o_s.part',
33    '0042-o_s.part',
34    '0043-o_c.part',
35    '0044-o_t.part',
36]
37
38# generated compat parts
39rules_compat_generated = []
40
41if get_option('compat-rules')
42  # non-generated compat parts
43  parts += [
44      'compat/0028-lv_c.part',
45      'compat/0029-l1v1_c.part',
46      'compat/0030-l2v2_c.part',
47      'compat/0031-l3v3_c.part',
48      'compat/0032-l4v4_c.part',
49      'compat/0041-o_s.part',
50  ]
51
52  layout_mappings = files('compat/layoutsMapping.lst')
53  variant_mappings = files('compat/variantsMapping.lst')
54  map_variants_py = find_program('compat/map-variants.py')
55
56  # two sets of files are generated: ml_s.part and mlv_s.part
57  # each with the level name in the filename
58  lvl_ml_s = {
59    '0': '0012-ml_s.part',
60    '1': '0014-ml1_s.part',
61    '2': '0017-ml2_s.part',
62    '3': '0019-ml3_s.part',
63    '4': '0021-ml4_s.part',
64  }
65
66  lvl_mlv_s = {
67    '0': '0010-mlv_s.part',
68    '1': '0016-ml1v1_s.part',
69    '2': '0023-ml2v2_s.part',
70    '3': '0024-ml3v3_s.part',
71    '4': '0025-ml4v4_s.part',
72  }
73
74  foreach lvl: [0, 1, 2, 3, 4]
75      ml_s_file = lvl_ml_s['@0@'.format(lvl)]
76      ml_s = custom_target(ml_s_file,
77                           build_by_default: true,
78                           command: [
79                               map_variants_py,
80                               '--want=mls',
81                               '--number=@0@'.format(lvl),
82                               '@OUTPUT@',
83                               layout_mappings,
84                               variant_mappings,
85                           ],
86                           output: ml_s_file,
87                           install: false)
88      rules_compat_generated += [ml_s]
89
90      mlv_s_file = lvl_mlv_s['@0@'.format(lvl)]
91      mlv_s = custom_target(mlv_s_file,
92                           build_by_default: true,
93                           command: [
94                               map_variants_py,
95                               '--want=mlvs',
96                               '--number=@0@'.format(lvl),
97                               '@OUTPUT@',
98                               variant_mappings,
99                           ],
100                           output: mlv_s_file,
101                           install: false)
102      rules_compat_generated += [mlv_s]
103  endforeach
104endif # compat-rules
105
106merge_py = find_program('merge.py')
107xml2lst = find_program('xml2lst.pl')
108foreach ruleset: ['base', 'evdev']
109    # generate the "evdev" and "base" rules files
110    #
111    # First: copy all the parts over to the build directory, replacing
112    # RULESET with the rulename (evdev or base) and prefix it with the
113    # ruleset name. So 0000-hdr.part becomes 0000-hdr.part.evdev and
114    # 0000-hdr.part.base
115    rules_parts = []
116    foreach part: parts
117      infile = part.format(ruleset)
118      p = configure_file(output: '@PLAINNAME@.@0@'.format(ruleset),
119                         input: infile,
120                         copy: true,
121                         install: false)
122      rules_parts += p
123    endforeach
124
125    # Second: merge those parts together into the actual rules file
126    custom_target('rules-@0@'.format(ruleset),
127                  build_by_default: true,
128                  command: [
129                      merge_py,
130                      rules_parts + rules_compat_generated,
131                  ],
132                  depends: rules_compat_generated,
133                  output: ruleset,
134                  capture: true,
135                  install: true,
136                  install_dir: dir_xkb_rules)
137
138    # Third: the xml files, simply copied from the base*.xml files
139    ruleset_xml = configure_file(output: '@0@.xml'.format(ruleset),
140                       input: 'base.xml',
141                       copy: true,
142                       install: true,
143                       install_dir: dir_xkb_rules)
144
145    # This is used by the man page's meson.build
146    if ruleset == 'evdev'
147      evdev_ruleset = ruleset_xml
148    endif
149
150    configure_file(output: '@0@.extras.xml'.format(ruleset),
151                   input: 'base.extras.xml',
152                   copy: true,
153                   install: true,
154                   install_dir: dir_xkb_rules)
155
156    # Fourth: generate the evdev.lst and base.lst files
157    lst_file = '@0@.lst'.format(ruleset)
158    custom_target(lst_file,
159                  build_by_default: true,
160                  command: [xml2lst, ruleset_xml],
161                  capture: true,
162                  output: lst_file,
163                  install: true,
164                  install_dir: dir_xkb_rules)
165
166endforeach
167
168if get_option('xorg-rules-symlinks')
169	foreach suffix: ['', '.lst', '.xml']
170		meson.add_install_script('sh', '-c',
171			'ln -s base@0@ $DESTDIR@1@/xorg@0@'.format(suffix, dir_xkb_rules))
172	endforeach
173endif
174# Copy the DTD to the build directory, the man page generation expects it in
175# the same directory as the input XML file.
176configure_file(output: 'xkb.dtd',
177               input: 'xkb.dtd',
178               copy: true,
179               install: false)
180