2 """Create/Update man page(s) from ReST source file(s) to be included in source distribution."""
7 from os
import chdir
, environ
, getcwd
8 from os
.path
import join
10 from subprocess
import run
12 build_root
= environ
.get("MESON_BUILD_ROOT")
13 dist_root
= environ
.get("MESON_DIST_ROOT")
14 source_root
= environ
.get("MESON_SOURCE_ROOT")
16 ap
= argparse
.ArgumentParser()
17 ap
.add_argument("-v", "--verbose", action
="store_true", help="Be more verbose.")
18 ap
.add_argument("man_page", nargs
="*", help="Man page(s) to create.")
19 args
= ap
.parse_args()
22 print("cwd:", getcwd())
23 print("build root:", build_root
)
24 print("dist root:", dist_root
)
25 print("source root:", source_root
)
26 print("sys.argv:", sys
.argv
)
28 for man
in args
.man_page
:
29 target
= join("docs", man
)
30 dst
= join(dist_root
, "docs", man
)
32 print("Creating man page '{}'".format(target
))
43 if proc
.returncode
!= 0:
44 sys
.exit("'ninja' returned non-zero ({}) for target '{}'.".format(proc
.returncode
, target
))
46 shutil
.copy(target
, dst
)