Skip to content

Commit

Permalink
[build]: Added support for cache status on the build output (sonic-ne…
Browse files Browse the repository at this point in the history
…t#5564)

print cache status when use cached file in the build process

Without DPKG cache support :
  [ building ] [ target/docker-base.gz ]
  [ finished ] [ target/docker-base.gz ]

With DPKG cache support :
  [ building ] [ target/docker-base.gz ]
  [ cached   ] [ target/docker-base.gz ]

extracted from PR 4595 by Kalimuthu Velappan

Signed-off-by: Guohan Lu <[email protected]>
  • Loading branch information
lguohan authored Oct 9, 2020
1 parent c1add9a commit 7229774
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rules/functions
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ define HEADER
@
$(PRINT_DEPENDENCIES)
$(FLUSH_LOG)
./update_screen.sh -a $@
./update_screen.sh -a $@ $*
endef

# footer for each rule
define FOOTER
./update_screen.sh -d $@
./update_screen.sh -d $@ $($*_CACHE_LOADED)
endef

###############################################################################
Expand Down
19 changes: 16 additions & 3 deletions update_screen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ done

function remove_target {
# Check if TERM is available
[[ "${TERM}" == "dumb" ]] && echo "[ finished ] [ $1 ] " && return
local status="finished"
[[ ! -z "${2}" ]] && status="cached"
[[ "${TERM}" == "dumb" ]] && echo "[ ${status} ] [ $1 ] " && return

old_list=$(cat ${target_list_file})
rm ${target_list_file}
Expand All @@ -52,6 +54,17 @@ sleep 2 && print_targets && rm -f .screen &
exit 0
}

# $3 takes the DPKG caching argument, if the target is loaded from cache,
# it adds the log as 'cached' else it is logged as 'finished'
#
# Without DPKG cache support :
# [ building ] [ target/docker-base.gz ]
# [ finished ] [ target/docker-base.gz ]
#
# With DPKG cache support :
# [ building ] [ target/docker-base.gz ]
# [ cached ] [ target/docker-base.gz ]

while getopts ":a:d:e:" opt; do
case $opt in
a)
Expand All @@ -61,12 +74,12 @@ while getopts ":a:d:e:" opt; do
;;
d)
scroll_up
remove_target ${OPTARG}
remove_target ${OPTARG} $3
print_targets
;;
e)
scroll_up
remove_target ${OPTARG}
remove_target ${OPTARG} $3
echo "[ FAIL LOG START ] [ ${OPTARG} ]"
cat ${OPTARG}.log
echo "[ FAIL LOG END ] [ ${OPTARG} ]"
Expand Down

0 comments on commit 7229774

Please sign in to comment.