forked from fibjs/fibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·153 lines (140 loc) · 2.75 KB
/
Copy pathbuild
File metadata and controls
executable file
·153 lines (140 loc) · 2.75 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
usage()
{
echo ""
echo "Usage: `basename $0` [release | debug | i386 | amd64 | arm | arm64 | clean] [-jn] [-v] [-h]"
echo "Options:"
echo " release, debug: "
echo " Specifies the build type."
echo " i386, amd64, arm, arm64:"
echo " Specifies the architecture for code generation."
echo " clean: "
echo " Clean the build folder."
echo " -h, --help:"
echo " Print this message and exit."
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
}
HOST_OS=`uname`
HOST_ARCH=`uname -m`
case ${HOST_ARCH} in
x86_64) HOST_ARCH="amd64"
;;
armv6|armv7|armv7s|armv7l) HOST_ARCH="arm"
;;
aarch64) HOST_ARCH="arm64"
;;
esac
TARGET_OS=$HOST_OS
TARGET_ARCH=$HOST_ARCH
BUILD_TYPE="release"
BUILD_PREFIX=""
BUILD_OPTION=""
for i in "$@"
do
case $i in
i386|amd64|arm|arm64) TARGET_ARCH=$i
;;
release|debug|clean) BUILD_TYPE=$i
;;
-j*) ENABLE_JOBS=1; BUILD_JOBS="${i#-j}"
;;
-v) BUILD_VERBOSE='VERBOSE=1'
;;
--help|-h) usage
;;
*) echo "illegal option $i"
usage
;;
esac
done
if [ $TARGET_ARCH != $HOST_ARCH ] || [ $TARGET_OS != $HOST_OS ]; then
case $TARGET_ARCH in
i386)
if [ $HOST_ARCH = "amd64" ]; then
BUILD_OPTION="-m32"
else
usage
fi
;;
amd64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="x86_64-linux-gnu-"
else
usage
fi
;;
arm)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="arm-linux-gnueabihf-"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3"
else
usage
fi
;;
arm64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="aarch64-linux-gnu-"
else
usage
fi
;;
esac
fi
if [ "$BUILD_PREFIX" != "" ]; then
export CC=${BUILD_PREFIX}gcc
export CXX=${BUILD_PREFIX}g++
fi
if [ "$ENABLE_JOBS" = "1" -a "$BUILD_JOBS" = "" ]; then
#get cpu core count
CPU_CORE=1
case ${HOST_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 $TARGET_ARCH
if [ $? != 0 ]; then
exit 1
fi
cd ..
else
inform
fi
cd fibjs
sh build $BUILD_TYPE $TARGET_ARCH
if [ $? != 0 ]; then
exit 1
fi
cd ..