From eb085da965c2030efa6d2d850ece4a26d19cc138 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Thu, 8 Jun 2023 19:13:38 +0100 Subject: [PATCH] some infrastructure for 'roku lt' subcommand --- .profile.roku.build | 2 + .profile.roku.dev | 4 +- _roku.sh | 10 +- _roku_build.sh | 295 ++++++++++++++++++++++++++++++++++++++++++++ _roku_completion.sh | 71 +++++++++++ _roku_lt.sh | 14 +++ _roku_shared.sh | 126 +------------------ 7 files changed, 399 insertions(+), 123 deletions(-) create mode 100644 _roku_build.sh create mode 100644 _roku_completion.sh create mode 100644 _roku_lt.sh diff --git a/.profile.roku.build b/.profile.roku.build index abe64cd..0a38a45 100644 --- a/.profile.roku.build +++ b/.profile.roku.build @@ -27,6 +27,7 @@ __build_legacy() ${PLATFORM_TYPE:+PLATFORM_TYPE=$PLATFORM_TYPE} \ ENABLE_ICECC=$ENABLE_ICECC \ PAX_DEBUG=$PAX_DEBUG \ + ROOTFSCOMPONENTS_DBG=gdbserver \ ${BUILD_MODE:+BUILD_MODE=$BUILD_MODE} \ $OPTIONS \ -j $JOBS \ @@ -42,6 +43,7 @@ __build_os() ${PLATFORM_TYPE:+PLATFORM_TYPE=$PLATFORM_TYPE} \ ENABLE_ICECC=$ENABLE_ICECC \ PAX_DEBUG=$PAX_DEBUG \ + ROOTFSCOMPONENTS_DBG=gdbserver \ ${BUILD_MODE:+BUILD_MODE=$BUILD_MODE} \ $OPTIONS \ -j $JOBS \ diff --git a/.profile.roku.dev b/.profile.roku.dev index f7c5c76..5093014 100644 --- a/.profile.roku.dev +++ b/.profile.roku.dev @@ -1,6 +1,8 @@ #!/bin/sh -source _roku_shared.sh +_ROKU_SHELL_DIR=$(dirname $(realpath $(readlink -f "${BASH_SOURCE[0]}" ))) +source $_ROKU_SHELL_DIR/_roku_shared.sh +source $_ROKU_SHELL_DIR/_roku_completion.sh roku() { diff --git a/_roku.sh b/_roku.sh index b21977c..68fe8bc 100755 --- a/_roku.sh +++ b/_roku.sh @@ -1,6 +1,11 @@ #!/bin/bash -source _roku_shared.sh +if [ -z "$_ROKU_SHELL_DIR" ]; then + _ROKU_SHELL_DIR=$(dirname $(realpath $(readlink -f "${BASH_SOURCE[0]}" ))) +fi +source $_ROKU_SHELL_DIR/_roku_shared.sh +source $_ROKU_SHELL_DIR/_roku_lt.sh +source $_ROKU_SHELL_DIR/_roku_build.sh ############################################################################### # @@ -217,7 +222,8 @@ _roku_wget() else local USER_PASSWORD="--password=$ROKU_CORP_PASSWORD" fi - wget --no-check-certificate --user=vkhachatryan $USER_PASSWORD "$@" + # wget --no-check-certificate --user=vkhachatryan $USER_PASSWORD "$@" + wget --user=vkhachatryan $USER_PASSWORD "$@" } # _roku_wget_pass() sets corp password. It is defined in the diff --git a/_roku_build.sh b/_roku_build.sh new file mode 100644 index 0000000..c27e55d --- /dev/null +++ b/_roku_build.sh @@ -0,0 +1,295 @@ +#!/bin/sh + +_roku_build_completion() +{ +} + +_roku_build() +{ + __build "$@" +} + +_roku_build_port() +{ + __build "$@" +} + +export ACLOCAL_PATH=/usr/share/aclocal + +# This is needed to be able to set brake point on /bin/Application +export PAX_DEBUG=on + +__build_help() +{ + cat <&2 + exit 1 + fi + local BUILD_ROOT=$REPO_ROOT/os + + # + # Parse arguments + # + while [ $# -gt 0 ]; do + case "$1" in + wdk) + BUILD_ROOT=$REPO_ROOT/os + BUILD_PLATFORM=carbon + TARGET=wdk-kit + BUILD_PLID=00 + if [ "$1" == "streambar"]; then + PLATFORM_TYPE=WDK_STREAMBAR + else + PLATFORM_TYPE=WDK_STB + fi + ;; + porting-kit|\ + streambar|\ + stb) + BUILD_ROOT=$REPO_ROOT/os + BUILD_PLATFORM=carbon + TARGET=porting-kit + BUILD_PLID=00 + if [ "$1" == "streambar"]; then + PLATFORM_TYPE=STREAMBAR + else + PLATFORM_TYPE=STB + fi + ;; + tests|\ + unittests) + BUILD_PLATFORM=host + PLATFORM_TYPE=unittests + TARGET=build-tests-all + PAX_DEBUG=off + ;; + host|\ + hoststatic|\ + unity|\ + native) + BUILD_PLATFORM=$1 + PAX_DEBUG=off + MAKE=$DOCKER_MAKE + TARGET=all + ;; + reno|\ + nemo|\ + rockett|\ + bailey|\ + marlin|\ + brewster|\ + benjamin|\ + benjaminw|\ + loggan|\ + lockhart|\ + madison) + local ROOT_DIR="$(basename $REPO_ROOT)" + if [ "$ROOT_DIR" == "stark" ] || \ + [ "$ROOT_DIR" == "hank" ]; then + local BUILD_ROOT="$REPO_ROOT/$1" + local ROKU_OS_DIR=$REPO_ROOT/../../../os/dist/rootfs/Carbon14_dev_stb.OBJ/export/package/porting_kit/os + # local ROKU_WLAN_DIR=$REPO_ROOT/common/wlan + local TARGET=image + else + local BUILD_ROOT=$REPO_ROOT/os + fi + BUILD_PLATFORM=$1 + ;; + icecc) + ENABLE_ICECC=1 + JOBS=256 + ;; + port-only) + ROKU_OS_DIR=$REPO_ROKU_OS_DIR + ;; + local) + ENABLE_ICECC=0 + JOBS=$(nproc) + ;; + all|\ + addon-checksums|\ + addon-checksum-check|\ + clean|\ + cleanall|\ + clobber|\ + build-tests-all|\ + build-tests-ZipMountServerTest|\ + build-tests-FuseServerTest|\ + build-tests-PluginPackageManagemnetPluginUnitTests|\ + make_custom_package|\ + clobber-all) + TARGET=$1 + ;; + build-integration-tests) + OPTIONS+="BUILD_INTEGRATION_TESTS=true" + ;; + here) + BUILD_ROOT="." + ;; + nopax) + PAX_DEBUG=off + ;; + make) + MAKE=make + ;; + docker) + MAKE=$DOCKER_MAKE + ;; + debug) + BUILD_MODE=dbg + ;; + help) + build_help + return + ;; + *) + echo "Really? Do you mean that?" + return + ;; + esac + shift + done + + # Fallback to make if docker image not found. + if [ -e $MAKE ]; then + local MAKE=make + fi + + if [ "$BUILD_PLATFORM" == "carbon" ]; then + __build_os + elif [ "$TARGET" == "image" ]; then + __build_port + else + __build_legacy + fi +} + +############################################################################### +# +# Build Completion +# +__build_completion_contains() +{ + # Platforms + for WORD in "$@"; do + if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then + return 1 + fi + done + return 0 +} + +__build_completion_add_if() +{ + __build_completion_contains "$@" + if [[ $? == 0 ]]; then + CANDIDATES+=" $@" + fi +} + +complete -F __build_completion build +__build_completion() +{ + local CANDIDATES="help clobber tests addon-checksums" + + # Docker + __build_completion_add_if docker make + + # Build hosts + __build_completion_add_if icecc local + + # Port dir + __build_completion_add_if port-only + + # Platforms + __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb + + COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) +} + diff --git a/_roku_completion.sh b/_roku_completion.sh new file mode 100644 index 0000000..a5b8c6a --- /dev/null +++ b/_roku_completion.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# +# It is assumed that the following variables are set. +# +#_ROKU_SHELL_DIR=$(dirname $(realpath $(readlink $0))) +#_ROKU_SHELL=$_ROKU_SHELL_DIR/_roku.sh + +############################################################################### +# +# Build Completion +# +__roku_completion_contains() +{ + # Platforms + for WORD in "$@"; do + if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then + return 1 + fi + done + return 0 +} + +__roku_completion_add_if() +{ + __roku_completion_contains "$@" + if [[ $? == 0 ]]; then + CANDIDATES+=" $@" + fi +} + +# complete -F __build_completion roku +# __build_completion() +# { +# local CANDIDATES="help clobber tests addon-checksums" + +# # Docker +# __build_completion_add_if docker make + +# # Build hosts +# __build_completion_add_if icecc local + +# # Port dir +# __build_completion_add_if port-only + +# # Platforms +# __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb + +# COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) +# } + +complete -F __roku_completion roku +__roku_completion() +{ + local CANDIDATES="device get log flash gdb gdb_attach telnet reboot audcap san_update sideload token_install" + + # # Docker + # __build_completion_add_if docker make + + # # Build hosts + # __build_completion_add_if icecc local + + # # Port dir + # __build_completion_add_if port-only + + # # Platforms + # __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb + + COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) +} + diff --git a/_roku_lt.sh b/_roku_lt.sh new file mode 100644 index 0000000..a838b57 --- /dev/null +++ b/_roku_lt.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +_roku_lt_completion() +{ +} + +_roku_lt_build() +{ +} + +_roku_lt_flash() +{ +} + diff --git a/_roku_shared.sh b/_roku_shared.sh index b30fbc0..7265067 100644 --- a/_roku_shared.sh +++ b/_roku_shared.sh @@ -1,19 +1,16 @@ #!/bin/sh -# I have my automake -export ACLOCAL_PATH=/usr/share/aclocal - -export ROKU_NFS_ROOT=$HOME/roku/nfs -export ROKU_NFS_IP=192.168.0.64 -export EXPORTROOT=${ROKU_NFS_ROOT} - +if [ -z "$_ROKU_SHELL_DIR" ]; then + _ROKU_SHELL_DIR=$(dirname $(realpath $(readlink -f "${BASH_SOURCE[0]}" ))) +fi +_ROKU_SHELL=$_ROKU_SHELL_DIR/_roku.sh export DEVPASSWORD=aaaa _roku_device() { if [ "$1" != "" ]; then export ROKU_DEV_TARGET="$1" - export ROKU_DEV_PLATFORM="$(_roku.sh device_platform)" + export ROKU_DEV_PLATFORM="$($_ROKU_SHELL device_platform)" fi echo "device: $ROKU_DEV_TARGET" echo "platform: $ROKU_DEV_PLATFORM" @@ -26,7 +23,7 @@ _roku_wget_pass() export ROKU_CORP_PASSWORD } -_ROKU_DEFAULT_DISPATCH_FUNC=_roku.sh +_ROKU_DEFAULT_DISPATCH_FUNC=$_ROKU_SHELL _roku_dispatch() { local DISPATCH_FUNC=$_ROKU_DEFAULT_DISPATCH_FUNC @@ -47,114 +44,3 @@ roku() _roku_dispatch "$@" } - -############################################################################### -# -# Build Completion -# -__roku_completion_contains() -{ - # Platforms - for WORD in "$@"; do - if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then - return 1 - fi - done - return 0 -} - -__roku_completion_add_if() -{ - __roku_completion_contains "$@" - if [[ $? == 0 ]]; then - CANDIDATES+=" $@" - fi -} - -# complete -F __build_completion roku -# __build_completion() -# { -# local CANDIDATES="help clobber tests addon-checksums" - -# # Docker -# __build_completion_add_if docker make - -# # Build hosts -# __build_completion_add_if icecc local - -# # Port dir -# __build_completion_add_if port-only - -# # Platforms -# __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb - -# COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) -# } - -complete -F __roku_completion roku -__roku_completion() -{ - local CANDIDATES="device get log flash gdb gdb_attach telnet reboot audcap san_update sideload token_install" - - # # Docker - # __build_completion_add_if docker make - - # # Build hosts - # __build_completion_add_if icecc local - - # # Port dir - # __build_completion_add_if port-only - - # # Platforms - # __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb - - COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) -} - -############################################################################### -# -# Logging -# -LOGDIR="${HOME}/roku/logs" - - -dcapture() -{ - nc minicom "$@" -C $LOGDIR/.log.$(date +%Y-%m-%d--%H-%M-%S) -} - - -dfile() -{ - local Nth="-1" - if [ $# -gt 0 ]; then - Nth="$1" - fi - - echo $(ls -tr -1 ${LOGDIR}/minicom.log.* | tail ${Nth} | head -1) -} - -dless() -{ - less $(lfile "$@") -} - -dcat() -{ - cat $(lfile "$@") -} - -dgrep() -{ - lcat | grep -a --color "$@" -} - -dtail() -{ - if [ $# -gt 0 ]; then - tail -f $(lfile) | grep "$@" - else - tail -f $(lfile) - fi -} -