mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
feat(build): use parallel compile to speed up pre_build
Signed-off-by: NaturalSelect <2145973003@qq.com>
This commit is contained in:
parent
c1b17f0cef
commit
f1f9e50109
28
Makefile
28
Makefile
@ -1,6 +1,6 @@
|
||||
# Cubefs Makefile
|
||||
#
|
||||
|
||||
threads?=0
|
||||
RM := $(shell [ -x /bin/rm ] && echo "/bin/rm" || echo "/usr/bin/rm" )
|
||||
GOMOD=on
|
||||
default: all
|
||||
@ -12,34 +12,34 @@ phony += build server authtool client cli libsdk fsck fdstore preload bcache blo
|
||||
build: server authtool client cli libsdk fsck fdstore preload bcache blobstore
|
||||
|
||||
server:
|
||||
@build/build.sh server $(GOMOD)
|
||||
@build/build.sh server $(GOMOD) --threads=$(threads)
|
||||
|
||||
blobstore:
|
||||
@build/build.sh blobstore $(GOMOD)
|
||||
@build/build.sh blobstore $(GOMOD) --threads=$(threads)
|
||||
|
||||
client:
|
||||
@build/build.sh client $(GOMOD)
|
||||
@build/build.sh client $(GOMOD) --threads=$(threads)
|
||||
|
||||
authtool:
|
||||
@build/build.sh authtool $(GOMOD)
|
||||
@build/build.sh authtool $(GOMOD) --threads=$(threads)
|
||||
|
||||
cli:
|
||||
@build/build.sh cli $(GOMOD)
|
||||
@build/build.sh cli $(GOMOD) --threads=$(threads)
|
||||
|
||||
fsck:
|
||||
@build/build.sh fsck $(GOMOD)
|
||||
@build/build.sh fsck $(GOMOD) --threads=$(threads)
|
||||
|
||||
libsdk:
|
||||
@build/build.sh libsdk $(GOMOD)
|
||||
@build/build.sh libsdk $(GOMOD) --threads=$(threads)
|
||||
|
||||
fdstore:
|
||||
@build/build.sh fdstore $(GOMOD)
|
||||
@build/build.sh fdstore $(GOMOD) --threads=$(threads)
|
||||
|
||||
preload:
|
||||
@build/build.sh preload $(GOMOD)
|
||||
@build/build.sh preload $(GOMOD) --threads=$(threads)
|
||||
|
||||
bcache:
|
||||
@build/build.sh bcache $(GOMOD)
|
||||
@build/build.sh bcache $(GOMOD) --threads=$(threads)
|
||||
|
||||
phony += clean
|
||||
clean:
|
||||
@ -47,15 +47,15 @@ clean:
|
||||
|
||||
phony += dist-clean
|
||||
dist-clean:
|
||||
@build/build.sh dist_clean
|
||||
@build/build.sh dist_clean --threads=$(threads)
|
||||
|
||||
phony += test
|
||||
test:
|
||||
@build/build.sh test $(GOMOD)
|
||||
@build/build.sh test $(GOMOD) --threads=$(threads)
|
||||
|
||||
phony += testcover
|
||||
testcover:
|
||||
@build/build.sh testcover $(GOMOD)
|
||||
@build/build.sh testcover $(GOMOD) --threads=$(threads)
|
||||
|
||||
phony += mock
|
||||
mock:
|
||||
|
||||
@ -87,7 +87,7 @@ build_zlib() {
|
||||
echo "build zlib..."
|
||||
pushd ${BuildOutPath}/zlib-${ZLIB_VER}
|
||||
CFLAGS='-fPIC' ./configure --static
|
||||
make
|
||||
make -j$1
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -111,7 +111,7 @@ build_bzip2() {
|
||||
|
||||
echo "build bzip2..."
|
||||
pushd ${BuildOutPath}/bzip2-bzip2-${BZIP2_VER}
|
||||
make CFLAGS='-fPIC -O2 -g -D_FILE_OFFSET_BITS=64'
|
||||
make -j$1 CFLAGS='-fPIC -O2 -g -D_FILE_OFFSET_BITS=64'
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -132,7 +132,7 @@ build_lz4() {
|
||||
|
||||
echo "build lz4..."
|
||||
pushd ${BuildOutPath}/lz4-${LZ4_VER}/lib
|
||||
make CFLAGS='-fPIC -O2'
|
||||
make -j$1 CFLAGS='-fPIC -O2'
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -153,7 +153,7 @@ build_zstd() {
|
||||
|
||||
echo "build zstd..."
|
||||
pushd ${BuildOutPath}/zstd-${ZSTD_VER}/lib
|
||||
make CFLAGS='-fPIC -O2'
|
||||
make -j$1 CFLAGS='-fPIC -O2'
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -176,7 +176,7 @@ build_snappy() {
|
||||
echo "build snappy..."
|
||||
mkdir ${BuildOutPath}/snappy-${SNAPPY_VER}/build
|
||||
pushd ${BuildOutPath}/snappy-${SNAPPY_VER}/build
|
||||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSNAPPY_BUILD_TESTS=OFF .. && make
|
||||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSNAPPY_BUILD_TESTS=OFF .. && make -j$1
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@ -236,12 +236,12 @@ init_gopath() {
|
||||
}
|
||||
|
||||
pre_build() {
|
||||
build_zlib
|
||||
build_bzip2
|
||||
build_lz4
|
||||
build_zstd
|
||||
build_snappy
|
||||
build_rocksdb
|
||||
build_zlib $1
|
||||
build_bzip2 $1
|
||||
build_lz4 $1
|
||||
build_zstd $1
|
||||
build_snappy $1
|
||||
build_rocksdb $1
|
||||
|
||||
export CGO_CFLAGS=${cgo_cflags}
|
||||
export CGO_LDFLAGS="${cgo_ldflags}"
|
||||
@ -341,7 +341,6 @@ build_fsck() {
|
||||
}
|
||||
|
||||
build_snapshot() {
|
||||
pre_build
|
||||
pushd $SrcPath >/dev/null
|
||||
echo -n "build cfs-snapshot "
|
||||
go build $MODFLAGS -ldflags "${LDFlags}" -o ${BuildBinPath}/cfs-snapshot ${SrcPath}/snapshot/*.go && echo "success" || echo "failed"
|
||||
@ -414,7 +413,33 @@ elif [ "${cmd}" == "clean" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
pre_build
|
||||
get_cpu_cores() {
|
||||
cores=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||
return $cores
|
||||
}
|
||||
|
||||
threads=0
|
||||
for para in $*
|
||||
do
|
||||
check=`echo $para | grep "^--threads=" | wc -l`
|
||||
if test $check -eq 1
|
||||
then
|
||||
check=`echo "$para" | grep "^--threads=[0-9]*[^0-9]\{1,\}" | wc -l`
|
||||
if test $check -eq 0
|
||||
then
|
||||
threads=`echo "$para" | grep -o "[0-9]\{1,\}"`
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if test $threads -eq 0
|
||||
then
|
||||
get_cpu_cores
|
||||
threads=`expr $? + 1`
|
||||
threads=`expr $threads / 2`
|
||||
fi
|
||||
|
||||
pre_build $threads
|
||||
|
||||
case "$cmd" in
|
||||
"all")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user