Skip to content

Commit

Permalink
format tools/configure.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Dec 5, 2023
1 parent 9795943 commit 4bdb7cc
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions tools/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def dependencies(self, source_dir, algorithm, source_file):
files = []
for line in stdout.splitlines():
# Remove object file and the c file itself
first_line_search = "(\w*).o: " + \
re.escape(join(source_dir, "(\w*).c"))
first_line_search = "(\w*).o: " + re.escape(join(source_dir, "(\w*).c"))
line = re.sub(first_line_search, "", line)
line = line.strip()
line = line.split(" ")
Expand All @@ -87,8 +86,7 @@ def dependencies(self, source_dir, algorithm, source_file):
# Get all source files in source_dir
source_files = glob(join(source_dir, "*.c"))
# remove source_dir and .c
source_files = list(
map(lambda s: s[len(source_dir) + 1: -2], source_files))
source_files = list(map(lambda s: s[len(source_dir) + 1 : -2], source_files))

# Now let's collect the c files from the included headers
# This adds all files without looking at the feature requirements into deps.
Expand Down Expand Up @@ -181,8 +179,7 @@ def __init__(
self.hacl_includes = []
for a in self.hacl_files:
for source_file in self.hacl_files[a]:
files, includes = self.dependencies(
source_dir, a, source_file["file"])
files, includes = self.dependencies(source_dir, a, source_file["file"])
self.hacl_includes.extend(
includes if type(includes) == list else [includes]
)
Expand Down Expand Up @@ -232,8 +229,10 @@ def __init__(
# Flatten libcrux sources
libcrux_files_flattened = []
for _, impls in self.libcrux_files.items():
libcrux_files_flattened.extend(impl["file"] for impl in impls)
self.libcrux_files = [join("libcrux", "src", f) for f in libcrux_files_flattened]
libcrux_files_flattened.extend(impl["file"] for impl in impls)
self.libcrux_files = [
join("libcrux", "src", f) for f in libcrux_files_flattened
]

# Evercrypt has feature detection and we don't disable anything.
self.evercrypt_compile_files = []
Expand All @@ -250,8 +249,7 @@ def __init__(
self.hacl_compile_feature[k] = list(
dict.fromkeys(self.hacl_compile_feature[k])
)
self.evercrypt_compile_files = list(
dict.fromkeys(self.evercrypt_compile_files))
self.evercrypt_compile_files = list(dict.fromkeys(self.evercrypt_compile_files))
self.hacl_includes = list(dict.fromkeys(self.hacl_includes))
# Drop Hacl_ files from evercrypt
self.evercrypt_compile_files = [
Expand Down Expand Up @@ -355,17 +353,14 @@ def write_cmake_config(self, cmake_config):
"set(LIBCRUX_SOURCES\n\t%s\n)\n"
% (
"\n\t".join(
join("${PROJECT_SOURCE_DIR}", f)
for f in self.libcrux_files
join("${PROJECT_SOURCE_DIR}", f) for f in self.libcrux_files
).replace("\\", "/"),
)
)

out.write(
"set(ALGORITHM_TEST_FILES\n\t%s\n)\n"
% "\n\t".join("TEST_FILES_" + a for a in self.tests).replace(
"\\", "/"
)
% "\n\t".join("TEST_FILES_" + a for a in self.tests).replace("\\", "/")
)
for a in self.tests:
out.write(
Expand Down

0 comments on commit 4bdb7cc

Please sign in to comment.