Skip to content

Commit bd31a5d

Browse files
authored
feat: Enhance 3rdparty build script with build type option (#42092)
See #42091 In this PR, - Added a new `-t` option to specify the build type (Debug/Release). - Updated the Makefile to pass the build type to the 3rdparty build script. - Included usage instructions for the script to improve user guidance. Signed-off-by: Ted Xu <[email protected]>
1 parent b9b5546 commit bd31a5d

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ download-milvus-proto:
253253

254254
build-3rdparty:
255255
@echo "Build 3rdparty ..."
256-
@(env bash $(PWD)/scripts/3rdparty_build.sh -o ${use_opendal})
256+
@(env bash $(PWD)/scripts/3rdparty_build.sh -o ${use_opendal} -t ${mode})
257257

258258
generated-proto-without-cpp: download-milvus-proto get-proto-deps
259259
@echo "Generate proto ..."

scripts/3rdparty_build.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ if [[ ${SKIP_3RDPARTY} -eq 1 ]]; then
2222
exit 0
2323
fi
2424

25+
usage() {
26+
echo "Usage: $0 [-o BUILD_OPENDAL] [-t BUILD_TYPE] [-h]"
27+
echo " -o BUILD_OPENDAL Enable/disable OpenDAL build (ON/OFF, default: OFF)"
28+
echo " -t BUILD_TYPE Set build type (Debug/Release/RelWithDebInfo/MinSizeRel, default: Release)"
29+
echo " -h Show this help message"
30+
echo ""
31+
echo "Examples:"
32+
echo " $0 # Build with default settings (Release, OpenDAL OFF)"
33+
echo " $0 -t Debug # Build in Debug mode"
34+
echo " $0 -o ON -t RelWithDebInfo # Build with OpenDAL enabled and RelWithDebInfo"
35+
}
36+
2537
SOURCE="${BASH_SOURCE[0]}"
2638
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
2739
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@@ -30,14 +42,37 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
3042
done
3143

3244
BUILD_OPENDAL="OFF"
33-
while getopts "o:" arg; do
45+
BUILD_TYPE="Release"
46+
while getopts "o:t:h" arg; do
3447
case $arg in
3548
o)
3649
BUILD_OPENDAL=$OPTARG
3750
;;
51+
t)
52+
BUILD_TYPE=$OPTARG
53+
;;
54+
h)
55+
usage
56+
exit 0
57+
;;
58+
*)
59+
usage
60+
exit 1
61+
;;
3862
esac
3963
done
4064

65+
# Validate build type
66+
case "${BUILD_TYPE}" in
67+
Debug|Release)
68+
echo "Build type: ${BUILD_TYPE}"
69+
;;
70+
*)
71+
echo "Invalid build type: ${BUILD_TYPE}. Valid options are: Debug, Release"
72+
exit 1
73+
;;
74+
esac
75+
4176
ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
4277
CPP_SRC_DIR="${ROOT_DIR}/internal/core"
4378
BUILD_OUTPUT_DIR="${ROOT_DIR}/cmake_build"
@@ -63,7 +98,7 @@ fi
6398
unameOut="$(uname -s)"
6499
case "${unameOut}" in
65100
Darwin*)
66-
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler=clang -s compiler.version=${llvm_version} -s compiler.libcxx=libc++ -s compiler.cppstd=17 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
101+
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s build_type=${BUILD_TYPE} -s compiler=clang -s compiler.version=${llvm_version} -s compiler.libcxx=libc++ -s compiler.cppstd=17 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
67102
;;
68103
Linux*)
69104
if [ -f /etc/os-release ]; then
@@ -75,9 +110,9 @@ case "${unameOut}" in
75110
export CPU_TARGET=avx
76111
GCC_VERSION=`gcc -dumpversion`
77112
if [[ `gcc -v 2>&1 | sed -n 's/.*\(--with-default-libstdcxx-abi\)=\(\w*\).*/\2/p'` == "gcc4" ]]; then
78-
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler.version=${GCC_VERSION} -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
113+
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s build_type=${BUILD_TYPE} -s compiler.version=${GCC_VERSION} -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
79114
else
80-
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler.version=${GCC_VERSION} -s compiler.libcxx=libstdc++11 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
115+
conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s build_type=${BUILD_TYPE} -s compiler.version=${GCC_VERSION} -s compiler.libcxx=libstdc++11 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
81116
fi
82117
;;
83118
*)

0 commit comments

Comments
 (0)