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