From e08a8f89f323fe4578b23b5ed4a6655e5a08aebc Mon Sep 17 00:00:00 2001 From: Leonardo Vencovsky Date: Thu, 11 Jun 2020 22:04:23 -0300 Subject: [PATCH] Update autogen.py and travis --- .travis.yml | 2 +- autogen.py | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7ffa96..8efae36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,6 @@ addons: script: - sudo ln -s /usr/bin/gcc-6 /usr/local/bin/gcc - export CC=gcc-7 - - make coverage + - make after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/autogen.py b/autogen.py index ed5d58d..9afc512 100644 --- a/autogen.py +++ b/autogen.py @@ -1,4 +1,5 @@ -# A script that automatically expands the macros for code coverage +# A script that automatically generates code for code coverage, updates tests +# and Makefiles, and creates necessary directories import os import sys @@ -130,15 +131,21 @@ for ftype in ['HEADER', 'SOURCE']: os.remove(TMP_FILE) # Format all files -print('Formating files...') +from shutil import which -cmd = ['clang-format', '--style=file', '--verbose', '-i'] -dirs_to_format = [f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{lib.lower()}/*.{EXT_MAP[ftype]}' for ftype in DIR_MAP.keys() for lib in ALL_LIBS] +if which('clang-format') is not None: + print('clang-format found. Formating files...') -cmd.extend(dirs_to_format) -subprocess.call(cmd) + cmd = ['clang-format', '--style=file', '--verbose', '-i'] + dirs_to_format = [f'{OUTPUT_DIR}/{DIR_MAP[ftype]}/{lib.lower()}/*.{EXT_MAP[ftype]}' for ftype in DIR_MAP.keys() for lib in ALL_LIBS] + + cmd.extend(dirs_to_format) + subprocess.call(cmd) +else: + print('clang-format not found. Skipping code formatting...') # Makefile +# Contains many usefull things dealing with tests, code coverage and formatting BUILD_DIR = f'{OUTPUT_DIR}/build' OBJ_DIR = f'{BUILD_DIR}/obj' INCLUDE_DIR = f"{OUTPUT_DIR}/{DIR_MAP['HEADER']}" @@ -150,6 +157,8 @@ assert_dir(OBJ_DIR) for lib in ALL_LIBS: assert_dir(f'{OBJ_DIR}/{lib.lower()}') +print('Updating Makefile...') + file = open(f'Makefile', 'w') file.write(f'''# This file was generated by a Python script @@ -212,4 +221,4 @@ for data in collections: file.close() -print('Done') +print('\nDone')