Repository navigation
Expand file tree
/
Copy pathcompile.py
More file actions
executable file
·166 lines (148 loc) · 5.03 KB
/
Copy pathcompile.py
File metadata and controls
executable file
·166 lines (148 loc) · 5.03 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python3
import argparse
import subprocess
def main():
parser = argparse.ArgumentParser(
description="Compile the project using CMake."
)
parser.add_argument(
"--check_hardcoded",
action="store_true",
help="Enable Check Hardcoded",
)
parser.add_argument(
"--configure", action="store_true", help="Configure project"
)
parser.add_argument(
"--coverage", action="store_true", help="Enable Coverage"
)
parser.add_argument(
"-d", "--debug", action="store_true", help="Enable Debug mode"
)
parser.add_argument(
"-e", "--examples", action="store_true", help="Enable Examples"
)
parser.add_argument(
"-g", "--google_test", action="store_true", help="Enable Google Test"
)
parser.add_argument(
"-i",
"--incremental_build",
action="store_true",
help="Enable Incremental Build",
)
parser.add_argument(
"--unit_test", action="store_true", help="Enable Unit Test"
)
parser.add_argument(
"--ckks_core_test", action="store_true", help="Enable CKKS Core Test"
)
parser.add_argument(
"--ckks_engine_base_test",
action="store_true",
help="Enable CKKS Engine Base Test",
)
parser.add_argument(
"--ckks_engine_sp_test",
action="store_true",
help="Enable CKKS Engine SP Test",
)
parser.add_argument(
"--ckks_engine_spe_test",
action="store_true",
help="Enable CKKS Engine SPE Test",
)
parser.add_argument(
"--ckks_engine_spx_test",
action="store_true",
help="Enable CKKS Engine SPX Test",
)
parser.add_argument(
"--ckks_engine_reject_test",
action="store_true",
help="Enable CKKS Engine Reject Test",
)
parser.add_argument(
"-l", "--large_test", action="store_true", help="Enable Large Test"
)
parser.add_argument(
"-j",
"--parallel",
nargs="?",
const=0,
default=None,
type=int,
help="Enable Parallel Build",
)
args = parser.parse_args()
args_dict = vars(args)
# Enabling google_test:
# a) enables all tests by default
# b) exposes extra scheme presets for testing
if args.google_test:
args_dict["unit_test"] = True
args_dict["ckks_core_test"] = True
args_dict["ckks_engine_base_test"] = True
args_dict["ckks_engine_sp_test"] = True
args_dict["ckks_engine_spe_test"] = True
args_dict["ckks_engine_spx_test"] = True
args_dict["ckks_engine_reject_test"] = True
elif (
args.unit_test
or args.ckks_core_test
or args.ckks_engine_base_test
or args.ckks_engine_sp_test
or args.ckks_engine_spe_test
or args.ckks_engine_spx_test
or args.ckks_engine_reject_test
):
args_dict["google_test"] = True
build_directory = "build"
compile_command = ["cmake", "-S", ".", "-B", build_directory]
if args.incremental_build:
compile_command.extend(["-G", "Ninja"])
flags = {
"check_hardcoded": "DESILO_FHE_CHECK_HARDCODED",
"configure": "DESILO_FHE_CONFIGURE",
"coverage": "DESILO_FHE_COVERAGE",
"debug": "DESILO_FHE_DEBUG",
"examples": "DESILO_FHE_EXAMPLES",
"google_test": "DESILO_FHE_GOOGLE_TEST",
"incremental_build": "DESILO_FHE_INCREMENTAL_BUILD",
"unit_test": "DESILO_FHE_UNIT_TEST",
"ckks_core_test": "DESILO_FHE_CKKS_CORE_TEST",
"ckks_engine_base_test": "DESILO_FHE_CKKS_ENGINE_BASE_TEST",
"ckks_engine_sp_test": "DESILO_FHE_CKKS_ENGINE_SP_TEST",
"ckks_engine_spe_test": "DESILO_FHE_CKKS_ENGINE_SPE_TEST",
"ckks_engine_spx_test": "DESILO_FHE_CKKS_ENGINE_SPX_TEST",
"ckks_engine_reject_test": "DESILO_FHE_CKKS_ENGINE_REJECT_TEST",
"large_test": "DESILO_FHE_LARGE_TEST",
}
compile_command.extend(
[
f'-D{flag}={"ON" if args_dict[arg] else "OFF"}'
for arg, flag in flags.items()
]
)
subprocess.run(compile_command, check=True)
if args.incremental_build:
build_command = ["ninja", "-C", build_directory]
# ninja runs in parallel by default
if args.parallel is None:
# we manually limit it to 1 job if --parallel is not specified
build_command.append("-j1")
elif args.parallel > 0:
# -j0 means infinity for ninja build, but that might be consume
# too many resources, so we just let ninja optimize itself
# by giving no -j option
build_command.append(f"-j{args.parallel}")
else:
build_command = ["cmake", "--build", build_directory]
if args.parallel is not None:
build_command.append("-j")
# We ignore 0 here like we did for ninja build
if args.parallel > 0:
build_command.append(f"{args.parallel}")
subprocess.run(build_command, check=True)
if __name__ == "__main__":
main()