2018-12-03 16:02:54 +08:00
|
|
|
#!/bin/bash
|
2019-06-02 04:58:16 +08:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2018 Intel Corporation. All rights reserved.
|
2019-04-08 09:20:04 +08:00
|
|
|
|
|
|
|
# fail immediately on any errors
|
|
|
|
set -e
|
|
|
|
|
2020-03-28 16:04:28 +08:00
|
|
|
print_usage()
|
|
|
|
{
|
|
|
|
cat <<EOFUSAGE
|
2021-05-19 06:11:36 +08:00
|
|
|
Deletes and re-builds from scratch CMake projects in the tools/
|
|
|
|
directory.
|
|
|
|
Attention: the list below is _not_ exhaustive. To re-build _everything_
|
|
|
|
from scratch don't select any particular target; this will build the
|
|
|
|
CMake's default target "ALL".
|
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
usage: $0 [-c|-f|-h|-l|-p|-t|-T]
|
|
|
|
-h Display help
|
2021-05-19 06:11:36 +08:00
|
|
|
|
|
|
|
-c Rebuild ctl/
|
2021-05-22 02:22:06 +08:00
|
|
|
-f Rebuild fuzzer/ # deprecated, see fuzzer/README.md
|
2021-05-19 06:11:36 +08:00
|
|
|
-l Rebuild logger/
|
|
|
|
-p Rebuild probes/
|
|
|
|
-T Rebuild topology/ (not topology/development/! Use ALL)
|
|
|
|
-t Rebuild test/topology/
|
|
|
|
|
|
|
|
-C No build, only CMake re-configuration. Shows CMake targets.
|
2020-03-28 16:04:28 +08:00
|
|
|
EOFUSAGE
|
|
|
|
}
|
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
# generate Makefiles
|
|
|
|
reconfigure_build()
|
2020-03-28 16:04:28 +08:00
|
|
|
{
|
2020-06-18 14:14:48 +08:00
|
|
|
rm -rf "$BUILD_TOOLS_DIR"
|
2021-02-20 09:24:04 +08:00
|
|
|
mkdir -p "$BUILD_TOOLS_DIR"
|
2020-06-18 14:14:48 +08:00
|
|
|
|
2021-02-20 09:24:04 +08:00
|
|
|
( cd "$BUILD_TOOLS_DIR"
|
|
|
|
cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
|
|
|
|
)
|
2020-06-18 14:14:48 +08:00
|
|
|
|
|
|
|
mkdir "$BUILD_TOOLS_DIR/fuzzer"
|
2021-02-20 09:24:04 +08:00
|
|
|
( cd "$BUILD_TOOLS_DIR/fuzzer"
|
|
|
|
cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools/fuzzer"
|
|
|
|
)
|
2020-03-28 16:04:28 +08:00
|
|
|
}
|
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
make_tool()
|
2020-03-28 16:04:28 +08:00
|
|
|
{
|
2020-06-18 14:14:48 +08:00
|
|
|
# if no argument provided, all the tools will be built. Empty tool is
|
|
|
|
# okay.
|
|
|
|
tool=$1
|
2020-09-16 02:21:55 +08:00
|
|
|
|
2021-05-19 06:11:36 +08:00
|
|
|
( set -x
|
2021-01-14 10:12:39 +08:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
cmake --build $BUILD_TOOLS_DIR -- -j "$NO_PROCESSORS" $tool
|
2021-05-19 06:11:36 +08:00
|
|
|
)
|
2020-03-28 16:04:28 +08:00
|
|
|
}
|
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
make_fuzzer()
|
2020-03-28 16:04:28 +08:00
|
|
|
{
|
2021-05-19 06:11:36 +08:00
|
|
|
( set -x
|
2021-01-14 10:12:39 +08:00
|
|
|
cmake --build "$BUILD_TOOLS_DIR"/fuzzer -- -j "$NO_PROCESSORS"
|
2021-05-19 06:11:36 +08:00
|
|
|
)
|
2020-06-18 14:14:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
print_build_info()
|
|
|
|
{
|
|
|
|
cat <<EOFUSAGE
|
|
|
|
|
|
|
|
Build commands for respective tools:
|
|
|
|
ctl: make -C "$BUILD_TOOLS_DIR" sof-ctl
|
|
|
|
logger: make -C "$BUILD_TOOLS_DIR" sof-logger
|
|
|
|
probes: make -C "$BUILD_TOOLS_DIR" sof-probes
|
|
|
|
topologies: make -C "$BUILD_TOOLS_DIR" topologies
|
2021-03-23 04:52:31 +08:00
|
|
|
test tplgs: make -C "$BUILD_TOOLS_DIR" tests
|
2021-05-19 06:11:36 +08:00
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer"
|
2021-05-19 06:11:36 +08:00
|
|
|
|
|
|
|
list of targets:
|
|
|
|
make -C "$BUILD_TOOLS_DIR/" help
|
2020-06-18 14:14:48 +08:00
|
|
|
EOFUSAGE
|
2020-03-28 16:04:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
2020-06-18 14:14:48 +08:00
|
|
|
local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \
|
2020-08-29 02:02:03 +08:00
|
|
|
DO_BUILD_tests DO_BUILD_topologies SCRIPT_DIR SOF_REPO CMAKE_ONLY \
|
2020-06-18 14:14:48 +08:00
|
|
|
BUILD_ALL
|
2020-03-28 16:04:28 +08:00
|
|
|
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
SOF_REPO=$(dirname "$SCRIPT_DIR")
|
2021-02-20 09:24:04 +08:00
|
|
|
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
|
2020-08-29 01:59:17 +08:00
|
|
|
: "${NO_PROCESSORS:=$(nproc)}"
|
2020-06-18 14:14:48 +08:00
|
|
|
BUILD_ALL=false
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
BUILD_ALL=true
|
|
|
|
fi
|
2020-03-28 16:04:28 +08:00
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
DO_BUILD_ctl=false
|
|
|
|
DO_BUILD_fuzzer=false
|
|
|
|
DO_BUILD_logger=false
|
|
|
|
DO_BUILD_probes=false
|
|
|
|
DO_BUILD_tests=false
|
|
|
|
DO_BUILD_topologies=false
|
|
|
|
CMAKE_ONLY=false
|
|
|
|
|
2020-08-29 01:59:17 +08:00
|
|
|
# eval is a sometimes necessary evil
|
|
|
|
# shellcheck disable=SC2034
|
2020-06-18 14:14:48 +08:00
|
|
|
while getopts "cfhlptTC" OPTION; do
|
2020-03-28 16:04:28 +08:00
|
|
|
case "$OPTION" in
|
2020-06-18 14:14:48 +08:00
|
|
|
c) DO_BUILD_ctl=true ;;
|
|
|
|
f) DO_BUILD_fuzzer=true ;;
|
|
|
|
l) DO_BUILD_logger=true ;;
|
|
|
|
p) DO_BUILD_probes=true ;;
|
|
|
|
t) DO_BUILD_tests=true ;;
|
|
|
|
T) DO_BUILD_topologies=true ;;
|
|
|
|
C) CMAKE_ONLY=true ;;
|
|
|
|
h) print_usage; exit 1;;
|
2020-03-28 16:04:28 +08:00
|
|
|
*) print_usage; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
2020-08-29 01:59:17 +08:00
|
|
|
shift "$((OPTIND - 1))"
|
2020-06-18 14:14:48 +08:00
|
|
|
reconfigure_build
|
2020-03-28 16:04:28 +08:00
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
if "$CMAKE_ONLY"; then
|
|
|
|
print_build_info
|
|
|
|
exit
|
|
|
|
fi
|
2020-03-28 16:04:28 +08:00
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
if "$BUILD_ALL"; then
|
2021-05-19 06:11:36 +08:00
|
|
|
# default CMake targets
|
|
|
|
make_tool # trust set -e
|
|
|
|
|
2020-06-18 14:14:48 +08:00
|
|
|
make_fuzzer
|
2021-05-19 06:11:36 +08:00
|
|
|
exit $?
|
2020-03-28 16:04:28 +08:00
|
|
|
fi
|
|
|
|
|
2021-05-19 06:11:36 +08:00
|
|
|
# Keep 'topologies' first because it's the noisiest.
|
|
|
|
for util in topologies tests; do
|
|
|
|
if eval '$DO_BUILD_'$util; then
|
|
|
|
make_tool $util
|
2020-06-18 14:14:48 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2021-05-19 06:11:36 +08:00
|
|
|
for tool in ctl logger probes; do
|
|
|
|
if eval '$DO_BUILD_'$tool; then
|
|
|
|
make_tool sof-$tool
|
2020-06-18 14:14:48 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if "$DO_BUILD_fuzzer"; then
|
|
|
|
make_fuzzer
|
2020-03-28 16:04:28 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|