Updating autogen.py

This commit is contained in:
Leonardo Vencovsky committed 2020-06-22 23:27:20 -03:00
1 parent a1e0a4edbb
commit e1bb3542ee
2 files changed
+26 -7

No files matched your search

+1 -1
View File
@@ -17,6 +17,6 @@ script:
- export CC=gcc-9
- gcc --version
- python --version
- python autogen.py -e -b -cv -r
- python autogen.py -e -b -cv -r -nf
after_success:
- bash <(curl -s https://codecov.io/bash)
+25 -6
View File
@@ -43,6 +43,8 @@ SRC_DIR = f"{OUTPUT_DIR}/{DIR_MAP['SOURCE']}"
OBJ_DIR = BUILD_DIR
# The name of the main test executable
TEST_EXE = f'{OUTPUT_DIR}/main.exe'
# Where .gcov files should go
GCOV_DIR = f'{BUILD_DIR}/gcov'
# Compiler
@@ -50,8 +52,12 @@ TEST_EXE = f'{OUTPUT_DIR}/main.exe'
CC = 'gcc'
# Compilation Flags
CFLAGS = ['-Wall', '-Werror']
# Link flags
LFLAGS = []
# Coverage Flags
CVFLAGS = ['--coverage', '-O0']
# gcov flags
GCOV_FLAGS = []
# Include to the main Library
# const
INCLUDE = ['-I', './src']
@@ -82,10 +88,13 @@ CONFIG = f'''Directory Settings
INCLUDE_DIR = {INCLUDE_DIR}
SRC_DIR = {SRC_DIR}
OBJ_DIR = {OBJ_DIR}
GCOV_DIR = {GCOV_DIR}
Compiler Settings
CC = {CC}
CFLAGS = {CFLAGS}
LFLAGS = {LFLAGS}
CVFLAGS = {CVFLAGS}
GCOV_FLAGS = {GCOV_FLAGS}
INCLUDE = {INCLUDE}
TINCLUDE = {TINCLUDE}
Macro Expansion
@@ -165,6 +174,7 @@ def assert_structure():
assert_dir(BUILD_DIR)
assert_dir(OBJ_DIR)
assert_dir(GCOV_DIR)
for lib in ALL_LIBS:
assert_dir(f'{OBJ_DIR}/{lib.lower()}')
@@ -174,11 +184,13 @@ def clean_build(cleanfull: bool):
'''
Removes all files generated by compilation and code coverage along with folders.
'''
execute_command(['rm', '-r', '*.gcov'])
execute_command(['rm', '-r', f'{GCOV_DIR}/*.gcov'])
execute_command(['rm', TEST_EXE])
execute_command(['rm', '-r', BUILD_DIR])
for directory in [BUILD_DIR, SRC_DIR, INCLUDE_DIR]:
execute_command(['rm', '-r', directory])
if cleanfull:
execute_command(['rm', '-r', SRC_DIR])
execute_command(['rm', '-r', INCLUDE_DIR])
def expand_code():
@@ -268,6 +280,7 @@ def build_tests(with_coverage: bool):
Build all object files and the main executable for tests
'''
cflags = CFLAGS.copy()
lflags = CFLAGS.copy()
if with_coverage:
cflags += CVFLAGS
@@ -295,6 +308,7 @@ def build_tests(with_coverage: bool):
# Link everything producing OUTPUT_DIR/main.exe
cmd = [CC]
cmd += cflags
cmd += LFLAGS
cmd += ['-o', TEST_EXE]
cmd += [f'{OBJ_DIR}/main.o']
cmd += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.o' for data in COLLECTIONS]
@@ -308,9 +322,10 @@ def run_tests(coverage: bool):
execute_command([full_path(TEST_EXE)])
if coverage:
objects = [f'{OBJ_DIR}/main.o']
objects += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.o' for data in COLLECTIONS]
execute_command(['gcov'] + objects)
objects = [f'{OBJ_DIR}/main.gcda']
objects += [f'{OBJ_DIR}/{data["LIB"].lower()}/{data["SNAME"]}.gcda' for data in COLLECTIONS]
execute_command(['gcov'] + GCOV_FLAGS + objects)
execute_command(['mv', '*.gcov', GCOV_DIR])
if __name__ == '__main__':
@@ -395,6 +410,10 @@ if __name__ == '__main__':
if not args.noformat:
assert_executable('clang-format')
format_expand()
else:
# In case the next task is to build the code from source
# This warning is a very annoying one from gcc
CFLAGS += ['-Wno-misleading-indentation']
if args.fmt_source or args.fmt_tests:
assert_executable('find')