aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/meta-zephyr-sdk-build.sh
blob: eb957ad7cfa90a71a8c3cfa05a4a0be7ec7e302f (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
#
# Copyright (C) 2015-2016, Intel Corporation.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#


curdir=$(pwd)
mkdir -p downloads
export DL_DIR=$curdir/downloads

TOOLCHAINS=$curdir/poky/meta-zephyr-sdk/scripts/toolchains

if [ ! -d $TOOLCHAINS ] ; then
	mkdir -p $TOOLCHAINS
fi

rm -rf $TOOLCHAINS/*

cd poky

# setconf_var, i.e. "MACHINE","qemuarm",$localconf
setconf_var()
{
	sed -i "/^$1=/d" $3
	echo "$1=\"$2\"" >> $3
	echo $1="$2"
}

header ()
{
echo ""
echo "########################################################################"
echo "    $1"
echo "########################################################################"
}

newbuild()
{
	cd $curdir/poky
	source oe-init-build-env $1

	# Create bblayers.conf
	bblayers=conf/bblayers.conf

	echo "# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf" > $bblayers
	echo "# changes incompatibly" >> $bblayers
	echo "LCONF_VERSION = \"6\"" >> $bblayers
	echo "" >> $bblayers
	echo "BBPATH = \"\${TOPDIR}\"" >> $bblayers
	echo "BBFILES ?= \"\"" >> $bblayers
	echo "BBLAYERS ?= \" \\" >> $bblayers
	echo "  $curdir/poky/meta \\" >> $bblayers
	echo "  $curdir/poky/meta-yocto \\" >> $bblayers
	echo "  $curdir/poky/meta-yocto-bsp \\" >> $bblayers
	echo "  $curdir/poky/meta-crops \\" >> $bblayers
	echo "  $curdir/poky/meta-zephyr-sdk \\" >> $bblayers
	echo "  \" " >> $bblayers
	echo "BBLAYERS_NON_REMOVABLE ?= \" \\" >> $bblayers
	echo "  $curdir/poky/meta \\" >> $bblayers
	echo "  $curdir/poky/meta-yocto \\" >> $bblayers
	echo "  \" " >> $bblayers

	# Common values for all builds
	localconf=conf/local.conf
	setconf_var "DL_DIR" "$curdir/downloads" $localconf
	setconf_var "SDKMACHINE" "i686" $localconf
	setconf_var "DISTRO" "zephyr-sdk" $localconf
	if [ -z ${SSTATE_MIRROR_URI+x} ]; then
		setconf_var "SSTATE_MIRRORS" "file://.* $SSTATE_MIRROR_URI/PATH" $localconf
	fi
}

##############################################################################
# 32 bit build
##############################################################################
header "Building Zephyr host tools..."
newbuild build-zephyr-tools  > /dev/null
setconf_var "MACHINE" "qemux86" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake hosttools-tarball -c clean  > /dev/null
bitbake hosttools-tarball
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
echo "Building additional host tools...done"

# build NIOS2 toolchain
header "Building Nios2 toolchain..."
newbuild build-zephyr-nios2  > /dev/null
setconf_var "MACHINE" "nios2" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building Nios2 toolchain...done"

# build ARM toolchain
header "Building ARM toolchain..."
newbuild build-zephyr-arm  > /dev/null
setconf_var "MACHINE" "qemuarm" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
setconf_var "TUNE_FEATURES" "armv7m cortexm3" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building ARM toolchain...done"

# build x86 toolchain
header "Building x86 toolchain..."
newbuild build-zephyr-x86 > /dev/null
setconf_var "MACHINE" "qemux86" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building x86 toolchain...done"

#  build MIPS toolchain
header "Building MIPS toolchain..."
newbuild build-zephyr-mips  > /dev/null
setconf_var "MACHINE" "qemumips" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building MIPS toolchain...done"

# build ARC toolchain...
header "Building ARC toolchain..."
newbuild build-zephyr-arc  > /dev/null
setconf_var "MACHINE" "arc" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building ARC toolchain...done"

#  build IAMCU toolchain
header "Building IAMCU  toolchain..."
newbuild build-zephyr-iamcu  > /dev/null
setconf_var "MACHINE" "iamcu" $localconf
setconf_var "TCLIBC" "baremetal" $localconf
setconf_var "TOOLCHAIN_TARGET_TASK_append" " newlib" $localconf
rm -f ./tmp/deploy/sdk/*.sh
bitbake meta-toolchain -c clean  > /dev/null
bitbake meta-toolchain
[ $? -ne 0 ] && echo "Error(s) encountered during bitbake." && exit 1
cp ./tmp/deploy/sdk/*.sh $TOOLCHAINS
[ $? -ne 0 ] && exit 1
header "Building IAMCU toolchain...done"

# Pack it together ...

cd $curdir/poky/meta-zephyr-sdk/scripts
header "Creating SDK..."
./make_zephyr_sdk.sh
[ $? -ne 0 ] && echo "Error(s) encountered during SDK creation." && exit 1