Make sure logger levels stay in sync across files

This commit is contained in:
Maxim Biro 2018-10-06 01:22:43 -04:00
parent f5afc52655
commit 56432a44c6
No known key found for this signature in database
GPG Key ID: 76E9A6E7D9E20DFE
3 changed files with 21 additions and 0 deletions

View File

@ -85,6 +85,8 @@ travis_script() {
# Use () to run in a separate process so the exports are local. # Use () to run in a separate process so the exports are local.
(run_static_analysis) (run_static_analysis)
other/analysis/check_logger_levels
cmake -B_build -H. \ cmake -B_build -H. \
-DCMAKE_C_FLAGS="$C_FLAGS" \ -DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \ -DCMAKE_CXX_FLAGS="$CXX_FLAGS" \

View File

@ -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"

View File

@ -32,6 +32,7 @@
#define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO #define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO
#endif #endif
// NOTE: Don't forget to update build system files after modifying the enum.
typedef enum Logger_Level { typedef enum Logger_Level {
LOGGER_LEVEL_TRACE, LOGGER_LEVEL_TRACE,
LOGGER_LEVEL_DEBUG, LOGGER_LEVEL_DEBUG,