forked from fibjs/fibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·98 lines (85 loc) · 1.66 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
usage()
{
echo ""
echo "Usage: `basename $0` <Release | Release32 | Debug | Debug32 | clean> [-jn] [-v]"
echo " -j: enable make '-j' option."
echo " if 'n' is not given, will set jobs to auto detected core count, otherwise n is used."
echo " -v: verbose make"
echo ""
exit 0
}
inform()
{
echo ""
echo "submodule vender is not existed!"
echo "you can execute the given command to init and update it."
echo " \$ git submodule init"
echo " \$ git submodule update"
echo ""
exit 0
}
BUILD_TYPE=$1; shift 1;
if [ "$BUILD_TYPE" = "" ]; then
usage
fi
if [ $BUILD_TYPE != 'Release' ] && [ $BUILD_TYPE != 'Release32' ] && [ $BUILD_TYPE != 'Debug' ] && [ $BUILD_TYPE != 'Debug32' ] && [ $BUILD_TYPE != 'clean' ]; then
usage
fi
for i in "$@"
do
case $i in
-j*) ENABLE_JOBS=1; BUILD_JOBS="${i#-j}"
;;
-v) BUILD_VERBOSE='VERBOSE=1'
;;
*) usage
;;
esac
done
if [ "$ENABLE_JOBS" = "1" -a "$BUILD_JOBS" = "" ]; then
#get cpu core count
OS=$(uname)
CPU_CORE=1
case ${OS} in
Darwin)
CPU_CORE=$(sysctl hw.ncpu | awk '{print $2}')
;;
Linux)
CPU_CORE=$(cat /proc/cpuinfo | grep processor | wc -l)
;;
Windows)
CPU_CORE=$(echo $NUMBER_OF_PROCESSORS)
;;
esac
echo "host machine has ${CPU_CORE} core"
if [ "$CPU_CORE" = "1" ]; then
BUILD_JOBS=""
else
# set build jobs with cpu core count
BUILD_JOBS=${CPU_CORE}
fi
fi
export BUILD_JOBS
export BUILD_VERBOSE
if [ -d vender ]; then
cd vender
sh build $BUILD_TYPE
if [ $? != 0 ]; then
exit 1
fi
cd ..
else
inform
fi
cd fibjs
sh build $BUILD_TYPE
if [ $? != 0 ]; then
exit 1
fi
cd ..
if [ "$BUILD_TYPE" = "clean" ]; then
if [ -e "bin" ]; then
rm -rf "bin"
fi
fi