Skip to content

Commit 7d95fd7

Browse files
[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 <[email protected]>
1 parent f136334 commit 7d95fd7

File tree

4 files changed

+109
-36
lines changed

4 files changed

+109
-36
lines changed

rules/config

-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
## Configuration parameters for SONiC build system
33
###############################################################################
44

5-
# SONIC_CONFIG_VERBOSE - enable echoing for rules commands.
6-
# Uncomment next line to enable:
7-
# SONIC_CONFIG_VERBOSE = y
8-
95
# SONIC_CONFIG_PRINT_DEPENDENCIES - show dependencies for each invoked target.
106
# Before executing rule for each target its dependencies are printed to console.
117
# Uncomment next line to enable:
@@ -21,12 +17,6 @@ SONIC_CONFIG_BUILD_JOBS = 1
2117
# container.
2218
SONIC_CONFIG_MAKE_JOBS = $(shell nproc)
2319

24-
# SONIC_CONFIG_LOG_TO_FILES - print output from execution of rule for each
25-
# target into separate log file under target/log/.
26-
# Useful when executing parallel build
27-
# Uncomment next line to enable:
28-
SONIC_CONFIG_LOG_TO_FILES = y
29-
3020
# SONIC_CONFIG_ENABLE_COLORS - enable colored output in build system.
3121
# Comment next line to disable:
3222
# SONIC_CONFIG_ENABLE_COLORS = y

rules/functions

+5-18
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,30 @@ log_green = echo -e "$(GREEN)$(1)$(GRAY)"
4141
## Logging
4242
###############################################################################
4343

44-
ifeq ($(SONIC_CONFIG_LOG_TO_FILES),y)
4544
FLUSH_LOG = rm -f [email protected]
4645

47-
LOG = &>> $(PROJECT_ROOT)/[email protected] || { [ $$? -eq 0 ] || cat $(PROJECT_ROOT)/[email protected] ; false ; }
48-
endif
46+
LOG = &>> $(PROJECT_ROOT)/[email protected] || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; }
4947

5048
###############################################################################
5149
## Header and footer for each target
5250
###############################################################################
5351

54-
# Print name of target being built
55-
PRINT_TARGET = $(call log_purple,Executing rules for $@)
56-
57-
# Print name of target that finished build
58-
PRINT_END_TARGET = $(call log_green,Finished $@)
59-
6052
# Dump targets taht current depends on
6153
ifeq ($(SONIC_CONFIG_PRINT_DEPENDENCIES),y)
62-
PRINT_DEPENDENCIES = $(call log_blue,Dependencies for $@ are $^)
63-
endif
64-
65-
# Enable verbose mode
66-
ifneq ($(SONIC_CONFIG_VERBOSE),y)
67-
ENABLE_VERBOSE = @
54+
PRINT_DEPENDENCIES = echo Dependencies for $@ are $^ $(LOG)
6855
endif
6956

7057
# header for each rule
7158
define HEADER
72-
$(ENABLE_VERBOSE)
73-
$(PRINT_TARGET)
59+
@
7460
$(PRINT_DEPENDENCIES)
7561
$(FLUSH_LOG)
62+
./update_screen.sh -a $@
7663
endef
7764

7865
# footer for each rule
7966
define FOOTER
80-
$(PRINT_END_TARGET)
67+
./update_screen.sh -d $@
8168
endef
8269

8370
###############################################################################

slave.mk

+16-8
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,21 @@ export SONIC_CONFIG_MAKE_JOBS
8080
## Dumping key config attributes associated to current building exercise
8181
###############################################################################
8282

