meson: Generate ChangeLog files for release tarballs on dist
[platform/upstream/gstreamer.git] / subprojects / gst-docs / meson.build
1 project('GStreamer manuals and tutorials', 'c',
2   version: '1.21.2.1',
3   meson_version : '>= 0.62')
4
5 hotdoc_p = find_program('hotdoc')
6 if not hotdoc_p.found()
7     message('Hotdoc not found, not building the documentation')
8     subdir_done()
9 endif
10
11 hotdoc_req = '>= 0.12.2'
12 hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
13 if not hotdoc_version.version_compare(hotdoc_req)
14     error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
15 endif
16
17 hotdoc = import('hotdoc')
18 hotdoc_subprojects = []
19
20 apiversion = '1.0'
21 if host_machine.system() == 'windows'
22   pathsep = ';'
23 else
24   pathsep = ':'
25 endif
26
27 python3 = import('python').find_installation()
28
29 built_subprojects = get_option('built_subprojects')
30 if built_subprojects != ''
31   message('Have subprojects list from options')
32 else
33   read_file_contents = '''
34 import os
35 import sys
36
37 assert len(sys.argv) >= 2
38 fname = sys.argv[1]
39
40 with open(fname, 'r') as f:
41     for l in f:
42         print(l)
43 '''
44
45   # gst-build will generate this file for us to consume so that subproject
46   # changes can still work
47   fname = join_paths(meson.project_build_root(), '..', '..', 'GstDocumentedSubprojects')
48   cmdres = run_command(
49       python3,
50       '-c', read_file_contents,
51       fname,
52       check: false,
53     )
54   if cmdres.returncode() == 0
55     built_subprojects = cmdres.stdout().strip()
56     message('Have subprojects from file: @0@'.format(fname))
57   endif
58 endif
59
60 libs = ''
61 plugins_doc = ''
62 deps = []
63 plugins_sitemap = ''
64 if built_subprojects != ''
65     foreach project_name: built_subprojects.split(',')
66         sub = subproject(project_name)
67         if sub.get_variable('build_hotdoc')
68             message('Building @0@ documentation'.format(project_name))
69
70             foreach lib: sub.get_variable('libs_doc', [])
71               hotdoc_subprojects += [lib]
72               libs += lib.full_path() + pathsep
73               deps += [lib]
74             endforeach
75
76             foreach plugin_doc: sub.get_variable('plugins_doc', [])
77               plugins_doc += plugin_doc.full_path() + pathsep
78               hotdoc_subprojects += [plugin_doc]
79               deps += [plugin_doc]
80             endforeach
81         else
82             message('@0@ did not build hotdoc documentation, can\'t build API doc'.format(project_name))
83         endif
84     endforeach
85 endif
86 deps += [dependency('gstreamer-' + apiversion, fallback: ['gstreamer', 'gst_dep'])]
87
88 if get_option('use_portal_index')
89   index = 'markdown/index.md'
90 else
91   index = 'markdown/simple-index.md'
92 endif
93 sitemap_gen = find_program('scripts/generate_sitemap.py')
94 sitemap = configure_file(command: [sitemap_gen, '@INPUT@', '@OUTPUT@',
95   'gi-index', libs, plugins_doc],
96   input: 'sitemap.txt',
97   output: 'sitemap.txt')
98
99 html_theme = 'https://github.com/hotdoc/hotdoc_lumen_theme/releases/download/0.13.2/hotdoc_lumen_theme-0.13.2.tar.xz?sha256=5721189b7e985f27381ee20137f4a9003049a70a75ab1221a69fd04d27e752bc'
100
101 gstreamer_doc = hotdoc.generate_doc('GStreamer',
102     project_version: apiversion,
103     sitemap: sitemap,
104     index: index,
105     gi_index: index,
106     install: true,
107     extra_assets: [join_paths(meson.current_source_dir(), 'images')],
108     syntax_highlighting_activate: true,
109     html_theme: html_theme,
110     include_paths: [
111       meson.current_source_dir() / 'examples',
112       meson.current_source_dir() / 'markdown' / 'tutorials' / 'basic',
113       meson.current_source_dir() / 'markdown' / 'templates',
114       meson.current_source_dir() / 'markdown' / 'tutorials' / 'playback',
115     ],
116     html_extra_theme: join_paths(meson.current_source_dir(), 'theme/extra'),
117     dependencies: deps,
118     subprojects: hotdoc_subprojects,
119     disable_incremental_build: true,
120     gst_list_plugins_page: 'gst-index',
121     gst_index: join_paths(meson.current_source_dir(), 'markdown/plugins_doc.md'),
122     devhelp_activate: true,
123     devhelp_online: 'https://gstreamer.freedesktop.org/documentation/',
124     build_always_stale: true,
125     edit_on_github_repository: 'https://gitlab.freedesktop.org/gstreamer/gst-docs/',
126     previous_symbol_index: join_paths(meson.current_source_dir(), 'symbols', 'symbol_index.json'),
127     fatal_warnings: get_option('fatal_warnings')
128 )
129
130 # For devhelp
131 meson.add_devenv({'XDG_DATA_DIRS': meson.current_build_dir() / 'GStreamer-doc'},
132   method: 'prepend')
133
134 cdata = configuration_data()
135 cdata.set('GST_API_VERSION', apiversion)
136 readme = configure_file(input: 'scripts/RELEASE_README.md',
137                output: 'README.md',
138                configuration : cdata)
139
140 run_target('release',
141   command: [find_program('scripts/release.py'),
142             gstreamer_doc.full_path(),
143             meson.project_version(),
144             meson.current_build_dir()],
145   depends: [gstreamer_doc]
146 )
147
148 meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())