-
Notifications
You must be signed in to change notification settings - Fork 8
/
build
executable file
·181 lines (159 loc) · 5.73 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
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
#!/bin/bash
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set -euxo pipefail
OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
TI_SYSCONFIG_ROOT=${TI_SYSCONFIG_ROOT:-}
SYSCONFIG_VERSION=sysconfig_1.18.1
SYSCONFIG_USER=~/ti/${SYSCONFIG_VERSION}/
SYSCONFIG_SYSTEM=/opt/ti/${SYSCONFIG_VERSION}/
CMAKE=${CMAKE:-cmake}
GCC_ARMCOMPILER=${GCC_ARMCOMPILER:-/opt/gcc-arm-none-eabi-9-2020-q2-update}
TICLANG_ARMCOMPILER=${TICLANG_ARMCOMPILER:-""}
IAR_ARMCOMPILER=${IAR_ARMCOMPILER:-""}
if [ -z "$TI_SYSCONFIG_ROOT" ]; then
if [ -d "$SYSCONFIG_USER" ]; then
TI_SYSCONFIG_ROOT="$SYSCONFIG_USER"
elif [ -d "$SYSCONFIG_SYSTEM" ]; then
TI_SYSCONFIG_ROOT="$SYSCONFIG_SYSTEM"
fi
fi
readonly TI_LAUNCHPAD=(
CC1352P1_LAUNCHXL
CC1352P_2_LAUNCHXL
CC1352P_4_LAUNCHXL
CC1352R1_LAUNCHXL
CC26X2R1_LAUNCHXL
LP_CC1352P7_1
LP_CC1352P7_4
LP_CC2652PSIP
LP_CC2652R7
LP_CC2652RB
LP_CC2652RSIP
LP_EM_CC1354P10_1
LP_EM_CC1354P10_6
LP_CC2653P10
CC2674P10RGZ
CC2674P10RSK
CC2674R10RGZ
CC2674R10RSK
)
readonly OT_SRCDIR="$(pwd)"
readonly OT_OPTIONS=(
"-DOT_PLATFORM=external"
)
build()
{
local builddir="${OT_CMAKE_BUILD_DIR:-build}"
# the SimpleLink SDK uses normal 'make' to re-build it's libraries
make \
-C third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx \
CMAKE=${CMAKE} \
GCC_ARMCOMPILER=${GCC_ARMCOMPILER} \
IAR_ARMCOMPILER=${IAR_ARMCOMPILER} \
TICLANG_ARMCOMPILER=${TICLANG_ARMCOMPILER} \
GENERATOR=Ninja
${CMAKE} -GNinja -DOT_COMPILE_WARNING_AS_ERROR=ON "$@" "${OT_SRCDIR}" -B ${builddir}
if [[ -n ${OT_CMAKE_NINJA_TARGET[*]} ]]; then
${CMAKE} --build ${builddir} "${OT_CMAKE_NINJA_TARGET[@]}"
else
${CMAKE} --build ${builddir}
fi
if [[ ${ot_reference_release} == true ]]; then
cd ${builddir}/bin
for exe in *.out; do
cp -- "${exe}" "${exe%.out}"
done
fi
cd "${OT_SRCDIR}"
}
main()
{
local usage="usage: $0 [-h] <TI LaunchPad> [-D<OT_XXXX=ON> -D<OT_YYYY=OFF>]"
local ot_reference_release=false
# Parse flags
optspec=":h-:"
while getopts "$optspec" optchar; do
case "${optchar}" in
-)
case "${OPTARG}" in
ot-reference-release)
# The ot-reference-release repository expects the executables produced by this build to have
# no file endings. We do not make this the default behavior because file extensions make using
# UniFlash easier.
printf '\n\nProducing executables for ot-reference-release...\n\n' >&2
ot_reference_release=true
shift 1
;;
*)
echo "Unknown option --${OPTARG}" >&2
exit 2
;;
esac
;;
h)
echo "${usage}" >&2
exit 2
;;
esac
done
if [[ $# == 0 ]]; then
echo "Please specify a LaunchPad: ${TI_LAUNCHPAD[*]}"
exit 1
fi
local options=("${OT_OPTIONS[@]}")
local launchpad="$1"
echo "${TI_LAUNCHPAD[@]}" | grep -wq "${launchpad}" || die "Unsupported launchpad ${launchpad}"
case "${launchpad}" in
CC1352P1_LAUNCHXL | \
CC1352P_2_LAUNCHXL | \
CC1352P_4_LAUNCHXL | \
CC1352R1_LAUNCHXL | \
CC26X2R1_LAUNCHXL | \
LP_CC1352P7_1 | \
LP_CC1352P7_4 | \
LP_CC2652PSIP | \
LP_CC2652R7 | \
LP_CC2652RB | \
LP_CC2652RSIP)
options+=("-DCMAKE_TOOLCHAIN_FILE=src/arm-none-eabi-m4f.cmake")
;;
LP_EM_CC1354P10_1 | \
LP_EM_CC1354P10_6 | \
LP_CC2653P10 | \
CC2674P10RGZ | \
CC2674P10RSK | \
CC2674R10RGZ | \
CC2674R10RSK)
options+=("-DCMAKE_TOOLCHAIN_FILE=src/arm-none-eabi-m33.cmake")
;;
esac
options+=("$@")
build -DTI_SIMPLELINK_BOARD=${launchpad} "${options[@]}"
}
main "$@"