utils/c++expr: allow to change build directory

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2024-04-27 20:00:56 +02:00
parent 9b09550176
commit 42246791f0

View File

@ -12,6 +12,7 @@ OPTIONS:
-l LIB link against LIB (only for -I or -C) -l LIB link against LIB (only for -I or -C)
-b STEPS_NUM make program to benchmark specified code snippet and run tests with STEPS_NUM each -b STEPS_NUM make program to benchmark specified code snippet and run tests with STEPS_NUM each
-b perf-top run infinite benchmark and show perf top -b perf-top run infinite benchmark and show perf top
-B build-dir build directory for -I (default: "build")
-t TESTS_NUM make program to benchmark specified code snippet and run TESTS_NUM tests -t TESTS_NUM make program to benchmark specified code snippet and run TESTS_NUM tests
-o FILE do not run, just save binary executable file -o FILE do not run, just save binary executable file
-O CXX_OPTS forward option compiler (e.g. -O "-O3 -std=c++20") -O CXX_OPTS forward option compiler (e.g. -O "-O3 -std=c++20")
@ -37,6 +38,7 @@ GLOBAL=
OUTPUT_EXECUTABLE= OUTPUT_EXECUTABLE=
INCS="vector iostream typeinfo cstdlib cmath sys/time.h" INCS="vector iostream typeinfo cstdlib cmath sys/time.h"
LIBS="" LIBS=""
BUILD_DIR=build
BENCHMARK_STEPS=0 BENCHMARK_STEPS=0
RUN_PERFTOP= RUN_PERFTOP=
BENCHMARK_TESTS=5 BENCHMARK_TESTS=5
@ -51,7 +53,7 @@ CMD_PARAMS=
# #
if [ "$1" == "--help" ] || [ -z "$1" ]; then usage; fi if [ "$1" == "--help" ] || [ -z "$1" ]; then usage; fi
while getopts "vc:CIi:l:b:t:o:O:g:" OPT; do while getopts "vc:CIi:l:bB:t:o:O:g:" OPT; do
case "$OPT" in case "$OPT" in
v) set -x; ;; v) set -x; ;;
c) CXX="$OPTARG"; ;; c) CXX="$OPTARG"; ;;
@ -60,6 +62,7 @@ while getopts "vc:CIi:l:b:t:o:O:g:" OPT; do
i) INCS="$INCS $OPTARG"; ;; i) INCS="$INCS $OPTARG"; ;;
l) LIBS="$LIBS $OPTARG"; ;; l) LIBS="$LIBS $OPTARG"; ;;
b) if [ "$OPTARG" = perf-top ]; then BENCHMARK_STEPS=-1; RUN_PERFTOP=y; else BENCHMARK_STEPS="$OPTARG"; fi; ;; b) if [ "$OPTARG" = perf-top ]; then BENCHMARK_STEPS=-1; RUN_PERFTOP=y; else BENCHMARK_STEPS="$OPTARG"; fi; ;;
B) BUILD_DIR="$OPTARG"; ;;
t) BENCHMARK_TESTS="$OPTARG"; ;; t) BENCHMARK_TESTS="$OPTARG"; ;;
o) OUTPUT_EXECUTABLE="$OPTARG"; ;; o) OUTPUT_EXECUTABLE="$OPTARG"; ;;
O) CXX_OPTS="$CXX_OPTS $OPTARG"; ;; O) CXX_OPTS="$CXX_OPTS $OPTARG"; ;;
@ -110,11 +113,11 @@ find_clickhouse_root () {
find_clickhouse_build () { find_clickhouse_build () {
local CLICKHOUSE_ROOT="`find_clickhouse_root`" local CLICKHOUSE_ROOT="`find_clickhouse_root`"
if [ -e "$CLICKHOUSE_ROOT/build/CMakeCache.txt" ]; then if [ -e "$CLICKHOUSE_ROOT/$BUILD_DIR/CMakeCache.txt" ]; then
echo "$CLICKHOUSE_ROOT/build" echo "$CLICKHOUSE_ROOT/$BUILD_DIR"
return 0 return 0
fi fi
echo "error: $CLICKHOUSE_ROOT/build/CMakeCache.txt doesn't exist" echo "error: $CLICKHOUSE_ROOT/$BUILD_DIR/CMakeCache.txt doesn't exist"
return 1 return 1
} }