forked from zephyrproject-rtos/sdk-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go.sh
executable file
·122 lines (106 loc) · 2.84 KB
/
go.sh
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
#!/bin/bash
TARGETS=${@}
if [ -z "$TARGETS" ]; then
echo "Please specify target"
exit 1
fi
if [ "$TARGETS" == "all" ]; then
TARGETS=$(ls -1 configs/ | sed 's/.config//')
TARGETS=${TARGETS}" tools"
fi
COMMIT="37ee4b410c623620a0b151b270c070d6d1f6630f"
GITDIR=${PWD}
JOBS=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())')
unameOut="$(uname -s)"
unameMachine="$(uname -m)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ "$machine" == "Mac" ]; then
ImageName=CrossToolNGNew
ImageNameExt=${ImageName}.sparseimage
if [ ! -e "$ImageNameExt" ]; then
diskutil umount force /Volumes/${ImageName} && true
rm -f ${ImageNameExt} && true
hdiutil create ${ImageName} -volname ${ImageName} -type SPARSE -size 64g -fs HFSX
fi
if [ ! -d "/Volumes/$ImageName" ]; then
hdiutil mount ${ImageNameExt}
fi
cp -a patches /Volumes/$ImageName
cp -a patches-arc64 /Volumes/$ImageName
cp -a overlays /Volumes/$ImageName
cd /Volumes/$ImageName
fi
export SDK_NG_HOME=${PWD}
for t in ${TARGETS}; do
if [ "${t}" = "tools" ]; then
./meta-zephyr-sdk/scripts/meta-zephyr-sdk-clone.sh;
./meta-zephyr-sdk/scripts/meta-zephyr-sdk-build.sh tools;
mv ./meta-zephyr-sdk/scripts/toolchains/zephyr-sdk-${unameMachine}-hosttools-standalone-0.9.sh .
elif [ "${t}" = "cmake" ]; then
tar -jcvf ${t}.${unameMachine}.tar.bz2 -C ${GITDIR} cmake;
fi
done
if [ ! -d "crosstool-ng" ]; then
git clone https://github.com/zephyrproject-rtos/crosstool-ng.git
echo "Patching tree"
pushd crosstool-ng
git checkout ${COMMIT}
popd
fi
if [ ! -e "${SDK_NG_HOME}/bin/ct-ng" ]; then
pushd crosstool-ng
./bootstrap
CFLAGS="-DKBUILD_NO_NLS" ./configure --prefix=${SDK_NG_HOME}
make && make install
popd
fi
CT_NG=${SDK_NG_HOME}/bin/ct-ng
mkdir -p build
cd build
export OUTPUT_DIR=`pwd`/output
mkdir -p ${OUTPUT_DIR}/sources
for t in ${TARGETS}; do
if [ "${t}" = "tools" ]; then
# We handled tools above, so skip it here
continue
elif [ "${t}" = "cmake" ]; then
# We handled cmake above, so skip it here
continue
fi
if [ ! -f ${GITDIR}/configs/${t}.config ]; then
echo "Target configuration does not exist"
exit 1
fi
echo "Building ${t}"
mkdir -p build_${t}
pushd build_${t}
build_toolchain=1
if [ -n "${build_toolchain}" ]; then
case "${t}" in
xtensa_*)
cp -a ${SDK_NG_HOME}/overlays .
export CT_PREFIX=${OUTPUT_DIR}/xtensa/${t#xtensa_}
mkdir -p ${CT_PREFIX}
;;
*)
export CT_PREFIX=${OUTPUT_DIR}
;;
esac
${CT_NG} clean
${CT_NG} defconfig DEFCONFIG=${GITDIR}/configs/${t}.config
${CT_NG} savedefconfig DEFCONFIG=${t}.config
${CT_NG} build -j ${JOBS}
if [ $? != 0 ]; then
exit 1
fi
rm -rf ${CT_PREFIX}/*/newlib-nano
fi
popd
test -n ${DEBUG_BUILD} || rm -rf build_${t}
done