83-
ifndef $(CONFIGURED_PLATFORM)
84-
$(info CONFIGURED_PLATFORM is $(CONFIGURED_PLATFORM))
85-
endif
86-
87-
ifndef $(SONIC_ROUTING_STACK)
88-
$(info ROUTING_STACK is $(SONIC_ROUTING_STACK))
89-
endif
83+
$(info SONiC Build System)
84+
$(info )
85+
$(info Build Configuration)
86+
$(info "CONFIGURED_PLATFORM" : "$(if $(PLATFORM),$(PLATFORM),$(CONFIGURED_PLATFORM))")
87+
$(info "SONIC_CONFIG_PRINT_DEPENDENCIES" : "$(SONIC_CONFIG_PRINT_DEPENDENCIES)")
88+
$(info "SONIC_CONFIG_BUILD_JOBS" : "$(SONIC_CONFIG_BUILD_JOBS)")
89+
$(info "SONIC_CONFIG_MAKE_JOBS" : "$(SONIC_CONFIG_MAKE_JOBS)")
90+
$(info "DEFAULT_USERNAME" : "$(DEFAULT_USERNAME)")
91+
$(info "DEFAULT_PASSWORD" : "$(DEFAULT_PASSWORD)")
92+
$(info "ENABLE_DHCP_GRAPH_SERVICE" : "$(ENABLE_DHCP_GRAPH_SERVICE)")
93+
$(info "SHUTDOWN_BGP_ON_START" : "$(SHUTDOWN_BGP_ON_START)")
94+
$(info "SONIC_CONFIG_DEBUG" : "$(SONIC_CONFIG_DEBUG)")
95+
$(info "ROUTING_STACK" : "$(SONIC_ROUTING_STACK)")
96+
$(info "ENABLE_SYNCD_RPC" : "$(ENABLE_SYNCD_RPC)")
97+
$(info )
9098

9199
###############################################################################
92100
## Generic rules section
@@ -241,7 +249,7 @@ SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
241249
$(SONIC_EXTRA_DEBS)))
242250
$(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$*
243251
$(HEADER)
244-
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && exit 1; }
252+
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && false $(LOG) }
245253
# put a lock here because dpkg does not allow installing packages in parallel
246254
while true; do
247255
if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then

update_screen.sh

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
lockfile .screen
4+
5+
target_list_file=/tmp/target_list
6+
touch ${target_list_file}
7+
8+
function scroll_up {
9+
# Check if TERM is available
10+
[[ "${TERM}" == "dumb" ]] && return
11+
12+
for i in $(cat ${target_list_file}); do
13+
tput cuu1
14+
tput el
15+
done
16+
}
17+
18+
function print_targets {
19+
# Check if TERM is available
20+
[[ "${TERM}" == "dumb" ]] && return
21+
22+
count=1
23+
for i in $(cat ${target_list_file}); do
24+
printf "[ %02d ] [ %s ]\n" "${count}" "$i"
25+
((count++))
26+
done
27+
}
28+
29+
function remove_target {
30+
# Check if TERM is available
31+
[[ "${TERM}" == "dumb" ]] && echo "[ finished ] [ $1 ] " && return
32+
33+
old_list=$(cat ${target_list_file})
34+
rm ${target_list_file}
35+
for target in ${old_list}; do
36+
if [[ "${target}" != "$1" ]]; then
37+
echo ${target} >> ${target_list_file}
38+
fi
39+
done
40+
touch ${target_list_file}
41+
}
42+
43+
function add_target {
44+
# Check if TERM is available
45+
[[ "${TERM}" == "dumb" ]] && echo "[ building ] [ $1 ] " && return
46+
47+
echo $1 >> ${target_list_file}
48+
}
49+
50+
function print_targets_delay {
51+
sleep 2 && print_targets && rm -f .screen &
52+
exit 0
53+
}
54+
55+
while getopts ":a:d:e:" opt; do
56+
case $opt in
57+
a)
58+
scroll_up
59+
add_target ${OPTARG}
60+
print_targets
61+
;;
62+
d)
63+
scroll_up
64+
remove_target ${OPTARG}
65+
print_targets
66+
;;
67+
e)
68+
scroll_up
69+
remove_target ${OPTARG}
70+
echo "[ FAIL LOG START ] [ ${OPTARG} ]"
71+
cat ${OPTARG}.log
72+
echo "[ FAIL LOG END ] [ ${OPTARG} ]"
73+
print_targets_delay
74+
;;
75+
\?)
76+
echo "Invalid option: -$OPTARG" >&2
77+
rm -f .screen
78+
exit 1
79+
;;
80+
:)
81+
echo "Option -$OPTARG requires an argument." >&2
82+
rm -f .screen
83+
exit 1
84+
;;
85+
esac
86+
done
87+
88+
rm -f .screen

0 commit comments

Comments
 (0)