aboutsummaryrefslogtreecommitdiff
path: root/SConscript
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2020-11-26 11:55:09 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-12-01 14:20:47 +0000
commitf605bd202afb861c95693e9cefd34f8b063f107b (patch)
tree6df58eac9fae5471566b6314999fe28804a1bcc9 /SConscript
parent4c634e005eee65466eee607c4e287a8d5a0ee57d (diff)
downloadComputeLibrary-f605bd202afb861c95693e9cefd34f8b063f107b.tar.gz
Remove comments when pulling cl kernels files as raw strings
ComputeLibrary integrates the cl kernel implementation files during build as raw strings to reduce dependencies when deploying. Remove all the C comments to reduce the total size that these consume to the end binary file. Reduces binary size of CL-only build by 35%. Resolves: COMPMID-4017 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: I28dcdfa0ca64f99621f98bbe38ec9e24ba76b61b Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4624 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'SConscript')
-rw-r--r--SConscript14
1 files changed, 13 insertions, 1 deletions
diff --git a/SConscript b/SConscript
index 8bff84ba6d..f1fe9b288c 100644
--- a/SConscript
+++ b/SConscript
@@ -55,6 +55,17 @@ def build_library(name, sources, static=False, libs=[]):
Default(obj)
return obj
+def remove_incode_comments(code):
+ def replace_with_empty(match):
+ s = match.group(0)
+ if s.startswith('/'):
+ return " "
+ else:
+ return s
+
+ comment_regex = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE)
+ return re.sub(comment_regex, replace_with_empty, code)
+
def resolve_includes(target, source, env):
# File collection
FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents')
@@ -67,7 +78,8 @@ def resolve_includes(target, source, env):
for i in range(len(source)):
src = source[i]
dst = target[i]
- contents = src.get_contents().decode('utf-8').splitlines()
+ contents = src.get_contents().decode('utf-8')
+ contents = remove_incode_comments(contents).splitlines()
entry = FileEntry(target_name=dst, file_contents=contents)
files.append((os.path.basename(src.get_path()),entry))