History

meson: dynamically compute dependencies for manpage and html build

This allows us to rebuild the manpages and html documentation only when necessary. It is not necessary to manually keep the list of dependencies up to date. Unfortunately rst2pdf does not yet support this feature, see https://github.com/rst2pdf/rst2pdf/issues/1108

Thomas Weißschuh committed 3 years ago

Commit 8a0fa621 parent c8a90002 files · +68 −2Browse files

Showing the changes to TOOLS/docutils-wrapper.py (1 of 2 files). Show all

Unified · Split

TOOLS/docutils-wrapper.py+56−0
@@ -0,0 +1,56 @@
1#!/usr/bin/env python3
2"""
3Wrapper around docutils rst2x commands,
4converting their dependency files to a format understood by meson/ninja.
5"""
6
7#
8# This file is part of mpv.
9#
10# mpv is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14#
15# mpv is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU Lesser General Public License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public
21# License along with mpv. If not, see <http://www.gnu.org/licenses/>.
22#
23
24import os
25import subprocess
26import sys
27
28
29def convert_depfile(output, depfile):
30 with open(depfile, 'r') as f:
31 deps = f.readlines()
32
33 with open(depfile, 'w') as f:
34 f.write(os.path.abspath(output))
35 f.write(': \\\n')
36 for dep in deps:
37 dep = dep[:-1]
38 f.write('\t')
39 f.write(os.path.abspath(dep))
40 f.write(' \\\n')
41
42argv = sys.argv[1:]
43
44depfile = None
45output = argv[-1]
46
47for opt, optarg in zip(argv, argv[1:]):
48 if opt == '--record-dependencies':
49 depfile = optarg
50
51try:
52 subprocess.run(argv)
53 convert_depfile(output, depfile)
54except:
55 os.remove(output)
56 os.remove(depfile)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t