doc: Do not build plugins to build the doc
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-good / docs / meson.build
1 build_hotdoc = false
2
3 if static_build
4     if get_option('doc').enabled()
5         error('Documentation enabled but not supported when building statically.')
6     endif
7
8     message('Building statically, can\'t build the documentation')
9     subdir_done()
10 endif
11
12 if meson.is_cross_build()
13     if get_option('doc').enabled()
14         error('Documentation enabled but building the doc while cross building is not supported yet.')
15     endif
16
17     message('Documentation not built as building it while cross building is not supported yet.')
18     subdir_done()
19 endif
20
21 required_hotdoc_extensions = ['gst-extension']
22 if gst_dep.type_name() == 'internal'
23     gst_proj = subproject('gstreamer')
24     plugins_cache_generator = gst_proj.get_variable('plugins_cache_generator')
25 else
26     plugins_cache_generator = find_program(join_paths(gst_dep.get_variable('libexecdir'), 'gstreamer-' + api_version, 'gst-plugins-doc-cache-generator'),
27         required: false)
28 endif
29
30 plugins_cache = join_paths(meson.current_source_dir(), 'gst_plugins_cache.json')
31 if plugins.length() == 0
32     message('All good plugins have been disabled')
33 elif plugins_cache_generator.found()
34     gst_plugins_doc_dep = custom_target('good-plugins-doc-cache',
35         command: [plugins_cache_generator, plugins_cache, '@OUTPUT@', '@INPUT@'],
36         input: plugins,
37         output: 'gst_plugins_cache.json',
38         build_always_stale: true,
39     )
40 else
41     warning('GStreamer plugin inspector for documentation not found, can\'t update the cache')
42 endif
43
44 hotdoc_p = find_program('hotdoc', required: get_option('doc'))
45 if not hotdoc_p.found()
46     message('Hotdoc not found, not building the documentation')
47     subdir_done()
48 endif
49
50 hotdoc_req = '>= 0.11.0'
51 hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
52 if not hotdoc_version.version_compare(hotdoc_req)
53     if get_option('doc').enabled()
54         error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
55     else
56         message('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
57         subdir_done()
58     endif
59 endif
60
61 hotdoc = import('hotdoc')
62 foreach extension: required_hotdoc_extensions
63     if not hotdoc.has_extensions(extension)
64         if get_option('doc').enabled()
65             error('Documentation enabled but @0@ missing'.format(extension))
66         endif
67
68         message('@0@ extension not found, not building documentation'.format(extension))
69         subdir_done()
70     endif
71 endforeach
72
73 docconf = configuration_data()
74 docconf.set('GST_API_VERSION', api_version)
75 configure_file(input : 'gst_api_version.in',
76                output : 'gst_api_version.md',
77                configuration : docconf)
78 libs_doc = []
79 plugins_doc = []
80 excludes = []
81 build_hotdoc = true
82 foreach f: ['gstgdkpixbufplugin.c']
83     excludes += [join_paths(meson.current_source_dir(), '..', 'ext/gdk_pixbuf/', f)]
84 endforeach
85
86 excludes += [join_paths(meson.current_source_dir(), '..', 'sys', 'rpicamsrc', 'Raspi*.[ch]')]
87
88 list_plugin_res = run_command(python3, '-c',
89 '''
90 import sys
91 import json
92
93 with open("@0@") as f:
94     print(':'.join(json.load(f).keys()), end='')
95 '''.format(plugins_cache),
96   check: true)
97 foreach plugin_name: list_plugin_res.stdout().split(':')
98     plugins_doc += [hotdoc.generate_doc(plugin_name,
99     project_version: api_version,
100       sitemap: 'sitemap.txt',
101       index: 'index.md',
102       gst_index: 'index.md',
103       gst_smart_index: true,
104       gst_c_sources: [
105         '../sys/*/*.[cmh]',
106         '../ext/*/*.[ch]',
107         '../ext/*/*/*.[ch]',
108         '../gst/*/*.[ch]',
109       ],
110       gst_c_source_filters: excludes,
111       dependencies: [gst_dep],
112       gst_order_generated_subpages: true,
113       install: false,
114       disable_incremental_build: true,
115       gst_cache_file: plugins_cache,
116       gst_plugin_name: plugin_name,
117       include_paths: join_paths(meson.current_source_dir(), '..'),
118       )]
119 endforeach