| #!/bin/bash |
| # |
| # This script generates the required files for supporting the debug |
| # channels used throught the code. |
| # The generated files are |
| # include/debugdefs.h |
| # include/debug.h |
| # The script must be run in the root directory of the project. |
| # |
| # Dimitrie O. Paun <dimi@cs.toronto.edu> |
| # |
| DEBUG_H="include/debug.h" |
| DEBUG_DEFS_H="include/debugdefs.h" |
| |
| DEBUG_CHANNELS="$( tools/find_debug_channels )" |
| |
| { |
| cat <<EOF |
| /* Do not modify this file -- it is automatically generated! */ |
| |
| #ifndef __DEBUGTOOLS_H |
| #include "debugtools.h" |
| #endif |
| |
| EOF |
| i=0 |
| for ch in $DEBUG_CHANNELS |
| do |
| echo "#define dbch_${ch} $i" |
| let i=$i+1 |
| done |
| } > $DEBUG_H |
| |
| # Now, on the last step, we proceed to construct |
| # the definitions to be used by the main function. |
| # These will be stored in include/debugdefs.h |
| { |
| cat <<EOF |
| /* Do not modify this file -- it is automatically generated! */ |
| |
| #ifndef __DEBUGTOOLS_H |
| #include "debugtools.h" |
| #endif |
| |
| #define DEBUG_CHANNEL_COUNT $i |
| #ifdef DEBUG_RUNTIME |
| short debug_msg_enabled[][DEBUG_CLASS_COUNT] = { |
| EOF |
| |
| for ch in $DEBUG_CHANNELS |
| do |
| echo "{1, 1, 0, 0}," |
| done |
| echo '};' |
| |
| echo 'const char* debug_ch_name[] = {' |
| for ch in $DEBUG_CHANNELS |
| do |
| echo "\"${ch}\"," |
| done |
| echo '};' |
| |
| cat <<EOF |
| |
| const char* debug_cl_name[] = |
| { "fixme", "err", "warn", "info" }; |
| |
| #endif /*DEBUG_RUNTIME*/ |
| |
| /* end of automatically generated debug.h */ |
| EOF |
| |
| } > $DEBUG_DEFS_H |
| |
| |