This repository has been archived by the owner on Jul 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
63 lines (50 loc) · 1.58 KB
/
tasks.py
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
import itertools
import os
import sys
from invoke import Collection, task
import procdraw_utils as utils
import website
_project_dir = os.path.abspath(os.path.dirname(__file__))
@task
def check_file_headers(_):
"""
Check the C++ source file headers
"""
src_dir = os.path.relpath(os.path.join(_project_dir, "src"))
files = utils.find_cpp_files([src_dir])
reporter = utils.CheckResultTapReporter(31)
checker = utils.Apache2HeaderChecker()
for file in files:
reporter.add(checker.check(file, "//"))
reporter.print_summary()
if reporter.is_fail():
sys.exit(1)
@task
def format_cpp(c):
"""
Format the C++ source files with clang-format
"""
clang_format = c.config["procdraw"]["clang_format_name"]
src_dir = os.path.relpath(os.path.join(_project_dir, "src"))
files = utils.find_cpp_files([src_dir])
utils.run(itertools.chain([clang_format, "-i", "-style=file"], files))
@task
def validate_xml(_):
"""
Validate the docs XML
"""
reporter = utils.CheckResultTapReporter(1)
reporter.add(
utils.validate_xml(os.path.join(_project_dir, "docs", "docs.rng"),
os.path.join(_project_dir, "docs", "docs.xml")))
reporter.print_summary()
if reporter.is_fail():
sys.exit(1)
ns = Collection(check_file_headers, format_cpp, validate_xml, website)
ns.configure({
"procdraw": {
"clang_format_name": "clang-format",
"web_server_address": "127.0.0.1",
"web_server_port": 8000
}
})