This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathSConstruct
95 lines (82 loc) · 2.84 KB
/
SConstruct
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import sys
import SCons
opts = Variables()
opts.AddVariables(
BoolVariable("DEBUG", "Make debug build", 0),
BoolVariable("SANITIZE", "Use AddressSanitizer and UBSanitizer", 0),
BoolVariable("FUZZING", "Build with libFuzzer instrumentation and targets", 0),
BoolVariable("VERBOSE", "Show full build information", 0),
)
env = Environment(options=opts, ENV=os.environ)
env.Tool("clang")
# Add extra compiler flags from the environment
for flag in ["CCFLAGS", "CFLAGS", "CPPFLAGS", "CXXFLAGS", "LINKFLAGS"]:
if flag in os.environ:
env.Append(**{flag: SCons.Util.CLVar(os.getenv(flag))})
if env["DEBUG"]:
print("DEBUG MODE!")
env.Append(CCFLAGS=["-g", "-DDEBUG"])
if env["SANITIZE"]:
sanitizers = [
"-fsanitize=address,undefined",
"-fno-sanitize-recover=undefined,integer,nullability",
]
if not env["DEBUG"]:
sanitizers += ["-gline-tables-only"]
env.Append(CCFLAGS=sanitizers, LINKFLAGS=sanitizers)
if env["FUZZING"]:
fuzzing = ["-fsanitize=fuzzer-no-link"]
if not env["DEBUG"]:
fuzzing += ["-gline-tables-only"]
env.Append(CCFLAGS=fuzzing, LINKFLAGS=fuzzing)
if sys.platform == "darwin":
env.Append(
LINKFLAGS=[
"-L/usr/local/opt/nss/lib",
"-L/usr/local/opt/nspr/lib",
"-L/usr/local/opt/msgpack/lib",
],
# NOTE: this may be necessary on other platforms
CFLAGS=["-I/usr/local/opt/msgpack/include"],
)
include_pattern = "-I/usr/local/opt/{0}/include/{0}"
elif (
sys.platform.startswith("dragonfly")
or sys.platform.startswith("freebsd")
or sys.platform.startswith("openbsd")
):
env.Append(LINKFLAGS=["-L/usr/local/lib"])
env.Append(CFLAGS=["-isystem/usr/local/include"])
include_pattern = "-isystem/usr/local/include/{0}"
else:
include_pattern = "-I/usr/include/{0}"
env.Append(
LIBS=["mprio", "mpi", "nss3", "nspr4"],
LIBPATH=["#build/prio", "#build/mpi"],
CFLAGS=[
"-Wall",
"-Werror",
"-Wextra",
"-O3",
"-std=c99",
"-Wvla",
include_pattern.format("nss"),
include_pattern.format("nspr"),
"-Impi",
"-DDO_PR_CLEANUP",
"-DNSS_PKCS11_2_0_COMPAT",
],
)
env.Append(CPPPATH=["#include", "#."])
Export("env")
SConscript("mpi/SConscript", variant_dir="build/mpi")
SConscript("pclient/SConscript", variant_dir="build/pclient")
SConscript("pclient_uint/SConscript", variant_dir="build/pclient_uint")
SConscript("prio/SConscript", variant_dir="build/prio")
SConscript("ptest/SConscript", variant_dir="build/ptest")
if env["FUZZING"]:
SConscript("pfuzz/SConscript", variant_dir="build/pfuzz")