-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
153 lines (120 loc) · 4.43 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE, PIPE, check_call
from os import path
import os
import webbrowser
from itertools import chain
import sys
import ws.test
WAF_TOOLS = ["compiler_cxx", "boost"]
def options(ctx):
ctx.load(" ".join(WAF_TOOLS))
ctx.add_option(
'--with-llvm-config',
action='store',
default='llvm-config'
)
ctx.add_option(
'--release',
action='store_true',
default=False
)
def configure(ctx):
ctx.load(" ".join(WAF_TOOLS))
ctx.check(lib='pthread', mandatory=True, uselib_store='PTHREAD')
ctx.check(lib='dl', mandatory=True, uselib_store='DL')
ctx.check(lib='tinfo', mandatory=True, uselib_store='TINFO')
ctx.check(lib='z', mandatory=True, uselib_store='Z')
ctx.check(lib='gmp', mandatory=True, uselib_store='GMP')
ctx.check(lib='ffi', mandatory=True, uselib_store='FFI')
ctx.check_boost(lib="system program_options filesystem")
ctx.check_cfg(
path=ctx.options.with_llvm_config, package='',
args='--ldflags --cflags --libs all',
uselib_store='LLVM'
)
if ctx.env["CXX_NAME"] in ("gcc", "clang"):
ctx.env.append_unique("CXXFLAGS", "-std=gnu++1y")
if ctx.options.release:
ctx.env.append_unique("CXXFLAGS", "-Ofast")
else:
ctx.env.append_unique("CXXFLAGS", "-g")
ctx.env.append_unique("CXXFLAGS", "-O0")
ctx.env.append_unique("CXXFLAGS", "--coverage")
ctx.env.append_unique("LINKFLAGS", "--coverage")
ctx.env.append_unique("CXXFLAGS", "-Wall")
ctx.env.append_unique("CXXFLAGS", "-Wextra")
ctx.env.append_unique("CXXFLAGS", "-Wfatal-errors")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-final-types")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-final-methods")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-override")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-attribute=pure")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-attribute=const")
# ctx.env.append_unique("CXXFLAGS", "-Wsuggest-attribute=noreturn")
# ctx.env.append_unique("CXXFLAGS", "-Weffc++")
# ctx.env.append_unique("CXXFLAGS", "-Wpedantic")
ctx.env.append_unique("CXXFLAGS", "-Woverloaded-virtual")
ctx.env.append_unique("CXXFLAGS", "-Wno-unused-value")
ctx.env.append_unique("CXXFLAGS", "-Wno-unused-parameter")
ctx.env.append_unique("CXXFLAGS", "-rdynamic")
ctx.env.append_unique("LINKFLAGS", "-rdynamic")
def build(ctx):
start_dir = ctx.path.find_dir("lib")
ctx.install_files(
"${PREFIX}/lib/arrow", start_dir.ant_glob('**/*.as'),
cwd=start_dir,
relative_trick=True)
ctx.program(source=ctx.path.ant_glob("src/**/*.cpp"),
includes=[
"include",
"vendor",
],
target="arrow",
use=["BOOST", "LLVM", "PTHREAD", "DL", "TINFO", "Z", "GMP",
"FFI"])
def test(ctx):
result = ws.test.run(ctx)
if not result:
sys.exit(1)
def generate(ctx):
ws.test.generate(ctx)
def coverage(ctx):
with open(os.devnull) as nil:
# Generate *.gcov files
object_files = ctx.path.ant_glob("build/**/*.o")
for object_file in object_files:
check_call([
"gcov", "-r", "-b", "-c", object_file.abspath()
], cwd="./build", stdout=nil, stderr=nil)
# Process *.gcov files and create a coverage.info file
check_call([
"lcov",
"--capture",
"--directory", "./build",
"--output-file", "coverage.info"
], stdout=nil, stderr=nil)
# Remove external files
check_call([
"lcov",
"--remove", "coverage.info",
"/usr/*",
"--output-file", "coverage.info"
], stdout=nil, stderr=nil)
check_call([
"lcov",
"--remove", "coverage.info",
"vendor/*",
"--output-file", "coverage.info"
], stdout=nil, stderr=nil)
# Generate coverage report
check_call([
"genhtml",
"coverage.info",
"--output-directory", "coverage"
], stdout=nil, stderr=nil)
# Print the coverage report
check_call([
"lcov",
"--summary", "coverage.info",
])