File: SConscript

package info (click to toggle)
rmlint 2.10.2-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,180 kB
  • sloc: ansic: 15,671; python: 9,312; sh: 474; xml: 111; makefile: 72
file content (87 lines) | stat: -rw-r--r-- 2,074 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# encoding: utf-8

Import('env')
Import('VERSION_MAJOR')
Import('VERSION_MINOR')
Import('VERSION_PATCH')
Import('create_uninstall_target')
Import('find_sphinx_binary')


import os
import time
import subprocess

from functools import partial


def run_sphinx_binary(builder, **kwargs):
    sphinx_binary = find_sphinx_binary()
    if sphinx_binary is None:
        return

    build_dir = os.path.join('docs/_build', builder)
    try:
        os.makedirs(build_dir)
    except OSError:
        pass

    subprocess.check_call(
        [sphinx_binary, '-Q', '-b', builder, 'docs', build_dir]
    )


def gzip_file(target, source, env):
    source, dest = source[0].get_abspath(), target[0].get_abspath()
    try:
        subprocess.check_call('gzip -c {s} > {t}'.format(
            s=source, t=dest
        ), shell=True)
    except Exception as err:
        print('Warning: could not gzip {s} to {t}: {e}'.format(
            s=source, t=dest, e=err
        ))

# Do not use partial(), but a real function.
# Scons uses this to check if the previous action
# differs from the current action.
# Partial actions are always different.
def run_sphinx_binary_man(**kwargs):
    run_sphinx_binary('man', **kwargs)


sphinx = env.Command(
    '_build/man/rmlint.1', 'rmlint.1.rst',
    env.Action(run_sphinx_binary_man, "Building manpage from rst...")
)

manpage = env.Command(
    'rmlint.1.gz', '_build/man/rmlint.1', gzip_file
)

env.Default(sphinx)
env.Default(manpage)

env.Alias('man', env.Depends(manpage, sphinx))


if 'install' in COMMAND_LINE_TARGETS:
    man_install = env.InstallPerm(
        '$PREFIX/share/man/man1',
        [manpage],
        int("644", 8),
    )
    target = env.Alias('install', [manpage, man_install])


if 'uninstall' in COMMAND_LINE_TARGETS:
    create_uninstall_target(env, '$PREFIX/share/man/man1/rmlint.1.gz')

if 'docs' in COMMAND_LINE_TARGETS:
    env.Alias('docs',
        env.Command(
            'make_docs', None,
            Action(partial(run_sphinx_binary, 'html'), "Building online docs...")
        ),
    )