-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSConstruct
91 lines (76 loc) · 2.5 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
from sconutils import runpretty, bldlexrs
git_root = runpretty("git rev-parse --show-toplevel").decode()
print(git_root)
env = Environment()
env.Append(CCFLAGS="-O2 -Wall -Wextra -std=c99")
env.Append(LIBPATH=["/usr/lib", "/usr/local/lib", (git_root + "/build")])
dbg = ARGUMENTS.get("debug", 0)
afl = ARGUMENTS.get("afl", 0)
iniprint = ARGUMENTS.get("iniprint", 0)
Repository("/usr/include", "src")
if int(afl):
dbg = "1"
env.Replace(CC="afl-gcc")
if int(dbg):
env.Append(CCFLAGS="-g")
if int(iniprint):
env.Append(CPPDEFINES=["INI_PRINT"])
# Build C lexer state machines
bldlexrs()
# Components
parser_src = ["src/weebparse.c", "src/weebutil.c"]
parsebed_src = ["src/parsebed.c"] + parser_src
# Program Targets
if (
"build/parsebed" in COMMAND_LINE_TARGETS
or "parsebed" in COMMAND_LINE_TARGETS
):
env.Alias("parsebed", ["build/parsebed"])
parsebed = env.Program(target="build/parsebed", source=parsebed_src)
elif "mocka" in COMMAND_LINE_TARGETS:
env.Append(LIBS="cmocka")
env.Append(CCFLAGS="-g")
mockatests = [
"src/t/test_cmocka.t",
"src/t/test_weebparse_good1.t",
"src/t/test_weebparse_good2.t",
"src/t/test_weebparse_badfiles.t",
]
env.Alias("mocka", mockatests)
lextest_defines = ["MOCKA_TESTVARS"]
if "CPP_DEFINES" in env:
lextest_defines += env["CPP_DEFINES"]
printwrap_def = lextest_defines + ["INI_PRINT"]
twg1_env = env.Clone(
CFLAGS=env["CCFLAGS"],
CPPDEFINES=printwrap_def + ["TEST_WEEBPARSE_GOOD1"],
OBJPREFIX="twg1_",
)
test_weebparse_good1 = twg1_env.Program(
target="src/t/test_weebparse_good1.t",
source=parser_src + ["src/t/test_weebparse.c"],
)
twg2_env = env.Clone(
CFLAGS=env["CCFLAGS"],
CPPDEFINES=printwrap_def + ["TEST_WEEBPARSE_GOOD2"],
OBJPREFIX="twg2_",
)
test_weebparse_good2 = twg2_env.Program(
target="src/t/test_weebparse_good2.t",
source=parser_src + ["src/t/test_weebparse.c"],
)
test_weebparse_badfiles = env.Program(
target="src/t/test_weebparse_badfiles.t",
source=parser_src + ["src/t/test_weebparse_badfiles.c"],
CFLAGS=env["CCFLAGS"],
)
test_cmocka = env.Program(
target="src/t/test_cmocka.t", source=["src/t/test_cmocka.c"]
)
else:
env.Alias("weeb2psp", ["build/weeb2psp"])
weeb2psp = env.Program(
target="build/weeb2psp",
source=["src/weeb2psp.c", "src/weebutil.c", "src/weebfiles.c"],
)
Default("build/weeb2psp")