-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
132 lines (102 loc) · 3.9 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#! /usr/bin/env python
# encoding: utf-8
import os
import shutil
from waflib.Build import BuildContext
APPNAME = "abacus"
VERSION = "6.0.1"
def configure(conf):
conf.set_cxx_std(14)
def build(bld):
# Build static library if this is top-level, otherwise just .o files
features = ["cxx"]
if bld.is_toplevel():
features += ["cxxstlib"]
# Fix MSVC error C2131 about expression not being constexpr
cxxflags = []
compiler_binary = bld.env.get_flat("CXX").lower()
if "cl.exe" in compiler_binary:
cxxflags += ["/constexpr:steps10000000"]
bld(
features=features,
source=bld.path.ant_glob("src/**/*.cpp") + bld.path.ant_glob("src/**/*.cc"),
target="abacus",
use=["protobuf", "endian_includes", "bourne"],
install_path="${PREFIX}/lib",
cxxflags=cxxflags,
includes=["src"],
export_includes=["src"],
)
if bld.is_toplevel():
# Only build tests when executed from the top-level wscript,
# i.e. not when included as a dependency
bld.program(
features="cxx test",
source=bld.path.ant_glob("test/**/*.cpp") + bld.path.ant_glob("src/**/*.cc"),
target="abacus_tests",
use=["abacus", "protobuf", "gtest"],
)
bld.program(
features="cxx",
source="examples/metrics_simple.cpp",
target="metrics_simple",
install_path=None,
use=["abacus"],
)
sourcepath = bld.path.find_node("src")
bld.install_files(
dest="${PREFIX}/include",
files=sourcepath.ant_glob("**/*.hpp"),
cwd=sourcepath,
relative_trick=True,
)
bld.install_files(dest="${PREFIX}/", files=bld.path.ant_glob("NEWS.rst"))
def protogen(ctx):
# check if protec is available
protoc_location = "build_current/resolve_symlinks/protobuf/protoc"
if not os.path.isfile(protoc_location):
ctx.fatal("protoc not found. Make sure to configure waf with `--with_protoc` to include protoc in build.")
return
try:
shutil.rmtree("src/abacus/protobuf")
except:
pass
os.mkdir("src/abacus/protobuf")
ctx.exec_command(
f"(./{protoc_location} --cpp_out ./src --proto_path .. ../abacus/protobuf/*.proto)"
)
ctx.exec_command(
"echo 'DisableFormat: true\nSortIncludes: false' > src/abacus/protobuf/.clang-format"
)
class ReleaseContext(BuildContext):
cmd = "prepare_release"
fun = "prepare_release"
def prepare_release(ctx):
"""Prepare a release."""
# Rewrite versions
with ctx.rewrite_file(filename="src/abacus/version.hpp") as f:
pattern = r"#define STEINWURF_ABACUS_VERSION v\d+_\d+_\d+"
replacement = "#define STEINWURF_ABACUS_VERSION v{}".format(
VERSION.replace(".", "_")
)
f.regex_replace(pattern=pattern, replacement=replacement)
with ctx.rewrite_file(filename="src/abacus/version.cpp") as f:
pattern = r'return "\d+\.\d+\.\d+"'
replacement = 'return "{}"'.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()
)