From 56432a44c64e6ab3b663fe783fd1b2138cee689d Mon Sep 17 00:00:00 2001 From: Maxim Biro Date: Sat, 6 Oct 2018 01:22:43 -0400 Subject: [PATCH] Make sure logger levels stay in sync across files --- .travis/cmake-linux | 2 ++ other/analysis/check_logger_levels | 18 ++++++++++++++++++ toxcore/logger.h | 1 + 3 files changed, 21 insertions(+) create mode 100755 other/analysis/check_logger_levels diff --git a/.travis/cmake-linux b/.travis/cmake-linux index 87df3b37..5f8fcbde 100755 --- a/.travis/cmake-linux +++ b/.travis/cmake-linux @@ -85,6 +85,8 @@ travis_script() { # Use () to run in a separate process so the exports are local. (run_static_analysis) + other/analysis/check_logger_levels + cmake -B_build -H. \ -DCMAKE_C_FLAGS="$C_FLAGS" \ -DCMAKE_CXX_FLAGS="$CXX_FLAGS" \ diff --git a/other/analysis/check_logger_levels b/other/analysis/check_logger_levels new file mode 100755 index 00000000..5cced4a1 --- /dev/null +++ b/other/analysis/check_logger_levels @@ -0,0 +1,18 @@ +#!/bin/sh + +# Make sure that logger levels in toxcore/logger.h, CMakeLists.txt and +# configure.ac stay in sync. + +set -ex + +TMP_DIR="$(mktemp -d)" + +# ^\s+LOGGER_LEVEL_(\w+),?$ +sed -n 's/^\s\+LOGGER_LEVEL_\(\w\+\),\?$/\1/p' toxcore/logger.h > "${TMP_DIR}/logger.h" +# ^.*\$\{MIN_LOGGER_LEVEL\}" STREQUAL "(\w+)".*$ +sed -n 's/^.*\${MIN_LOGGER_LEVEL}\" STREQUAL \"\(\w\+\)\".*$/\1/p' CMakeLists.txt > "${TMP_DIR}/CMakeLists.txt" +# ^.*LOGGER_LEVEL_(\w+).*$ +sed -n 's/^.*LOGGER_LEVEL_\(\w\+\).*$/\1/p' configure.ac > "${TMP_DIR}/configure.ac" + +diff -u "${TMP_DIR}/CMakeLists.txt" "${TMP_DIR}/logger.h" +diff -u "${TMP_DIR}/configure.ac" "${TMP_DIR}/logger.h" diff --git a/toxcore/logger.h b/toxcore/logger.h index 6231ca4b..2cae7a0e 100644 --- a/toxcore/logger.h +++ b/toxcore/logger.h @@ -32,6 +32,7 @@ #define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO #endif +// NOTE: Don't forget to update build system files after modifying the enum. typedef enum Logger_Level { LOGGER_LEVEL_TRACE, LOGGER_LEVEL_DEBUG,