@@ -18,11 +18,13 @@ set -euo pipefail
1818
1919SOURCE_ROOT=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
2020OUTPUT_DIR=" $SOURCE_ROOT /output"
21- BUILD_TYPE=" release"
21+ BUILD_TYPE=" Release"
22+ BUILD_DIR=" $SOURCE_ROOT /build-release"
2223BUILD_NAME=" paimon-cpp"
2324MAKE_CLEAN=false
2425PACKAGE=false
25- CMAKE_OPTIONS=" "
26+ CMAKE_OPTIONS=()
27+ JOBS=" "
2628
2729show_help () {
2830 cat << EOF
@@ -33,15 +35,16 @@ Options:
3335 -d, --debug Build debug version
3436 -c, --clean Clean build directory before building
3537 -p, --package Package creation
38+ -j, --jobs <num> Number of parallel jobs for building (default: auto-detect)
3639 -h, --help Show this help message
3740
3841CMake Options:
3942 Any unrecognized options will be passed directly to CMake.
4043 You can specify multiple CMake options.
4144
4245Examples:
43- $0 -r -p -DPAIMON_BUILD_SHARED=ON -DPAIMON_BUILD_STATIC=OFF
44- $0 --debug --clean --package
46+ $0 -r -p -j 8 - DPAIMON_BUILD_SHARED=ON -DPAIMON_BUILD_STATIC=OFF
47+ $0 --debug --clean --package --jobs 4
4548
4649EOF
4750}
@@ -50,11 +53,14 @@ while [[ $# -gt 0 ]]; do
5053 case " $1 " in
5154 -r|--release)
5255 BUILD_TYPE=" Release"
56+ BUILD_DIR=" $SOURCE_ROOT /build-release"
57+ BUILD_NAME=" paimon-cpp"
5358 shift
5459 ;;
5560 -d|--debug)
5661 BUILD_TYPE=" Debug"
57- BUILD_NAME=$BUILD_NAME " -debug"
62+ BUILD_DIR=" $SOURCE_ROOT /build-debug"
63+ BUILD_NAME=" paimon-cpp-debug"
5864 shift
5965 ;;
6066 -c|--clean)
@@ -65,27 +71,40 @@ while [[ $# -gt 0 ]]; do
6571 PACKAGE=true
6672 shift
6773 ;;
74+ -j|--jobs)
75+ shift
76+ if [[ $# -gt 0 && $1 =~ ^[0-9]+$ ]]; then
77+ JOBS=" $1 "
78+ shift
79+ else
80+ echo " Error: -j/--jobs requires a numeric argument" >&2
81+ exit 1
82+ fi
83+ ;;
6884 -h|--help)
6985 show_help
7086 exit 0
7187 ;;
7288 * )
7389 # All remaining parameters are CMake options
74- CMAKE_OPTIONS= " $CMAKE_OPTIONS $1 "
90+ CMAKE_OPTIONS+=( " $1 " )
7591 shift
7692 ;;
7793 esac
7894done
7995
80- CMAKE_OPTIONS=$( echo " $CMAKE_OPTIONS " | xargs)
81-
8296echo " ========== Build Configuration =========="
8397echo " Build Type: $BUILD_TYPE "
8498echo " Package Name: $BUILD_NAME "
8599echo " Clean Build: $MAKE_CLEAN "
86100echo " Package: $PACKAGE "
87- if [ -n " $CMAKE_OPTIONS " ]; then
88- echo " CMake Options: $CMAKE_OPTIONS "
101+ if [ -n " $JOBS " ]; then
102+ echo " Parallel Jobs: $JOBS "
103+ else
104+ echo " Parallel Jobs: auto-detect"
105+ fi
106+ if [ ${# CMAKE_OPTIONS[@]} -gt 0 ]; then
107+ echo " CMake Options: ${CMAKE_OPTIONS[*]} "
89108else
90109 echo " CMake Options: None"
91110fi
@@ -95,33 +114,39 @@ echo "Step 1: Downloading dependencies..."
95114" $SOURCE_ROOT " /third_party/download_dependencies.sh
96115
97116echo " Step 2: Building Paimon..."
98- BUILD_DIR=" $SOURCE_ROOT /build-$BUILD_TYPE "
99117PACKAGE_DIR=" $OUTPUT_DIR /$BUILD_NAME "
100118
101119if [ " $MAKE_CLEAN " = true ]; then
120+ echo " Cleaning build directory: $BUILD_DIR "
102121 rm -rf " $BUILD_DIR "
103122fi
104123mkdir -p " $BUILD_DIR "
105124cd " $BUILD_DIR "
125+
106126CMAKE_ARGS=(
127+ -G " Ninja"
107128 -DCMAKE_BUILD_TYPE=" $BUILD_TYPE "
108129 -DCMAKE_INSTALL_PREFIX=" $PACKAGE_DIR "
109130)
110131
111- if [ -n " $ CMAKE_OPTIONS" ]; then
112- CMAKE_ARGS+=(" $CMAKE_OPTIONS " )
132+ if [ ${ # CMAKE_OPTIONS[@]} -gt 0 ]; then
133+ CMAKE_ARGS+=(" ${ CMAKE_OPTIONS[@]} " )
113134fi
114135
115136cmake " ${CMAKE_ARGS[@]} " ..
116137
117- JOBS=$( nproc 2> /dev/null || echo 4)
118- make -j" $JOBS "
138+ # Set default JOBS if not specified
139+ if [ -z " $JOBS " ]; then
140+ JOBS=$( nproc 2> /dev/null || echo 4)
141+ fi
142+
143+ ninja -j" $JOBS "
119144
120145if [ " $PACKAGE " = true ]; then
121146 echo " Step 3: Packaging..."
122147 mkdir -p " $OUTPUT_DIR "
123148 cd " $BUILD_DIR "
124- make install
149+ ninja install
125150 tar -czvf " $OUTPUT_DIR /$BUILD_NAME .tar.gz" -C " $OUTPUT_DIR " " $BUILD_NAME "
126151 echo " Package created: $OUTPUT_DIR /$BUILD_NAME .tar.gz"
127152else
0 commit comments