generated from steinwurf/template-bsd-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
113 lines (79 loc) · 3.13 KB
/
wscript
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#! /usr/bin/env python
# encoding: utf-8
APPNAME = "ranbo"
VERSION = "2.0.0"
import os
import sys
from waflib.Build import BuildContext
def options(opt):
if opt.is_toplevel():
opts = opt.add_option_group("Kernel options")
opts.add_option(
"--kernel_example",
action="store_true",
default=False,
help="Enable kernel example build",
)
opts.add_option(
"--kernel_path",
default=None,
dest="kernel_path",
help="Set the path to the Linux kernel sources",
)
def configure(conf):
conf.set_cxx_std(11)
def build(bld):
bld(includes="src", export_includes="src", name="ranbo_includes")
if bld.is_toplevel():
# Only build tests when executed from the top-level wscript,
# i.e. not when included as a dependency
bld.recurse("test")
bld.recurse("examples")
bld.recurse("benchmark")
if bld.get_tool_option("kernel_example"):
bld.recurse("examples/kernel")
class ReleaseContext(BuildContext):
cmd = "prepare_release"
fun = "prepare_release"
def prepare_release(ctx):
"""Prepare a release."""
# Rewrite versions
with ctx.rewrite_file(filename="src/ranbo/ranbo.h") as f:
pattern = r'#define STEINWURF_RANBO_VERSION "\d+\.\d+\.\d+"'
replacement = '#define STEINWURF_RANBO_VERSION "{}"'.format(VERSION)
f.regex_replace(pattern=pattern, replacement=replacement)
# Rewrite versions
with ctx.rewrite_file(filename="library.json") as f:
pattern = r'"version": "\d+\.\d+\.\d+",'
replacement = '"version": "{}",'.format(VERSION)
f.regex_replace(pattern=pattern, replacement=replacement)
def docs(ctx):
"""Build the documentation in a virtualenv"""
with ctx.create_virtualenv() as venv:
# To update the requirements.txt just delete it - a fresh one
# will be generated from test/requirements.in
if not os.path.isfile("docs/requirements.txt"):
venv.run("python -m pip install pip-tools")
venv.run("pip-compile docs/requirements.in")
venv.run("python -m pip install -r docs/requirements.txt")
build_path = os.path.join(ctx.path.abspath(), "build", "site", "docs")
venv.run(
"giit clean . --build_path {}".format(build_path), cwd=ctx.path.abspath()
)
venv.run(
"giit sphinx . --build_path {}".format(build_path), cwd=ctx.path.abspath()
)
def run_benchmarks(ctx):
venv = ctx.create_virtualenv(name="virtualenv-plots", overwrite=False)
# seeding benchmark
venv.run(
"build_current/benchmark/seeding --benchmark_out='benchmark_results/seeding.json' --benchmark_counters_tabular=true"
)
# generation benchmark
venv.run(
"build_current/benchmark/generation --benchmark_out='benchmark_results/generation.json' --benchmark_counters_tabular=true"
)
# seed and generate benchmark
venv.run(
"build_current/benchmark/generate_and_seed --benchmark_out='benchmark_results/generate_and_seed.json' --benchmark_counters_tabular=true"
)