Add support for release builds with debug info and using lib externally
This commit is contained in:
61
build
61
build
@@ -1,14 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
BUILD_TYPE="debug"
|
||||
# Colors
|
||||
RED="\033[0;31m"
|
||||
BOLD="\033[1m"
|
||||
NC="\033[0m" # No Color
|
||||
|
||||
BUILD_TYPE="Debug"
|
||||
ACCEPTED_BUILD_TYPES=("RelWithDebInfo" "Debug" "Release")
|
||||
KERNEL="$(uname -s)"
|
||||
ARGS=""
|
||||
|
||||
join_array_elements() {
|
||||
local IFS=","
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
print_usage() {
|
||||
echo -e "Usage: build [-b build_type] ..."
|
||||
echo -e " Options:"
|
||||
echo -e " -b, --build-type Choose from $(join_array_elements ${ACCEPTED_BUILD_TYPES[*]}) (Default: Debug)."
|
||||
echo -e " -h, --help Print this message and exit"
|
||||
}
|
||||
|
||||
while [[ $# > 0 ]];do
|
||||
case $1 in
|
||||
--release)
|
||||
BUILD_TYPE="release"
|
||||
shift
|
||||
-b|--build-type)
|
||||
BUILD_TYPE="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
print_usage
|
||||
exit 0
|
||||
;;
|
||||
*|-*|--*)
|
||||
rest=("$@")
|
||||
@@ -18,15 +40,24 @@ while [[ $# > 0 ]];do
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $KERNEL == "Darwin" ]]; then
|
||||
if [[ ! -d .venv ]]; then
|
||||
python3 -m venv .venv
|
||||
fi
|
||||
|
||||
source .venv/bin/activate
|
||||
pip install scan-build
|
||||
intercept-build make CC=intercept-cc CXX=intercept-c++ BUILD_TYPE=$BUILD_TYPE $ARGS
|
||||
deactivate
|
||||
else
|
||||
bear -- make BUILD_TYPE=$BUILD_TYPE $ARGS
|
||||
# Compare build type against array
|
||||
# From this: https://www.baeldung.com/linux/check-bash-array-contains-value#using-anifcondition-with-aregex-pattern
|
||||
build_regex="\<${BUILD_TYPE}\>"
|
||||
if [[ ! ${ACCEPTED_BUILD_TYPES[@]} =~ $build_regex ]]; then
|
||||
echo -e "${RED}${BOLD}Unknown build type: ${BUILD_TYPE}${NC}\n"
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $KERNEL == "Darwin" ]]; then
|
||||
if [[ ! -d .venv ]]; then
|
||||
python3 -m venv .venv
|
||||
fi
|
||||
|
||||
source .venv/bin/activate
|
||||
pip install scan-build
|
||||
intercept-build make CC=intercept-cc CXX=intercept-c++ BUILD_TYPE=$BUILD_TYPE $ARGS
|
||||
deactivate
|
||||
else
|
||||
bear -- make BUILD_TYPE=$BUILD_TYPE $ARGS
|
||||
fi
|
||||
|
Reference in New Issue
Block a user