Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
23 changes: 5 additions & 18 deletions rules/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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

###############################################################################
Expand Down
24 changes: 16 additions & 8 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
88 changes: 88 additions & 0 deletions update_screen.sh
Original file line number Diff line number Diff line change
@@ -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