doc: Do not build plugins to build the doc
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / docs / meson.build
1 build_hotdoc = false
2
3 if meson.is_cross_build()
4     if get_option('doc').enabled()
5         error('Documentation enabled but building the doc while cross building is not supported yet.')
6     endif
7
8     message('Documentation not built as building it while cross building is not supported yet.')
9     subdir_done()
10 endif
11
12 if static_build
13     if get_option('doc').enabled()
14         error('Documentation enabled but not supported when building statically.')
15     endif
16
17     message('Building statically, can\'t build the documentation')
18     subdir_done()
19 endif
20
21 if not build_gir
22     if get_option('doc').enabled()
23         error('Documentation enabled but introspection not built.')
24     endif
25
26     message('Introspection not built, won\'t build documentation requiring it')
27 endif
28
29 required_hotdoc_extensions = ['gi-extension', 'c-extension', 'gst-extension']
30 if gst_dep.type_name() == 'internal'
31     gst_proj = subproject('gstreamer')
32     plugins_cache_generator = gst_proj.get_variable('plugins_cache_generator')
33 else
34     plugins_cache_generator = find_program(join_paths(gst_dep.get_variable('libexecdir'), 'gstreamer-' + api_version, 'gst-plugins-doc-cache-generator'),
35         required: false)
36 endif
37
38 plugins_cache = join_paths(meson.current_source_dir(), 'plugins', 'gst_plugins_cache.json')
39
40 if plugins.length() == 0
41     message('All bad plugins have been disabled')
42 elif plugins_cache_generator.found()
43     gst_plugins_doc_dep = custom_target('bad-plugins-doc-cache',
44         command: [plugins_cache_generator, plugins_cache, '@OUTPUT@', '@INPUT@'],
45         input: plugins,
46         output: 'gst_plugins_cache.json',
47         build_always_stale: true,
48     )
49 else
50     warning('GStreamer plugin inspector for documentation not found, can\'t update the cache')
51 endif
52
53 hotdoc_p = find_program('hotdoc', required: get_option('doc'))
54 if not hotdoc_p.found()
55     message('Hotdoc not found, not building the documentation')
56     subdir_done()
57 endif
58
59 hotdoc_req = '>= 0.11.0'
60 hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
61 if not hotdoc_version.version_compare(hotdoc_req)
62     if get_option('doc').enabled()
63         error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
64     else
65         message('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
66         subdir_done()
67     endif
68 endif
69
70 hotdoc = import('hotdoc')
71 foreach extension: required_hotdoc_extensions
72     if not hotdoc.has_extensions(extension)
73         if get_option('doc').enabled()
74             error('Documentation enabled but @0@ missing'.format(extension))
75         endif
76
77         message('@0@ extensions not found, not building documentation requiring it'.format(extension))
78     endif
79 endforeach
80
81 build_hotdoc = true
82
83 docconf = configuration_data()
84 docconf.set('GST_API_VERSION', api_version)
85
86 configure_file(input : 'gst_api_version.in',
87                output : 'gst_api_version.md',
88                configuration : docconf)
89
90 root_rel = '..'
91 excludes = []
92 foreach f: [
93         'gst/frei0r/frei0r.h',
94         'gst/mxf/mxful.c',
95         'gst-libs/gst/*/*-private.h',
96         'gst-libs/gst/codecparsers/nalutils.h',
97         'ext/closedcaption/bcd.h',
98         'ext/closedcaption/bit_slicer.[ch]',
99         'ext/closedcaption/decoder.[ch]',
100         'ext/closedcaption/macros.h',
101         'ext/closedcaption/misc.h',
102         'ext/closedcaption/raw_decoder.[ch]',
103         'ext/closedcaption/sampling_par.[ch]',
104         'ext/closedcaption/sliced.[ch]',
105         'ext/lv2/gstlv2utils.h',
106         'ext/closedcaption/hamm.h',
107         'ext/closedcaption/io-sim.h',
108         'ext/avtp/gstavtpcrfbase.h',
109         'sys/nvcodec/nvEncodeAPI.h',
110         'sys/nvcodec/cuviddec.h',
111         'sys/nvcodec/nvcuvid.h',
112         'sys/winks/ksvideohelpers.h',
113         'gst/videoparsers/gstjpeg2000parse.h',
114         'gst-libs/gst/*/*-prelude.h',
115         'gst-libs/gst/vulkan/vulkan_fwd.h'
116     ]
117     excludes += [join_paths(meson.current_source_dir(), root_rel, f)]
118 endforeach
119
120 libs = []
121 if build_gir
122     libs = [
123         {'name': 'mpegts', 'gir': mpegts_gir, 'lib': gstmpegts_dep},
124         {'name': 'play', 'gir': play_gir, 'lib': gstplay_dep},
125         {'name': 'player', 'gir': player_gir, 'lib': gstplayer_dep},
126         {'name': 'insertbin', 'gir': insertbin_gir, 'lib': gstinsertbin_dep},
127         {'name': 'codecparsers', 'lib': gstcodecparsers_dep},
128         {'name': 'adaptivedemux', 'lib': gstadaptivedemux_dep},
129         {'name': 'basecamerabinsrc', 'gir': basecamerabin_gir, 'lib': gstbasecamerabin_dep},
130         {'name': 'webrtc', 'gir': webrtc_gir, 'lib': gstwebrtc_dep, 'suffix': 'lib'},
131         {'name': 'audio', 'gir': audio_gir, 'lib': gstbadaudio_dep, 'prefix': 'bad-'},
132         {'name': 'transcoder', 'gir': transcoder_gir, 'lib': gst_transcoder_dep},
133         {'name': 'codecs', 'gir': codecs_gir, 'lib': gstcodecs_dep},
134         {'name': 'cuda', 'gir': gst_cuda_gir, 'lib': gstcuda_dep},
135     ]
136
137     if gstopencv_dep.found()
138         libs += [
139             {'name': 'opencv', 'lib': gstopencv_dep, 'c_source_patterns': ['*.h', '*.cpp'], 'extra_c_flags': ['-x c++']},
140         ]
141     endif
142
143     if gstva_dep.found()
144         libs += [{'name': 'va', 'gir': va_gir, 'lib': gstva_dep, 'suffix': 'lib'}]
145     endif
146
147     if gstvulkan_dep.found()
148         libs += [
149              {'name': 'vulkan', 'gir': vulkan_gir, 'lib': gstvulkan_dep, 'suffix': 'lib'},
150         ]
151         if enabled_vulkan_winsys.contains('xcb')
152             libs += [
153                 {'name': 'vulkan-xcb', 'gir': vulkan_xcb_gir, 'lib': gstvulkanxcb_dep, 'extra_sources' : [
154                     join_paths(root_rel, 'gst-libs/gst/vulkan/xcb/gstvkdisplay_xcb.[ch]'),
155                 ]},
156             ]
157         endif
158         if enabled_vulkan_winsys.contains('wayland')
159             libs += [
160                 {'name': 'vulkan-wayland', 'gir': vulkan_wayland_gir, 'lib': gstvulkanwayland_dep, 'extra_sources' : [
161                     join_paths(root_rel, 'gst-libs/gst/vulkan/wayland/gstvkdisplay_wayland.[ch]'),
162                 ]},
163             ]
164         endif
165     endif
166 endif
167
168 has_gi_extension = hotdoc.has_extensions('gi-extension')
169 has_c_extension = hotdoc.has_extensions('c-extension')
170 libs_doc = []
171 foreach lib_def: libs
172   name = lib_def['name']
173   lib = lib_def['lib']
174   extra_sources = lib_def.get('extra_sources', [])
175
176   c_source_patterns = lib_def.get('c_source_patterns', ['*.[hc]'])
177   c_sources = []
178   foreach pattern: c_source_patterns
179     c_sources += join_paths(root_rel, 'gst-libs/gst', name, pattern)
180   endforeach
181   c_sources += extra_sources
182
183     if lib_def.has_key('gir')
184         if has_gi_extension
185             gir = lib_def['gir']
186             prefix = lib_def.get('prefix', '')
187             suffix = lib_def.get('suffix', '')
188             libs_doc += [hotdoc.generate_doc(prefix + name + suffix,
189                 project_version: api_version,
190                 gi_c_sources: c_sources,
191                 gi_sources: gir[0].full_path(),
192                 gi_c_source_filters: excludes,
193                 sitemap: join_paths('libs', name, 'sitemap.txt'),
194                 index: join_paths('libs/', name, 'index.md'),
195                 gi_index: join_paths('libs/', name, 'index.md'),
196                 gi_smart_index: true,
197                 gi_order_generated_subpages: true,
198                 dependencies: [lib, gir],
199                 c_flags: '-DGST_USE_UNSTABLE_API',
200                 install: false,
201             )]
202         endif
203     else
204         if has_c_extension
205             libs_doc += [hotdoc.generate_doc('gst-plugins-bad-' + name,
206                 sitemap: join_paths('libs', name, 'sitemap.txt'),
207                 index: join_paths('libs', name, 'index.md'),
208                 project_version: api_version,
209                 c_sources: c_sources,
210                 c_source_filters: excludes,
211                 c_index: join_paths('libs', name, 'index.md'),
212                 c_smart_index: true,
213                 c_order_generated_subpages: true,
214                 extra_c_flags: ['-DGST_USE_UNSTABLE_API'] + lib_def.get('extra_c_flags', []),
215                 dependencies: lib,
216                 install: false,
217             )]
218         endif
219     endif
220 endforeach
221
222 list_plugin_res = run_command(python3, '-c',
223 '''
224 import sys
225 import json
226
227 with open("@0@") as f:
228     print(':'.join(json.load(f).keys()), end='')
229 '''.format(plugins_cache),
230   check: true)
231
232 plugins_doc = []
233 foreach plugin_name: list_plugin_res.stdout().split(':')
234     plugins_doc += [hotdoc.generate_doc(plugin_name,
235         project_version: api_version,
236         sitemap: 'plugins/sitemap.txt',
237         index: 'plugins/index.md',
238         c_flags: '-DGST_USE_UNSTABLE_API',
239         gst_index: 'plugins/index.md',
240         gst_smart_index: true,
241         gst_c_sources: [
242             join_paths(root_rel, 'sys/*/*.[cmh]'),
243             join_paths(root_rel, 'sys/*/*.cpp'),
244             join_paths(root_rel, 'sys/*/*.cc'),
245             join_paths(root_rel, 'sys/*/*.mm'),
246             join_paths(root_rel, 'sys/*/*.hh'),
247             join_paths(root_rel, 'ext/*/*.[ch]'),
248             join_paths(root_rel, 'ext/*/*.cpp'),
249             join_paths(root_rel, 'ext/*/*.cc'),
250             join_paths(root_rel, 'ext/*/*.hh'),
251             join_paths(root_rel, 'gst/*/*.[ch]'),
252             join_paths(root_rel, 'gst/rtmp2/*/*.[ch]'),
253         ],
254         dependencies: [gst_dep],
255         install: false,
256         disable_incremental_build: true,
257         gst_cache_file: plugins_cache,
258         gst_c_source_filters: excludes,
259         gst_order_generated_subpages: true,
260         gst_plugin_name: plugin_name,
261         include_paths: join_paths(meson.current_source_dir(), '..'),
262     )]
263 endforeach