-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathbuild-tools.sh
More file actions
executable file
·180 lines (146 loc) · 4.91 KB
/
build-tools.sh
File metadata and controls
executable file
·180 lines (146 loc) · 4.91 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
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
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation. All rights reserved.
# fail immediately on any errors
set -e
SOF_TOP=$(cd "$(dirname "$0")/.." && pwd)
print_usage()
{
cat <<EOFUSAGE
Configures and builds selected CMake projects in the tools/ directory.
Attention: the list of selected shortcuts below is _not_ exhaustive. To
build _everything_ don't select any particular target; this will build
CMake's default target "ALL".
usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A]
-h Display help
-c Rebuild ctl/
-l Rebuild logger/
-p Rebuild probes/
-T Rebuild topology/ (not topology/development/! Use ALL)
-X Rebuild topology1 only
-Y Rebuild topology2 only
-t Rebuild test/topology/ (or tools/test/topology/tplg-build.sh directly)
-A Clone and rebuild local ALSA lib and utils.
-C No build, only CMake re-configuration. Shows CMake targets.
EOFUSAGE
warn_if_incremental_build
}
# generate Makefiles
reconfigure_build()
{
rm -rf "$BUILD_TOOLS_DIR"
mkdir -p "$BUILD_TOOLS_DIR"
( cd "$BUILD_TOOLS_DIR"
cmake -GNinja -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
)
}
make_tool()
{
# if no argument provided, all the tools will be built. Empty tool is
# okay.
tool=$1
( set -x
# shellcheck disable=SC2086
cmake --build $BUILD_TOOLS_DIR -- -j "$NO_PROCESSORS" $tool
)
}
print_build_info()
{
cat <<EOFUSAGE
Build commands for respective tools:
ctl: ninja -C "$BUILD_TOOLS_DIR" sof-ctl
logger: ninja -C "$BUILD_TOOLS_DIR" sof-logger
probes: ninja -C "$BUILD_TOOLS_DIR" sof-probes
topologies: ninja -C "$BUILD_TOOLS_DIR" topologies
topologies1: ninja -C "$BUILD_TOOLS_DIR" topologies1
topologies2: ninja -C "$BUILD_TOOLS_DIR" topologies2
test tplgs: ninja -C "$BUILD_TOOLS_DIR" tests
(or ./tools/test/topology/tplg-build.sh directly)
list of targets:
ninja -C "$BUILD_TOOLS_DIR/" help
EOFUSAGE
warn_if_incremental_build
}
warn_if_incremental_build()
{
$warn_incremental_build || return 0
cat <<EOF
WARNING: building tools/ is now incremental by default!
To build from scratch delete: $BUILD_TOOLS_DIR
or use the -C option.
EOF
}
main()
{
local DO_BUILD_ctl DO_BUILD_logger DO_BUILD_probes \
DO_BUILD_tests DO_BUILD_topologies1 DO_BUILD_topologies2 SCRIPT_DIR SOF_REPO \
CMAKE_ONLY BUILD_ALL
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SOF_REPO=$(dirname "$SCRIPT_DIR")
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
: "${NO_PROCESSORS:=$(nproc)}"
BUILD_ALL=false
if [ $# -eq 0 ]; then
BUILD_ALL=true
fi
DO_BUILD_ctl=false
DO_BUILD_alsa=false
DO_BUILD_logger=false
DO_BUILD_probes=false
DO_BUILD_tests=false
DO_BUILD_topologies1=false
DO_BUILD_topologies2=false
CMAKE_ONLY=false
# better safe than sorry
local warn_incremental_build=true
# eval is a sometimes necessary evil
# shellcheck disable=SC2034
while getopts "cfhlptTCXYA" OPTION; do
case "$OPTION" in
c) DO_BUILD_ctl=true ;;
l) DO_BUILD_logger=true ;;
p) DO_BUILD_probes=true ;;
t) DO_BUILD_tests=true ;;
T) DO_BUILD_topologies1=true ; DO_BUILD_topologies2=true ;;
X) DO_BUILD_topologies1=true ;;
Y) DO_BUILD_topologies2=true ;;
C) CMAKE_ONLY=true ;;
A) DO_BUILD_alsa=true ;;
h) print_usage; exit 1;;
*) print_usage; exit 1;;
esac
done
shift "$((OPTIND - 1))"
if "$DO_BUILD_alsa"; then
$SOF_TOP/scripts/build-alsa-tools.sh
fi
if "$CMAKE_ONLY"; then
reconfigure_build
print_build_info
exit
fi
test -e "$BUILD_TOOLS_DIR"/build.ninja ||
test -e "$BUILD_TOOLS_DIR"/Makefile || {
warn_incremental_build=false
reconfigure_build
}
if "$BUILD_ALL"; then
# default CMake targets
make_tool # trust set -e
warn_if_incremental_build
exit 0
fi
# Keep 'topologies' first because it's the noisiest.
for util in topologies1 topologies2 tests; do
if eval '$DO_BUILD_'$util; then
make_tool $util
fi
done
for tool in ctl logger probes; do
if eval '$DO_BUILD_'$tool; then
make_tool sof-$tool
fi
done
warn_if_incremental_build
}
main "$@"