[rules/functions][slave.mk]: Refine build output (#838)

Print current build configuration before run
Update screen with currently running targets (only available if TERM is
available)
Change format of printed targets

Signed-off-by: marian-pritsak <marianp@mellanox.com>
This commit is contained in:
Marian Pritsak 2017-07-25 09:49:39 +03:00 committed by GitHub
parent f136334c72
commit 7d95fd7e8c
4 changed files with 109 additions and 36 deletions

View File

@ -2,10 +2,6 @@
## Configuration parameters for SONiC build system
###############################################################################
# SONIC_CONFIG_VERBOSE - enable echoing for rules commands.
# Uncomment next line to enable:
# SONIC_CONFIG_VERBOSE = y
# SONIC_CONFIG_PRINT_DEPENDENCIES - show dependencies for each invoked target.
# Before executing rule for each target its dependencies are printed to console.
# Uncomment next line to enable:
@ -21,12 +17,6 @@ SONIC_CONFIG_BUILD_JOBS = 1
# container.
SONIC_CONFIG_MAKE_JOBS = $(shell nproc)
# SONIC_CONFIG_LOG_TO_FILES - print output from execution of rule for each
# target into separate log file under target/log/.
# Useful when executing parallel build
# Uncomment next line to enable:
SONIC_CONFIG_LOG_TO_FILES = y
# SONIC_CONFIG_ENABLE_COLORS - enable colored output in build system.
# Comment next line to disable:
# SONIC_CONFIG_ENABLE_COLORS = y

View File

@ -41,43 +41,30 @@ log_green = echo -e "$(GREEN)$(1)$(GRAY)"
## Logging
###############################################################################
ifeq ($(SONIC_CONFIG_LOG_TO_FILES),y)
FLUSH_LOG = rm -f $@.log
LOG = &>> $(PROJECT_ROOT)/$@.log || { [ $$? -eq 0 ] || cat $(PROJECT_ROOT)/$@.log ; false ; }
endif
LOG = &>> $(PROJECT_ROOT)/$@.log || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; }
###############################################################################
## Header and footer for each target
###############################################################################
# Print name of target being built
PRINT_TARGET = $(call log_purple,Executing rules for $@)
# Print name of target that finished build
PRINT_END_TARGET = $(call log_green,Finished $@)
# Dump targets taht current depends on
ifeq ($(SONIC_CONFIG_PRINT_DEPENDENCIES),y)
PRINT_DEPENDENCIES = $(call log_blue,Dependencies for $@ are $^)
endif
# Enable verbose mode
ifneq ($(SONIC_CONFIG_VERBOSE),y)
ENABLE_VERBOSE = @
PRINT_DEPENDENCIES = echo Dependencies for $@ are $^ $(LOG)
endif
# header for each rule
define HEADER
$(ENABLE_VERBOSE)
$(PRINT_TARGET)
@
$(PRINT_DEPENDENCIES)
$(FLUSH_LOG)
./update_screen.sh -a $@
endef
# footer for each rule
define FOOTER
$(PRINT_END_TARGET)
./update_screen.sh -d $@
endef
###############################################################################

View File

@ -80,13 +80,21 @@ export SONIC_CONFIG_MAKE_JOBS
## Dumping key config attributes associated to current building exercise
###############################################################################
ifndef $(CONFIGURED_PLATFORM)
$(info CONFIGURED_PLATFORM is $(CONFIGURED_PLATFORM))
endif
ifndef $(SONIC_ROUTING_STACK)
$(info ROUTING_STACK is $(SONIC_ROUTING_STACK))
endif
$(info SONiC Build System)
$(info )
$(info Build Configuration)
$(info "CONFIGURED_PLATFORM" : "$(if $(PLATFORM),$(PLATFORM),$(CONFIGURED_PLATFORM))")
$(info "SONIC_CONFIG_PRINT_DEPENDENCIES" : "$(SONIC_CONFIG_PRINT_DEPENDENCIES)")
$(info "SONIC_CONFIG_BUILD_JOBS" : "$(SONIC_CONFIG_BUILD_JOBS)")
$(info "SONIC_CONFIG_MAKE_JOBS" : "$(SONIC_CONFIG_MAKE_JOBS)")
$(info "DEFAULT_USERNAME" : "$(DEFAULT_USERNAME)")
$(info "DEFAULT_PASSWORD" : "$(DEFAULT_PASSWORD)")
$(info "ENABLE_DHCP_GRAPH_SERVICE" : "$(ENABLE_DHCP_GRAPH_SERVICE)")
$(info "SHUTDOWN_BGP_ON_START" : "$(SHUTDOWN_BGP_ON_START)")
$(info "SONIC_CONFIG_DEBUG" : "$(SONIC_CONFIG_DEBUG)")
$(info "ROUTING_STACK" : "$(SONIC_ROUTING_STACK)")
$(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
$(info )
###############################################################################
## Generic rules section
@ -241,7 +249,7 @@ SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
$(SONIC_EXTRA_DEBS)))
$(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$*
$(HEADER)
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && exit 1; }
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && false $(LOG) }
# put a lock here because dpkg does not allow installing packages in parallel
while true; do
if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then

88
update_screen.sh Executable file
View File

@ -0,0 +1,88 @@
#!/bin/bash
lockfile .screen
target_list_file=/tmp/target_list
touch ${target_list_file}
function scroll_up {
# Check if TERM is available
[[ "${TERM}" == "dumb" ]] && return
for i in $(cat ${target_list_file}); do
tput cuu1
tput el
done
}
function print_targets {
# Check if TERM is available
[[ "${TERM}" == "dumb" ]] && return
count=1
for i in $(cat ${target_list_file}); do
printf "[ %02d ] [ %s ]\n" "${count}" "$i"
((count++))
done
}
function remove_target {
# Check if TERM is available
[[ "${TERM}" == "dumb" ]] && echo "[ finished ] [ $1 ] " && return
old_list=$(cat ${target_list_file})
rm ${target_list_file}
for target in ${old_list}; do
if [[ "${target}" != "$1" ]]; then
echo ${target} >> ${target_list_file}
fi
done
touch ${target_list_file}
}
function add_target {
# Check if TERM is available
[[ "${TERM}" == "dumb" ]] && echo "[ building ] [ $1 ] " && return
echo $1 >> ${target_list_file}
}
function print_targets_delay {
sleep 2 && print_targets && rm -f .screen &
exit 0
}
while getopts ":a:d:e:" opt; do
case $opt in
a)
scroll_up
add_target ${OPTARG}
print_targets
;;
d)
scroll_up
remove_target ${OPTARG}
print_targets
;;
e)
scroll_up
remove_target ${OPTARG}
echo "[ FAIL LOG START ] [ ${OPTARG} ]"
cat ${OPTARG}.log
echo "[ FAIL LOG END ] [ ${OPTARG} ]"
print_targets_delay
;;
\?)
echo "Invalid option: -$OPTARG" >&2
rm -f .screen
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
rm -f .screen
exit 1
;;
esac
done
rm -f .screen