forked from openthread/ot-qorvo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·108 lines (90 loc) · 3.54 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
#!/bin/bash
#
# Copyright (c) 2021, 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:-}
QORVO_PLATFORMS=(gp712 qpg6105 qpg7015m)
readonly QORVO_PLATFORMS
OT_SRCDIR="$(pwd)"
readonly OT_SRCDIR
OT_OPTIONS=(
"-DCMAKE_BUILD_TYPE=MinSizeRel"
"-DOT_PLATFORM=external"
"-DOT_SLAAC=ON"
)
readonly OT_OPTIONS
die()
{
echo " ** ERROR: $1"
exit 1
}
build()
{
builddir="${OT_CMAKE_BUILD_DIR:-build}"
mkdir -p "${builddir}"
cd "${builddir}"
cmake -GNinja -DOT_COMPILE_WARNING_AS_ERROR=ON "$@" "${OT_SRCDIR}"
if [[ -n ${OT_CMAKE_NINJA_TARGET[*]} ]]; then
ninja "${OT_CMAKE_NINJA_TARGET[@]}"
else
ninja
fi
cd "${OT_SRCDIR}"
}
main()
{
if [[ $# == 0 ]]; then
echo "Please specify a platform: ${QORVO_PLATFORMS[*]}"
exit 1
fi
local platform="$1"
echo "${QORVO_PLATFORMS[@]}" | grep -wq "${platform}" || die "Unsupported platform ${platform}"
shift
local options=("${OT_OPTIONS[@]}")
local cmdline_options=("$@")
case "${platform}" in
gp712 | qpg7015m)
OT_CMAKE_NINJA_TARGET=("ot-rcp" "ot-cli-ftd" "ot-cli-mtd")
options+=("-DCMAKE_TOOLCHAIN_FILE=src/${platform}/arm-linux-gnueabihf.cmake")
;;
qpg6105)
OT_CMAKE_NINJA_TARGET=("ot-cli-ftd" "ot-cli-mtd")
options+=("-DCMAKE_TOOLCHAIN_FILE=src/${platform}/arm-none-eabi.cmake")
;;
esac
build -DQORVO_PLATFORM="${platform}" "${options[@]}" "${cmdline_options[@]}"
case "${platform}" in
qpg6105)
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" -not -name "*-test-*" \
-execdir sh -c 'x="$1"; arm-none-eabi-objcopy -O ihex "$1" "$2-$(basename ${x}).hex"' _ {} "${platform}" \;
;;
esac
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" -not -name "*-test-*" \
-execdir sh -c 'x="$1"; mv "$x" "$2-$(basename ${x}).elf"' _ {} "${platform}" \;
}
main "$@"