diff --git a/tools/resources/bake_tools.sh b/tools/resources/bake_tools.sh deleted file mode 100755 index 3541866f..00000000 --- a/tools/resources/bake_tools.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash - -# @file merge common helpers and script into a single script without dependencies -# -# -# - -set -e - -# find script resources directory -if [ -z "$TBD_PROJECT_DIR" ]; then - scripts_srcs_dir="$(realpath -- $(dirname -- ${BASH_SOURCE[0]}))" -else - scripts_srcs_dir="$TBD_PROJECT_DIR/tools/resources" -fi - -source "$scripts_srcs_dir/common_header.sh" - -# @brief parameter defaults -# -# -tbd_logging_tag="bake_tools" -script_files="$scripts_srcs_dir"/src/*.sh -process_only=false -header_file=$scripts_srcs_dir/common_header.sh - -# @brief parse command line options -# -# -parse_args() { - while [ $# -gt 0 ]; do - arg=$1 - - case $arg in - -o|--out-dir) - out_dir=$2 - shift - ;; - -p|--process-ony) - process_only=true - ;; - *) - break - ;; - esac - shift - done - - if [ $# -gt 0 ]; then - script_files=$@ - fi - - - if [ -z "$out_dir" ]; then - out_dir=$(dirname -- "$scripts_srcs_dir")/bin - fi -} - - -parse_args $@ - -tbd_logi "writing baked script files to $out_dir" - -if ! [ -d "$out_dir" ]; then - mkdir -p "$out_dir" -fi - -for script_file in $script_files; do - if ! [ -f "$script_file" ]; then - tbd_loge "$script_file: input file not found" - continue - fi - - # remove .sh extension from final tool name - out_file=$out_dir/$(basename -- ${script_file%.sh}) - - num_header_lines=$(awk '/-- END OF HEADER --/{ print NR; exit }' "$script_file") - if [ -z "$num_header_lines" ]; then - if $process_only; then - continue - fi - - if cp "$script_file" "$out_file"; then - tbd_logi "$script_file: copied" - else - tbd_loge "$script_file: failed to copy" - fi - else - if cat "$header_file" > "$out_file" \ - && tail -n +$num_header_lines "$script_file" >> $out_file - then - tbd_logi "$script_file: baked" - else - tbd_loge "$script_file: failed to bake" - fi - fi -done diff --git a/tools/resources/src/tbb.sh b/tools/resources/src/tbb.sh deleted file mode 100755 index fcebee38..00000000 --- a/tools/resources/src/tbb.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash - -resource_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) -source "$resource_path/common_header.sh" - -# -- END OF HEADER -- - -tbd_logging_tag="tbd build" - -comands= -tbd_cmd_verbosity=VERBOSE -build_dir=build - -# @brief parse command line options -# -# All options unknown to tbb are passed on to CMake -# -parse_args() { - while [ $# -gt 0 ]; do - arg=$1 - case $arg in - -p|--project-dir) - project_dir=$2 - shift - ;; - -b|--build-dir) - build_dir=$2 - shift - ;; - --silent) - tbd_cmd_verbosity="SILENT" - ;; - *) - break - ;; - esac - shift - done - - if [ $# -lt 1 ]; then - tbd_abort "no platform specified" - fi - platform=$1 - shift - - commands=$@ -} - -parse_args $@ - -if [ -z "$project_dir"]; then - project_dir=$(tbd_project_root) -fi - -if [ -z "$project_dir" ]; then - tbd_abort "could not find TBD project in path" -fi - -if ! tbd_is_project_root "$project_dir"; then - tbd_abort "not a valid project root: $project_dir" -fi - -if [ -z "$build_dir"]; then - tbd_abort "build directory not specified" -fi - -if ! tbd_is_valid_platform "$project_dir" "$platform"; then - tbd_abort "no such platform: $platform" -fi - -if ! tbd_ensure_idf; then - tbd_abort "failed to find ESP IDF" -fi - -# run commands in order - -pushd "$project_dir" - -if tbd_is_item_in_list "install" $commands; then - tbd_logi "installing dependencies" - tbd_loge "not implemented" -fi - -if tbd_is_item_in_list "configure" $commands; then - tbd_logi "configuring build" - tbd_run cmake -GNinja -B"$build_dir/$platform" -DTBD_PLATFORM="$platform" -fi - -if tbd_is_item_in_list "build" $commands; then - tbd_logi "building project" - tbd_run cmake --build "$build_dir/$platform" -fi - -if tbd_is_item_in_list "flash" $commands; then - tbd_logi "flashing to device" - tbd_loge "not implemented" -fi diff --git a/tools/resources/src/tbx.sh b/tools/resources/src/tbx.sh deleted file mode 100755 index d0e48c59..00000000 --- a/tools/resources/src/tbx.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set +e - -tbd_logging_tag=tbx - -load_includes() { - resource_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]}))/resources - source "$resource_path/helpers.sh" -} - -load_includes - -var=$(tbd_project_root) -echo $var diff --git a/tools/scripts/bake_tools.sh b/tools/scripts/bake_tools.sh new file mode 100755 index 00000000..e9545815 --- /dev/null +++ b/tools/scripts/bake_tools.sh @@ -0,0 +1,177 @@ +#!/usr/bin/env bash + +# @file merge common helpers and script into a single script without dependencies +# +# +# + +set +e + +# find script directory +if [ -z "$TBD_PROJECT_DIR" ]; then + scripts_srcs_dir="$(realpath -- $(dirname -- ${BASH_SOURCE[0]}))" +else + scripts_srcs_dir="$TBD_PROJECT_DIR/tools/scripts" +fi + +source "$scripts_srcs_dir/lib/common_header.sh" + +# @brief parameter defaults +# +# +tbd_logging_tag="bake_tools" +script_files="$scripts_srcs_dir"/src/*.sh +process_only=false +header_file=$scripts_srcs_dir/common_header.sh + +# @brief parse command line options +# +# +parse_args() { + local has_verbosity=false + + while [ $# -gt 0 ]; do + arg=$1 + + case $arg in + -o|--out-dir) + out_dir=$2 + shift + ;; + -vs|--silent) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -ve|--verrors) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -vw|--vwarnings) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -v|--vinfo) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=INFO + has_verbosity=true + ;; + -vv|--verbose) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=VERBOSE + has_verbosity=true + ;; + -vvv|--vdebug) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=DEBUG + has_verbosity=true + ;; + *) + break + ;; + esac + shift + done + + if [ $# -gt 0 ]; then + script_files=$@ + fi + + + if [ -z "$out_dir" ]; then + out_dir=$(dirname -- "$scripts_srcs_dir")/bin + fi +} + + +parse_args $@ + +tbd_logi "writing baked script files to $out_dir" + +if ! [ -d "$out_dir" ]; then + mkdir -p "$out_dir" +fi + +for script_file in $script_files; do + if ! [ -f "$script_file" ]; then + tbd_loge "$script_file: input file not found" + continue + fi + + # remove .sh extension from final tool name + out_file=$out_dir/$(basename -- ${script_file%.sh}) + + num_header_lines=$(awk '/-- END OF HEADER --/{ print NR; exit }' "$script_file") + if [ -z "$num_header_lines" ]; then + if $process_only; then + continue + fi + + if cp "$script_file" "$out_file"; then + tbd_logi "$script_file: copied" + else + tbd_loge "$script_file: failed to copy" + fi + else + sourced_scripts=() + + # expect first path component of source to be variable to scripts path + regex="^\\s*source\\s+\"?\\\$[a-z][a-zA-Z0-9_]+/(([a-z][a-zA-Z0-9_]*/)*[a-z][a-zA-Z0-9_]*.sh)\"?\\s*$" + header=$(head -n $num_header_lines "$script_file") + + # search for 'source' commands in header part of script + while read line; do + if [[ "$line" =~ $regex ]] + then + sourced_script="${BASH_REMATCH[1]}" + sourced_scripts+=("$sourced_script") + tbd_logv "adding $sourced_script to baked script" + fi + done <<<"$header" + + if ! echo "#!/usr/bin/env bash" > "$out_file"; then + tbd_loge "$script_file: failed to create/overwrite script stub: $out_file" + continue + fi + + has_error=false + for relative_header_path in "${sourced_scripts[@]}"; do + header_file="$scripts_srcs_dir/$relative_header_path" + if ! cat "$header_file" >> "$out_file"; then + tbd_loge "$script_file: failed to append imported file: $header_file" + has_error=true + break + fi + done + + if $has_error; then + continue + fi + + if ! tail -n +$num_header_lines "$script_file" >> "$out_file"; then + tbd_loge "$script_file: failed to append header src: $header_file" + continue + fi + + if ! chmod +x "$out_file"; then + tbd_loge "$script_file: failed to ensure script file is executable" + continue + fi + + tbd_logi "$script_file: baked" + fi +done diff --git a/tools/resources/device.gdb b/tools/scripts/device.gdb similarity index 100% rename from tools/resources/device.gdb rename to tools/scripts/device.gdb diff --git a/tools/resources/emu.gdb b/tools/scripts/emu.gdb similarity index 100% rename from tools/resources/emu.gdb rename to tools/scripts/emu.gdb diff --git a/tools/resources/common_header.sh b/tools/scripts/lib/common_header.sh similarity index 67% rename from tools/resources/common_header.sh rename to tools/scripts/lib/common_header.sh index e2c8c8d5..5e565e78 100644 --- a/tools/resources/common_header.sh +++ b/tools/scripts/lib/common_header.sh @@ -1,9 +1,23 @@ -#!/usr/bin/env bash +#### defaults #### -set -e +# settable from env var +TBD_LOG_LEVEL=${TBD_LOG_LEVEL:-INFO} + +# not settable from env var +tbd_quit_on_error=true +tbd_use_git=true #### logging utils #### +tbd_log_levels=( + SILENT + ERROR + WARN + INFO + VERBOSE + DEBUG +) + c_none="0" c_black="0;30" c_red="0;31" @@ -30,8 +44,45 @@ reset_color() { printf "\033[${c_none}m" } +# @brief get the verbosity of a log level +# +# The verbosity is an integer, where lower values denote less verbosity and more severity: +# verbosity of DEBUG > verbosity of ERROR +# and +# severity of DEBUG < severity of ERROR +# +# @arg $1 [enum] log level +# +tbd_log_level_verbosity() { + local log_level=$1 + for i in "${!tbd_log_levels[@]}"; do + if [[ "${tbd_log_levels[$i]}" = "$log_level" ]]; then + echo "$i" + return 0 + fi + done + return 1 +} + +# @brief determine if a message of given log severity should be output +# +# @arg $1 [enum] log level to check +# +tbd_should_print() { + local verbosity + local max_verbosity + verbosity=$(tbd_log_level_verbosity "$1") + max_verbosity=$(tbd_log_level_verbosity "$TBD_LOG_LEVEL") + + if [ $verbosity -gt $max_verbosity ]; then + return 1 + else + return 0 + fi +} + tbd_log() { - text_color=$1 + local text_color=$1 shift printf "[" @@ -44,16 +95,28 @@ tbd_log() { reset_color } -tbd_logv() { - tbd_log $c_lgray $@ +tbd_loge() { + if tbd_should_print ERROR; then + tbd_log $c_red $@ + fi +} + +tbd_logw() { + if tbd_should_print ERROR; then + tbd_log $c_yellow $@ + fi } tbd_logi() { - tbd_log $c_lblue $@ + if tbd_should_print INFO; then + tbd_log $c_lblue $@ + fi } -tbd_loge() { - tbd_log $c_red $@ +tbd_logv() { + if tbd_should_print VERBOSE; then + tbd_log $c_lgray $@ + fi } tbd_abort() { @@ -63,23 +126,21 @@ tbd_abort() { #### script execution utils #### -tbd_cmd_verbosity=VERBOSE -tbd_quit_on_error=true - # @brief run a bash command with output # # @arg 1 [enum] display or hide stdout of command (SILENT/VERBOSE) # @tail [array] command to run and its arguments # tbd_run() { - if [ "$tbd_cmd_verbosity" = "SILENT" ]; then - cmd=$@ > /dev/null - elif [ "$tbd_cmd_verbosity" = "VERBOSE" ]; then + local cmd + if tbd_should_print DEBUG; then cmd=$@ + else + cmd=$@ > /dev/null fi - tbd_logv "[cmd] $@" + tbd_logi "[cmd] $@" if ! $cmd; then - tbd_logv "[$(change_color $c_red)failed$(change_color $c_lgray)] $@$(reset_color)" + tbd_logi "[$(change_color $c_red)failed$(change_color $c_lgray)] $@$(reset_color)" if $tbd_quit_on_error; then exit 1 else @@ -87,7 +148,7 @@ tbd_run() { fi fi - tbd_logv "[$(change_color $c_green)done$(change_color $c_lgray)] $@$(reset_color)" + tbd_logi "[$(change_color $c_green)done$(change_color $c_lgray)] $@$(reset_color)" } #### TBD project utils #### @@ -169,6 +230,9 @@ tbd_ensure_idf() { # tbd_get_platforms() { local project_dir=$1 + local platform + local platform_file + if [ -z "$project_dir" ]; then project_dir=$(tbd_project_root) fi @@ -187,11 +251,13 @@ tbd_get_platforms() { # @brief check if config exists for platform name # # @arg $1 [path] project directory -# @arg $2 [str] platform name +# @arg $2 [str] platform name # tbd_is_valid_platform() { local project_dir=$1 local platform_name=$2 + local platform + for platform in $(tbd_get_platforms "$project_dir"); do if [ "$platform_name" == "$platform" ]; then return 0 @@ -201,9 +267,9 @@ tbd_is_valid_platform() { } tbd_is_item_in_list() { - item=$1 + local item=$1 shift - list=$@ + local list=$@ for list_item in $list; do if [ "$list_item" == "$item" ]; then diff --git a/tools/resources/src/gdb-device.sh b/tools/scripts/src/gdb-device.sh similarity index 79% rename from tools/resources/src/gdb-device.sh rename to tools/scripts/src/gdb-device.sh index bb0b70f9..5fb63bab 100755 --- a/tools/resources/src/gdb-device.sh +++ b/tools/scripts/src/gdb-device.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -resource_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) -source "$resource_path/common_header.sh" +scripts_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) +source "$scripts_path/lib/common_header.sh" # -- END OF HEADER -- @@ -22,6 +22,6 @@ if ! [ -f "$symbols_file" ]; then fi exec xtensa-esp32s3-elf-gdb \ - -x "$project_dir/tools/resources/device.gdb" \ + -x "$project_dir/tools/scripts/device.gdb" \ "$symbols_file" \ $@ diff --git a/tools/resources/src/gdb-emu.sh b/tools/scripts/src/gdb-emu.sh similarity index 79% rename from tools/resources/src/gdb-emu.sh rename to tools/scripts/src/gdb-emu.sh index f8c8dc2a..2b6406d9 100755 --- a/tools/resources/src/gdb-emu.sh +++ b/tools/scripts/src/gdb-emu.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -resource_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) -source "$resource_path/common_header.sh" +scripts_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) +source "$scripts_path/lib/common_header.sh" # -- END OF HEADER -- @@ -22,6 +22,6 @@ if ! [ -f "$symbols_file" ]; then fi exec xtensa-esp32s3-elf-gdb \ - -x "$project_dir/tools/resources/emu.gdb" \ + -x "$project_dir/tools/scripts/emu.gdb" \ "$symbols_file" \ $@ diff --git a/tools/scripts/src/tbb.sh b/tools/scripts/src/tbb.sh new file mode 100755 index 00000000..295f49f5 --- /dev/null +++ b/tools/scripts/src/tbb.sh @@ -0,0 +1,144 @@ +#!/usr/bin/env bash + +scripts_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) +source "$scripts_path/lib/common_header.sh" + +# -- END OF HEADER -- + +tbd_logging_tag="tbd build" + +comands= +tbd_cmd_verbosity=VERBOSE +build_dir=build + +# @brief parse command line options +# +# All options unknown to tbb are passed on to CMake +# +parse_args() { + local has_verbosity=false + + while [ $# -gt 0 ]; do + arg=$1 + case $arg in + -p|--project-dir) + project_dir=$2 + shift + ;; + -b|--build-dir) + build_dir=$2 + shift + ;; + -vs|--silent) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -ve|--verrors) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -vw|--vwarnings) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -v|--vinfo) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=INFO + has_verbosity=true + ;; + -vv|--verbose) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=VERBOSE + has_verbosity=true + ;; + -vvv|--vdebug) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=DEBUG + has_verbosity=true + ;; + *) + break + ;; + esac + shift + done + + if [ $# -lt 1 ]; then + tbd_abort "no platform specified" + fi + + platform=$1 + shift + + commands=$@ +} + +parse_args $@ + +if [ -z "$project_dir" ]; then + project_dir=$(tbd_project_root) +fi + +if [ -z "$project_dir" ]; then + tbd_abort "could not find TBD project in path" +fi + +if ! tbd_is_project_root "$project_dir"; then + tbd_abort "not a valid project root: $project_dir" +fi + +if [ -z "$build_dir" ]; then + tbd_abort "build directory not specified" +fi + +if ! tbd_is_valid_platform "$project_dir" "$platform"; then + tbd_abort "no such platform: $platform" +fi + +if ! tbd_ensure_idf; then + tbd_abort "failed to find ESP IDF" +fi + + +# run commands in order + +pushd "$project_dir" + +if tbd_is_item_in_list "selftest" $commands; then + exit 0 +fi + +if tbd_is_item_in_list "install" $commands; then + tbd_logi "installing dependencies" + tbd_abort "not implemented" +fi + +if tbd_is_item_in_list "configure" $commands; then + tbd_logi "configuring build" + tbd_run cmake -GNinja -B"$build_dir/$platform" -DTBD_PLATFORM="$platform" +fi + +if tbd_is_item_in_list "build" $commands; then + tbd_logi "building project" + tbd_run cmake --build "$build_dir/$platform" +fi + +if tbd_is_item_in_list "flash" $commands; then + tbd_logi "flashing to device" + tbd_abort "not implemented" +fi diff --git a/tools/resources/src/tbd.sh b/tools/scripts/src/tbd.sh similarity index 100% rename from tools/resources/src/tbd.sh rename to tools/scripts/src/tbd.sh diff --git a/tools/resources/src/tbd_deps.sh b/tools/scripts/src/tbd_deps.sh similarity index 100% rename from tools/resources/src/tbd_deps.sh rename to tools/scripts/src/tbd_deps.sh diff --git a/tools/resources/src/tbe.sh b/tools/scripts/src/tbe.sh similarity index 96% rename from tools/resources/src/tbe.sh rename to tools/scripts/src/tbe.sh index 24adafac..e7a7f9d8 100755 --- a/tools/resources/src/tbe.sh +++ b/tools/scripts/src/tbe.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -resource_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) -source "$resource_path/common_header.sh" +scripts_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) +source "$scripts_path/lib/common_header.sh" # -- END OF HEADER -- diff --git a/tools/resources/src/tbr.sh b/tools/scripts/src/tbr.sh similarity index 100% rename from tools/resources/src/tbr.sh rename to tools/scripts/src/tbr.sh diff --git a/tools/scripts/src/tbx.sh b/tools/scripts/src/tbx.sh new file mode 100755 index 00000000..d888df68 --- /dev/null +++ b/tools/scripts/src/tbx.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash + +scripts_path=$(dirname -- $(dirname -- ${BASH_SOURCE[0]})) +source "$scripts_path/lib/common_header.sh" + +# -- END OF HEADER -- + +tbd_logging_tag="tbd build" + +rebuild=false +comands= +tbd_cmd_verbosity=VERBOSE +build_dir=build + +# @brief parse command line options +# +# All options unknown to tbb are passed on to CMake +# +parse_args() { + local has_verbosity=false + + while [ $# -gt 0 ]; do + arg=$1 + case $arg in + --rebuild) + rebuild=true + ;; + -p|--project-dir) + project_dir=$2 + shift + ;; + -b|--build-dir) + build_dir=$2 + shift + ;; + -vs|--silent) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -ve|--verrors) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -vw|--vwarnings) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL="SILENT" + has_verbosity=true + ;; + -v|--vinfo) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=INFO + has_verbosity=true + ;; + -vv|--verbose) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=VERBOSE + has_verbosity=true + ;; + -vvv|--vdebug) + if $has_verbosity; then + tbd_abort "multiple verbosity arguments present" + fi + TBD_LOG_LEVEL=DEBUG + has_verbosity=true + ;; + *) + break + ;; + esac + shift + done + + if [ $# -lt 1 ]; then + tbd_abort "no platform specified" + fi + platform=$1 + shift + + commands=$@ +} + +parse_args $@ + +if [ -z "$project_dir" ]; then + project_dir=$(tbd_project_root) +fi + +if [ -z "$project_dir" ]; then + tbd_abort "could not find TBD project in path" +fi + +if ! tbd_is_project_root "$project_dir"; then + tbd_abort "not a valid project root: $project_dir" +fi + +if [ -z "$build_dir" ]; then + tbd_abort "build directory not specified" +fi + +if ! tbd_is_valid_platform "$project_dir" "$platform"; then + tbd_abort "no such platform: $platform" +fi + +# run commands in order + +if ! pushd "$project_dir" > /dev/null; then + tbd_abort "failed to enter project directory $project_dir" +fi + +if $rebuild || ! docker inspect tbdbuild > /dev/null 2>&1; then + if ! docker buildx build --tag tbdbuild --file $project_dir/tools/docker/build.Dockerfile $project_dir; then + tbd_abort "failed to build tbd build container" + fi + + if ! docker run --user "$(id -u):$(id -g)" -v"$project_dir":/code tbdbuild "$platform" selftest; then + tbd_abort "build container precheck failed" + fi +fi + +exec docker run --user "$(id -u):$(id -g)" -v"$project_dir":/code -e TBD_LOG_LEVEL="$TBD_LOG_LEVEL" tbdbuild "$platform" $commands