Skip to content

Commit

Permalink
remove direct python dependency from build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mjleehh committed Dec 17, 2024
1 parent 1c9a80c commit 3573d2b
Show file tree
Hide file tree
Showing 11 changed files with 637 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: ls -1 tools/docker/build.Dockerfile && docker build -t tbd_firmware -f tools/docker/build.Dockerfile $PWD

- name: build firmware
run: docker run -v $PWD:/code tbd_firmware ${{ inputs.tbd-platform }} configure && docker run -v $PWD:/code tbd_firmware ${{ inputs.tbd-platform }} build
run: docker run -v $PWD:/code tbd_firmware ${{ inputs.tbd-platform }} configure build

- name: upload firmware
uses: actions/upload-artifact@v4
Expand Down
71 changes: 65 additions & 6 deletions tools/bin/gdb-device
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,31 @@ 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
tbd_logv "[cmd] $@"
$@ > /dev/null
cmd=$@ > /dev/null
elif [ "$tbd_cmd_verbosity" = "VERBOSE" ]; then
tbd_logv "[cmd] $@"
$@
else
tbd_loge "unknown output verbosity '${silent}'"
cmd=$@
fi
tbd_logv "[cmd] $@"
if ! $cmd; then
tbd_logv "[$(change_color $c_red)failed$(change_color $c_lgray)] $@$(reset_color)"
if $tbd_quit_on_error; then
exit 1
else
return 1
fi
fi

tbd_logv "[$(change_color $c_green)done$(change_color $c_lgray)] $@$(reset_color)"
}

#### TBD project utils ####
Expand Down Expand Up @@ -137,6 +147,26 @@ tbd_project_root() {
return 1
}

tbd_ensure_idf() {
if [ -n "$IDF_DEACTIVATE_FILE_PATH" ]; then
return 0
fi

if [ "$TBD_IN_CONTAINER" = 1 ]; then
. "$TBD_IDF_ACTIVATE"
fi

if [ -z "$IDF_DEACTIVATE_FILE_PATH" ]; then
return 1
fi
}

# @brief get list of all available platforms in project dir
#
# List is newline separated.
#
# @arg $1 [path] project directory
#
tbd_get_platforms() {
local project_dir=$1
if [ -z "$project_dir" ]; then
Expand All @@ -152,8 +182,37 @@ tbd_get_platforms() {
platform=${platform#platform.}
echo $platform
done
}

# @brief check if config exists for platform name
#
# @arg $1 [path] project directory
# @arg $2 [str] platform name
#
tbd_is_valid_platform() {
local project_dir=$1
local platform_name=$2
for platform in $(tbd_get_platforms "$project_dir"); do
if [ "$platform_name" == "$platform" ]; then
return 0
fi
done
return 1
}

tbd_is_item_in_list() {
item=$1
shift
list=$@

for list_item in $list; do
if [ "$list_item" == "$item" ]; then
return 0
fi
done
return 1
}

# -- END OF HEADER --

tbd_logging_tag="tbd gdb device"
Expand Down
71 changes: 65 additions & 6 deletions tools/bin/gdb-emu
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,31 @@ 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
tbd_logv "[cmd] $@"
$@ > /dev/null
cmd=$@ > /dev/null
elif [ "$tbd_cmd_verbosity" = "VERBOSE" ]; then
tbd_logv "[cmd] $@"
$@
else
tbd_loge "unknown output verbosity '${silent}'"
cmd=$@
fi
tbd_logv "[cmd] $@"
if ! $cmd; then
tbd_logv "[$(change_color $c_red)failed$(change_color $c_lgray)] $@$(reset_color)"
if $tbd_quit_on_error; then
exit 1
else
return 1
fi
fi

tbd_logv "[$(change_color $c_green)done$(change_color $c_lgray)] $@$(reset_color)"
}

#### TBD project utils ####
Expand Down Expand Up @@ -137,6 +147,26 @@ tbd_project_root() {
return 1
}

tbd_ensure_idf() {
if [ -n "$IDF_DEACTIVATE_FILE_PATH" ]; then
return 0
fi

if [ "$TBD_IN_CONTAINER" = 1 ]; then
. "$TBD_IDF_ACTIVATE"
fi

if [ -z "$IDF_DEACTIVATE_FILE_PATH" ]; then
return 1
fi
}

# @brief get list of all available platforms in project dir
#
# List is newline separated.
#
# @arg $1 [path] project directory
#
tbd_get_platforms() {
local project_dir=$1
if [ -z "$project_dir" ]; then
Expand All @@ -152,8 +182,37 @@ tbd_get_platforms() {
platform=${platform#platform.}
echo $platform
done
}

# @brief check if config exists for platform name
#
# @arg $1 [path] project directory
# @arg $2 [str] platform name
#
tbd_is_valid_platform() {
local project_dir=$1
local platform_name=$2
for platform in $(tbd_get_platforms "$project_dir"); do
if [ "$platform_name" == "$platform" ]; then
return 0
fi
done
return 1
}

tbd_is_item_in_list() {
item=$1
shift
list=$@

for list_item in $list; do
if [ "$list_item" == "$item" ]; then
return 0
fi
done
return 1
}

# -- END OF HEADER --

tbd_logging_tag="tbd gdb emu"
Expand Down
Loading

0 comments on commit 3573d2b

Please sign in to comment.