xref: /dpdk/doc/api/meson.build (revision f8dbaebbf1c9efcbb2e2354b341ed62175466a57)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2018 Luca Boccassi <bluca@debian.org>
3
4doxygen = find_program('doxygen', required: get_option('enable_docs'))
5
6if not doxygen.found()
7  subdir_done()
8endif
9
10# due to the CSS customisation script, which needs to run on a file that
11# is in a subdirectory that is created at build time and thus it cannot
12# be an individual custom_target, we need to wrap the doxygen call in a
13# script to run the CSS modification afterwards
14generate_doxygen = find_program('generate_doxygen.sh')
15generate_examples = find_program('generate_examples.sh')
16generate_css = find_program('doxy-html-custom.sh')
17
18htmldir = join_paths(get_option('datadir'), 'doc', 'dpdk')
19
20# due to the following bug: https://github.com/mesonbuild/meson/issues/4107
21# if install is set to true it will override build_by_default and it will
22# cause the target to always be built. If install were to be always set to
23# false it would be impossible to install the docs.
24# So use a configure option for now.
25example = custom_target('examples.dox',
26        output: 'examples.dox',
27        command: [generate_examples, join_paths(meson.source_root(), 'examples'), '@OUTPUT@'],
28        depfile: 'examples.dox.d',
29        install: get_option('enable_docs'),
30        install_dir: htmldir,
31        build_by_default: get_option('enable_docs'))
32
33cdata = configuration_data()
34cdata.set('VERSION', meson.project_version())
35cdata.set('API_EXAMPLES', join_paths(meson.build_root(), 'doc', 'api', 'examples.dox'))
36cdata.set('OUTPUT', join_paths(meson.build_root(), 'doc', 'api'))
37cdata.set('HTML_OUTPUT', 'html')
38cdata.set('TOPDIR', meson.source_root())
39cdata.set('STRIP_FROM_PATH', ' '.join([meson.source_root(), join_paths(meson.build_root(), 'doc', 'api')]))
40cdata.set('WARN_AS_ERROR', 'NO')
41if get_option('werror')
42    cdata.set('WARN_AS_ERROR', 'YES')
43endif
44
45doxy_conf = configure_file(input: 'doxy-api.conf.in',
46        output: 'doxy-api.conf',
47        configuration: cdata)
48
49doxy_build = custom_target('doxygen',
50        depends: example,
51        depend_files: 'doxy-api-index.md',
52        input: doxy_conf,
53        output: 'html',
54        depfile: 'html.d',
55        command: [generate_doxygen, '@INPUT@', '@OUTPUT@', generate_css],
56        install: get_option('enable_docs'),
57        install_dir: htmldir,
58        build_by_default: get_option('enable_docs'))
59
60doc_targets += doxy_build
61doc_target_names += 'Doxygen_API'
62