summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-03-27 05:32:42 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-03-27 05:32:42 +0200
commit1bd6db17fd115fe9cf71c945b73381d7d4417c1a (patch)
treef3766922f11e6439a301ced04c9ec08c90b2a40f
parent57aa67d435a11f3ffd0ac0d3472ca9288115a8d0 (diff)
downloadkit-1bd6db17fd115fe9cf71c945b73381d7d4417c1a.zip
Remove Python code
-rwxr-xr-xgen_cmake.py89
1 files changed, 0 insertions, 89 deletions
diff --git a/gen_cmake.py b/gen_cmake.py
deleted file mode 100755
index bded58a..0000000
--- a/gen_cmake.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/python3
-
-import os, glob
-
-def get_subdirs(folder: str):
- dirs = list()
- for f in glob.glob(os.path.join(folder, '*', '')):
- dirs.append(os.path.basename(os.path.normpath(f)))
- return dirs
-
-def get_files(folder: str, ext: str):
- files = list()
- for f in glob.glob(os.path.join(folder, ext)):
- files.append(os.path.basename(f))
- return files
-
-def check_subdirs(folder):
- for r, d, f in os.walk(folder):
- for file in f:
- return True
- return False
-
-def print_list(s: list, offset: int):
- buf = ''
- char_count = offset
- for i in range(char_count - 1):
- buf += ' '
- for f in s:
- char_count += len(f) + 1
- if char_count >= 64:
- char_count = 0
- if char_count == 0:
- buf += '\n'
- for i in range(offset - 1):
- buf += ' '
- char_count = offset - 1
- buf += ' ' + f
- return buf
-
-def print_sources(folder: str, target_name: str):
- buf = ''
- srcs = get_files(folder, '*.c') + get_files(folder, '*.cpp')
- hdrs = get_files(folder, '*.h')
- if len(srcs) > 0 or len(hdrs) > 0:
- buf += 'target_sources(\n ' + target_name
- if len(srcs) > 0:
- buf += '\n PRIVATE\n' + print_list(srcs, 6)
- if len(hdrs) > 0:
- buf += '\n PUBLIC'
- for f in hdrs:
- buf += '\n $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/' + f + '>'
- buf += ')\n'
- return buf
-
-def print_subdirs(folder: str):
- buf = ''
- dirs = get_subdirs(folder)
- for f in dirs:
- if check_subdirs(os.path.join(folder, f)):
- buf += 'add_subdirectory(' + f + ')\n'
- return buf
-
-def write_subdirs(folder: str, target_name: str):
- if check_subdirs(folder):
- out = open(os.path.join(folder, 'CMakeLists.txt'), 'w')
- out.write(print_sources(folder, target_name))
- out.write(print_subdirs(folder))
- out.close()
-
- for dir in get_subdirs(folder):
- write_subdirs(os.path.join(folder, dir), target_name)
-
-def clean_subdirs(folder: str):
- for r, d, f in os.walk(folder):
- for file in f:
- if file == 'CMakeLists.txt':
- os.remove(os.path.join(r, file))
-
-def gen_cmake(folder: str, target_name: str):
- clean_subdirs(folder)
- write_subdirs(folder, target_name)
-
-def main():
- gen_cmake(os.path.join('source', 'kit'), 'kit')
- gen_cmake(os.path.join('source', 'kit_test'), 'kit_test')
- gen_cmake(os.path.join('source', 'test', 'unittests'), 'kit_test_suite')
-
-if __name__ == '__main__':
- main()