-
Notifications
You must be signed in to change notification settings - Fork 59
/
wscript
144 lines (108 loc) · 3.33 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
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------
# Copyright © 2010, RedJack, LLC.
# All rights reserved.
#
# Please see the LICENSE.txt file in this distribution for license
# details.
# ----------------------------------------------------------------------
from version import *
#--------------------------
# Edit the variables below
APPNAME = "ipset"
VERSION = get_git_version("RELEASE-VERSION")
SUBDIRS = [
"include",
"src",
]
# The tests subdirectory is only included if the user runs "waf test"
# or "waf build_tests".
# Everything below this is boilerplate
#--------------------------------------
def set_options(opt):
map(opt.recurse, SUBDIRS)
opt.add_option(
"--build-kind",
action="store",
default="debug,release",
help="which variants to build"
)
opt.add_option(
"--disable-strict-aliasing",
action="store_false",
default=True,
dest="strict_aliasing",
help="turn off strict aliasing"
)
def configure(conf):
conf.env.DEBUG_CFLAGS = [
"-Wall",
"-Werror",
"-O2",
"-g",
]
conf.env.RELEASE_CFLAGS = [
"-Wall",
"-Werror",
"-O3",
]
import Options
if not Options.options.strict_aliasing:
conf.env.DEBUG_CFLAGS.append("-fno-strict-aliasing")
conf.env.RELEASE_CFLAGS.append("-fno-strict-aliasing")
conf.env.DEBUG_DEFINES = []
conf.env.RELEASE_DEFINES = []
conf.env.APPNAME = APPNAME
conf.env.VERSION = VERSION
add_test_dirs(conf)
map(conf.recurse, SUBDIRS)
# Create debug and release builds
dbg = conf.env.copy()
rel = conf.env.copy()
dbg.set_variant("debug")
conf.set_env_name("debug", dbg)
conf.setenv("debug")
conf.env.CCFLAGS = conf.env.DEBUG_CFLAGS
conf.env.CCDEFINES = conf.env.DEBUG_DEFINES
conf.env.CXXFLAGS = conf.env.DEBUG_CFLAGS
conf.env.CXXDEFINES = conf.env.DEBUG_DEFINES
rel.set_variant("release")
conf.set_env_name("release", rel)
conf.setenv("release")
conf.env.CCFLAGS = conf.env.RELEASE_CFLAGS
conf.env.CCDEFINES = conf.env.RELEASE_DEFINES
conf.env.CXXFLAGS = conf.env.RELEASE_CFLAGS
conf.env.CXXDEFINES = conf.env.RELEASE_DEFINES
def build(bld):
map(bld.recurse, SUBDIRS)
for obj in bld.all_task_gen[:]:
debug_obj = obj.clone("debug")
release_obj = obj.clone("release")
obj.posted = True
if hasattr(obj, "unit_test"):
obj.unit_test = False
# Disable each variant if it's not included in the
# --build-kind command-line option.
import Options
kinds = Options.options.build_kind.split(",")
if "debug" not in kinds:
debug_obj.posted = True
if "release" not in kinds:
release_obj.posted = True
def test(tst):
import Scripting
Scripting.commands.insert(0, "run_tests")
Scripting.commands.insert(0, "build")
Scripting.commands.insert(0, "add_test_dirs")
def add_test_dirs(tst):
SUBDIRS.append("tests")
def run_tests(tst):
import unittestw
ut = unittestw.unit_test()
ut.run_if_waf_does = "test"
ut.run()
ut.print_results()
def build_tests(tst):
import Scripting
Scripting.commands.insert(0, "build")
Scripting.commands.insert(0, "add_test_dirs")