Debian Codegraph @

doc/meson.build

raw
1 # Extract list of man pages (one man page per symbol) from lib/libfribidi.def
2 python3 = import('python').find_installation()
3
4 result = run_command(python3,
5 '-c', 'import sys; print(open(sys.argv[1], "r").read())',
6 files('../lib/fribidi.def'),
7 check: false)
8
9 if result.returncode() != 0
10 error('Could not extract list of symbols from fribidi.def.')
11 endif
12
13 gen_man_pages = []
14
15 syms = result.stdout().strip().split('\n')
16 foreach sym : syms
17 # for consistency with autotools build and because we don't pass -v to c2man
18 if sym != 'fribidi_unicode_version' and sym != 'fribidi_version_info'
19 gen_man_pages += ['@[email protected]'.format(sym)]
20 endif
21 endforeach
22
23 # check if we have a tarball which contains the generated files
24 result = run_command(python3, '-c', '''import os.path; import sys
25 sys.exit(0 if os.path.isfile('@0@') else 1)'''.format(join_paths(meson.current_source_dir(), gen_man_pages[0])),
26 check: false)
27
28 have_man_pages = result.returncode() == 0
29 message('Have pre-generated man pages: @0@'.format(have_man_pages))
30
31 if have_man_pages
32 install_man(gen_man_pages)
33 else
34 c2man = find_program('c2man', required: false)
35 if not c2man.found()
36 error('c2man is required to build documentation from git. Or disable with -Ddocs=false')
37 endif
38
39 c2man_incs = []
40 c2man_incs += ['-I' + join_paths(meson.source_root(), 'lib')]
41 c2man_incs += ['-I' + join_paths(meson.build_root(), 'lib')]
42 c2man_incs += ['-I' + join_paths(meson.source_root(), 'gen.tab')]
43 c2man_incs += ['-I' + join_paths(meson.build_root(), 'gen.tab')]
44
45 custom_target('man pages',
46 command: [c2man, '-T', 'n', '-M', 'Programmer\'s Manual', c2man_incs,
47 '-D__FRIBIDI_DOC', '-DDONT_HAVE_FRIBIDI_CONFIG_H',
48 '-o@0@'.format(meson.current_build_dir()),
49 fribidi_headers],
50 depends: [fribidi_unicode_version_h],
51 output: gen_man_pages,
52 install_dir: join_paths(get_option('prefix'), get_option('mandir'), 'man3'),
53 install: true)
54 endif