Repository navigation
scripts: build-tools.sh: Make tools individually buildable #3064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,69 +5,126 @@ | |
| # fail immediately on any errors | ||
| set -e | ||
|
|
||
|
|
||
| print_usage() | ||
| { | ||
| cat <<EOFUSAGE | ||
| usage: $0 [-t|-f] | ||
| [-t] Build test topologies | ||
| [-f] Build fuzzer" | ||
| usage: $0 [-c|-f|-h|-l|-p|-t|-T] | ||
| -c Rebuild ctl | ||
| -f Rebuild fuzzer | ||
| -h Display help | ||
| -l Rebuild logger | ||
| -p Rebuild probes | ||
| -t Rebuild test topologies | ||
| -T Rebuild topologies | ||
| -C No build, only CMake re-configuration | ||
| EOFUSAGE | ||
| } | ||
|
|
||
|
crazoes marked this conversation as resolved.
Resolved
|
||
| build_tools() | ||
| # generate Makefiles | ||
| reconfigure_build() | ||
| { | ||
| cd "$SOF_REPO/tools" | ||
| rm -rf build_tools | ||
| mkdir build_tools | ||
| cd build_tools | ||
| rm -rf "$BUILD_TOOLS_DIR" | ||
| mkdir "$BUILD_TOOLS_DIR" | ||
|
|
||
| cd "$BUILD_TOOLS_DIR" | ||
| cmake .. | ||
| make -j "$NO_PROCESSORS" | ||
|
|
||
| mkdir "$BUILD_TOOLS_DIR/fuzzer" | ||
| cd "$BUILD_TOOLS_DIR/fuzzer" | ||
| cmake ../../fuzzer | ||
| } | ||
|
|
||
| build_test() | ||
| make_tool() | ||
| { | ||
| cd "$SOF_REPO/tools/build_tools" | ||
| make tests -j "$NO_PROCESSORS" | ||
| # if no argument provided, all the tools will be built. Empty tool is | ||
| # okay. | ||
| tool=$1 | ||
| make -C "$BUILD_TOOLS_DIR" -j "$NO_PROCESSORS" $tool | ||
| } | ||
|
|
||
| build_fuzzer() | ||
| make_fuzzer() | ||
| { | ||
| cd "$SOF_REPO/tools/build_tools" | ||
| mkdir build_fuzzer | ||
| cd build_fuzzer | ||
| cmake ../../fuzzer | ||
| make -j "$NO_PROCESSORS" | ||
| make -C "$BUILD_TOOLS_DIR/fuzzer" -j "$NO_PROCESSORS" | ||
| } | ||
|
|
||
| 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 | ||
| tests: make -C "$BUILD_TOOLS_DIR" tests | ||
| topologies: make -C "$BUILD_TOOLS_DIR" topologies | ||
| fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer" | ||
| EOFUSAGE | ||
| } | ||
|
|
||
| main() | ||
| { | ||
| local DO_BUILD_TEST DO_BUILD_FUZZER SCRIPT_DIR SOF_REPO | ||
| local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \ | ||
| DO_BUILD_test DO_BUILD_topology 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move this zero arg test after flags have been removed below, so it's ready for adding a flag that would affects all builds in the future?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we move this zero arg test below getopts, we shift everything by then and it will always be 0. Everything gets parsed and no way to know if any arguments were provided(build specific things) or none were provided(build everything).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, sorry. So I guess this would requires something like this instead: BUILD_ALL=true
while getopt
c) DO_BUILD_ctl=true; BUILD_ALL=false ;;
f) DO_BUILD_fuzzer=true; BUILD_ALL=false ;;Let's worry about that when the time comes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and I was trying to avoid not having to set |
||
|
|
||
| DO_BUILD_TEST=false | ||
| DO_BUILD_FUZZER=false | ||
| while getopts "tf" OPTION; do | ||
| 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 | ||
|
|
||
| while getopts "cfhlptTC" OPTION; do | ||
| case "$OPTION" in | ||
| t) DO_BUILD_TEST=true ;; | ||
| f) DO_BUILD_FUZZER=true ;; | ||
| 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;; | ||
| *) print_usage; exit 1;; | ||
| esac | ||
| done | ||
| shift "$(($OPTIND - 1))" | ||
| reconfigure_build | ||
|
|
||
| build_tools | ||
| if "$CMAKE_ONLY"; then | ||
| print_build_info | ||
|
crazoes marked this conversation as resolved.
Resolved
|
||
| exit | ||
| fi | ||
|
|
||
| if "$DO_BUILD_TEST" | ||
| then | ||
| build_test | ||
| if "$BUILD_ALL"; then | ||
| make_tool | ||
| make_fuzzer | ||
| exit | ||
| fi | ||
|
|
||
| if "$DO_BUILD_FUZZER" | ||
| then | ||
| build_fuzzer | ||
| for tool in ctl logger probes; do | ||
| if eval '$DO_BUILD_'$tool; then | ||
| make_tool sof-$tool | ||
| fi | ||
| done | ||
|
|
||
| for util in tests topologies; do | ||
| if eval '$DO_BUILD_'$util; then | ||
| make_tool $util | ||
| fi | ||
| done | ||
|
|
||
| if "$DO_BUILD_fuzzer"; then | ||
| make_fuzzer | ||
| fi | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.