Add option to disable runtime asserts
This commit is contained in:
81
Makefile
81
Makefile
@@ -8,6 +8,7 @@ BUILD_TYPE = Debug
|
|||||||
BUILD_DIR = libwapp-build/$(PLATFORM)-$(BUILD_TYPE)
|
BUILD_DIR = libwapp-build/$(PLATFORM)-$(BUILD_TYPE)
|
||||||
INSTALL_PREFIX = dist
|
INSTALL_PREFIX = dist
|
||||||
CODEGEN_INPUT = ""
|
CODEGEN_INPUT = ""
|
||||||
|
RUNTIME_ASSERT = true
|
||||||
|
|
||||||
# Internal variables
|
# Internal variables
|
||||||
override CFLAGS = -Wall -Wextra -Werror -pedantic -Isrc
|
override CFLAGS = -Wall -Wextra -Werror -pedantic -Isrc
|
||||||
@@ -43,33 +44,77 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Disable runtime asserts
|
||||||
|
ifeq ($(RUNTIME_ASSERT), false)
|
||||||
|
override BUILD_FLAGS += WAPP_NO_RUNTIME_ASSERT
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CC),gcc)
|
ifeq ($(CC),gcc)
|
||||||
# Used to disable the "ASan runtime does not come first in initial library list" error when compiling with gcc
|
# Used to disable the "ASan runtime does not come first in initial library list" error when compiling with gcc
|
||||||
export ASAN_OPTIONS=verify_asan_link_order=0
|
export ASAN_OPTIONS=verify_asan_link_order=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Escape sequences
|
||||||
|
BOLD = \033[1m
|
||||||
|
BLACK = \033[30m
|
||||||
|
BG_BLACK = \033[40m
|
||||||
|
RED = \033[31m
|
||||||
|
BG_RED = \033[41m
|
||||||
|
GREEN = \033[32m
|
||||||
|
BG_GREEN = \033[42m
|
||||||
|
YELLOW = \033[33m
|
||||||
|
BG_YELLOW = \033[43m
|
||||||
|
BLUE = \033[34m
|
||||||
|
BG_BLUE = \033[44m
|
||||||
|
MAGENTA = \033[35m
|
||||||
|
BG_MAGENTA = \033[45m
|
||||||
|
CYAN = \033[36m
|
||||||
|
BG_CYAN = \033[46m
|
||||||
|
WHITE = \033[37m
|
||||||
|
BG_WHITE = \033[47m
|
||||||
|
GRAY = \033[90m
|
||||||
|
BG_GRAY = \033[100m
|
||||||
|
BRIGHT_RED = \033[91m
|
||||||
|
BG_BRIGHT_RED = \033[101m
|
||||||
|
BRIGHT_GREEN = \033[92m
|
||||||
|
BG_BRIGHT_GREEN = \033[102m
|
||||||
|
BRIGHT_YELLOW = \033[93m
|
||||||
|
BG_BRIGHT_YELLOW = \033[103m
|
||||||
|
BRIGHT_BLUE = \033[94m
|
||||||
|
BG_BRIGHT_BLUE = \033[104m
|
||||||
|
BRIGHT_MAGENTA = \033[95m
|
||||||
|
BG_BRIGHT_MAGENTA = \033[105m
|
||||||
|
BRIGHT_CYAN = \033[96m
|
||||||
|
BG_BRIGHT_CYAN = \033[106m
|
||||||
|
BRIGHT_WHITE = \033[97m
|
||||||
|
BG_BRIGHT_WHITE = \033[107m
|
||||||
|
RESET = \033[0m
|
||||||
|
|
||||||
all: clean builddir codegen run-c-test full run-cc-test
|
all: clean builddir codegen run-c-test full run-cc-test
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Available build variables:"
|
@echo -e "$(BOLD)$(BLUE)Available build variables:$(RESET)"
|
||||||
@echo " CC C compiler to use (Default: clang)."
|
@echo -e " $(GREEN)CC$(RESET) C compiler to use $(YELLOW)(Default: clang)$(RESET)."
|
||||||
@echo " CXX C++ compiler to use (Default: clang++)."
|
@echo -e " $(GREEN)CXX$(RESET) C++ compiler to use $(YELLOW)(Default: clang++)$(RESET)."
|
||||||
@echo " AR Archiving utility to use for building static libraries (Default: ar)."
|
@echo -e " $(GREEN)AR$(RESET) Archiving utility to use for building static libraries $(YELLOW)(Default: ar)$(RESET)."
|
||||||
@echo " BUILD_TYPE Build type. Choose from \`Debug\`, \`RelWithDebInfo\` or \`Release\` (Default: Debug)."
|
@echo -e " $(GREEN)BUILD_TYPE$(RESET) Build type $(MAGENTA)[Debug | RelWithDebInfo | Release] $(YELLOW)(Default: Debug)$(RESET)."
|
||||||
@echo " BUILD_DIR Directory where build files will be written."
|
@echo -e " $(GREEN)BUILD_DIR$(RESET) Directory where build files will be written."
|
||||||
@echo " INSTALL_PREFIX Prefix where library and include files will be installed."
|
@echo -e " $(GREEN)INSTALL_PREFIX$(RESET) Prefix where library and include files will be installed."
|
||||||
@echo " CODEGEN_INPUT Input file for code generation (See codegen_custom_data_example.json for an example)."
|
@echo -e " $(GREEN)CODEGEN_INPUT$(RESET) Input file for code generation (See $(CYAN)codegen_custom_data_example.json$(RESET) for an example)."
|
||||||
|
@echo -e " $(GREEN)RUNTIME_ASSERT$(RESET) Whether runtime asserts are enabled $(MAGENTA)[true | false] $(YELLOW)(Default: true)$(RESET)."
|
||||||
|
@echo -e " $(GREEN)$(RESET) $(BOLD)$(RED)DISCLAIMER:$(RESET) Using this flag is not recommended as it disables safety checks"
|
||||||
|
@echo -e " $(GREEN)$(RESET) potentially leading to Undefined Behaviour."
|
||||||
@echo
|
@echo
|
||||||
@echo "Available targets:"
|
@echo -e "$(BOLD)$(BLUE)Available targets:$(RESET)"
|
||||||
@echo " make Build, install and test the full wapp library."
|
@echo -e " $(GREEN)make$(RESET) Build, install and test the full wapp library."
|
||||||
@echo " make full Build and install the full wapp library."
|
@echo -e " $(GREEN)make full$(RESET) Build and install the full wapp library."
|
||||||
@echo " make core Build and install only the \`core\` component of the wapp library with all its dependencies."
|
@echo -e " $(GREEN)make core$(RESET) Build and install only the $(CYAN)core$(RESET) component of the wapp library with all its dependencies."
|
||||||
@echo " make prng Build and install only the \`prng\` component of the wapp library with all its dependencies."
|
@echo -e " $(GREEN)make prng$(RESET) Build and install only the $(CYAN)prng$(RESET) component of the wapp library with all its dependencies."
|
||||||
@echo " make uuid Build and install only the \`uuid\` component of the wapp library with all its dependencies."
|
@echo -e " $(GREEN)make uuid$(RESET) Build and install only the $(CYAN)uuid$(RESET) component of the wapp library with all its dependencies."
|
||||||
@echo " make testing Build and install only the \`testing\` component of the wapp library with all its dependencies."
|
@echo -e " $(GREEN)make testing$(RESET) Build and install only the $(CYAN)testing$(RESET) component of the wapp library with all its dependencies."
|
||||||
@echo " make primitives Build and install only the \`primitives\` component of the wapp library with all its dependencies."
|
@echo -e " $(GREEN)make primitives$(RESET) Build and install only the $(CYAN)primitives$(RESET) component of the wapp library with all its dependencies."
|
||||||
@echo " make clean Clean build directory."
|
@echo -e " $(GREEN)make clean$(RESET) Clean the build directory."
|
||||||
@echo " make help Print this help message and exit."
|
@echo -e " $(GREEN)make help$(RESET) Print this help message and exit."
|
||||||
|
|
||||||
full: LIB_SRC = src/wapp.c
|
full: LIB_SRC = src/wapp.c
|
||||||
full: INCLUDES = common core primitives prng testing uuid
|
full: INCLUDES = common core primitives prng testing uuid
|
||||||
|
|||||||
@@ -14,7 +14,12 @@ BEGIN_C_LINKAGE
|
|||||||
#endif // !WAPP_PLATFORM_CPP
|
#endif // !WAPP_PLATFORM_CPP
|
||||||
|
|
||||||
#define wapp_static_assert(EXPR, MSG) extern char ASSERTION_FAILED[EXPR ? 1 : -1]
|
#define wapp_static_assert(EXPR, MSG) extern char ASSERTION_FAILED[EXPR ? 1 : -1]
|
||||||
#define wapp_runtime_assert(EXPR, MSG) __wapp_runtime_assert(EXPR, MSG)
|
|
||||||
|
#ifndef WAPP_NO_RUNTIME_ASSERT
|
||||||
|
#define wapp_runtime_assert(EXPR, MSG) __wapp_runtime_assert(EXPR, MSG)
|
||||||
|
#else
|
||||||
|
#define wapp_runtime_assert(EXPR, MSG)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WAPP_DEBUG_ASSERT
|
#ifdef WAPP_DEBUG_ASSERT
|
||||||
#define wapp_debug_assert(EXPR, MSG) wapp_runtime_assert(EXPR, MSG)
|
#define wapp_debug_assert(EXPR, MSG) wapp_runtime_assert(EXPR, MSG)
|
||||||
|
|||||||
Reference in New Issue
Block a user