Skip to content

Commit d99bc8d

Browse files
author
Jianchun Xu
committed
xplat: support build with Ninja
Add build.sh `-n, --ninja` option to build with Ninja instead of make. (Ninja uses multicore build by default and doesn't mix output from different cores.)
1 parent ddd3e0b commit d99bc8d

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

build.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PRINT_USAGE() {
2626
echo " --help, -h : Show help"
2727
echo " --icu : Path to ICU include folder (see example below)"
2828
echo " --jobs, -j : Multicore build (i.e. -j=3 for 3 cores)"
29+
echo " --ninja, -n : Build with ninja instead of make"
2930
echo ""
3031
echo " example:"
3132
echo " ./build.sh --cxx=/path/to/clang++ --cc=/path/to/clang -j=2"
@@ -36,7 +37,9 @@ PRINT_USAGE() {
3637

3738
_CXX=""
3839
_CC=""
39-
DEBUG_BUILD=0
40+
BUILD_TYPE="Release"
41+
CMAKE_GEN=
42+
MAKE=make
4043
MULTICORE_BUILD=""
4144
ICU_PATH=""
4245

@@ -57,7 +60,7 @@ while [[ $# -gt 0 ]]; do
5760
fi
5861

5962
if [[ "$1" == "--debug" || "$1" == "-d" ]]; then
60-
DEBUG_BUILD=1
63+
BUILD_TYPE="Debug"
6164
fi
6265

6366
if [[ "$1" =~ "-j" ]]; then
@@ -75,6 +78,11 @@ while [[ $# -gt 0 ]]; do
7578
ICU_PATH="-DICU_INCLUDE_PATH=${ICU_PATH:6}"
7679
fi
7780

81+
if [[ "$1" == "--ninja" || "$1" == "-n" ]]; then
82+
CMAKE_GEN="-G Ninja"
83+
MAKE=ninja
84+
fi
85+
7886
shift
7987
done
8088

@@ -115,14 +123,8 @@ fi
115123

116124
pushd BuildLinux > /dev/null
117125

118-
if [ $DEBUG_BUILD -eq 1 ]; then
119-
echo Generating Debug makefiles
120-
cmake $CC_PREFIX $ICU_PATH -DCMAKE_BUILD_TYPE=Debug ..
121-
else
122-
echo Generating Retail makefiles
123-
echo Building Retail;
124-
cmake $CC_PREFIX $ICU_PATH -DCMAKE_BUILD_TYPE=Release ..
125-
fi
126+
echo Generating $BUILD_TYPE makefiles
127+
cmake $CMAKE_GEN $CC_PREFIX $ICU_PATH -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
126128

127-
make $MULTICORE_BUILD 2>&1 | tee build.log
129+
$MAKE $MULTICORE_BUILD 2>&1 | tee build.log
128130
popd > /dev/null

0 commit comments

Comments
 (0)