Skip to content

buildsystem: create custom call function for stderr infos and warnings #22514

Description

@crasbe

Description

Infos that are printed during the build process have to be redirected to stderr to avoid confusing the automated scripts that interpret the stdout output (for example in our CI).

There are some variants how this is currently done:

$(shell echo "white text" 1>&2)
$(shell $(COLOR_ECHO) "$(COLOR_RED)red text$(COLOR_RESET)" 1>&2)

It would be nice to create a custom call function that could be called like this:

$(call stderr, "white text")
$(call stderr_red, "red text")

Somewhere in a shared stderr_output.inc.mk, we could have function defintions like this (not tested!):

# include color echo macros
include $(RIOTMAKE)/utils/ansi.mk
include $(RIOTMAKE)/color.inc.mk

define stderr_red
    $(shell $(COLOR_ECHO) "$(COLOR_RED)$(1)$(COLOR_RESET)" 1>&2)
endef

This would significantly reduce the boilerplate around the actual text and make the code more readable.

This is a (non exhaustive) list of occurances that can/should be migrated.

cbuec@W11nMate:~/RIOTstuff/riot-vanillaice/RIOT$ grep -RnwI "1>&2" . | grep Makefile
./Makefile.include:212:                          "https://github.com/RIOT-OS/RIOT/blob/master/dist/tools/vagrant/README.md 1>&2)
./Makefile.include:974:                          "$(sort $(filter $(DISABLE_MODULE), $(USEMODULE)))" 1>&2)
./Makefile.include:982:                          "$(FEATURES_MISSING)" 1>&2)
./Makefile.include:989:                          "$(FEATURES_USED_BLACKLISTED)" 1>&2)
./Makefile.include:998:      "BOARDS_SUPPORTED and BOARD_BLACKLIST to BOARDS_UNSUPPORTED.$(COLOR_RESET)" 1>&2)
./Makefile.include:1000:      "BOARDS_SUPPORTED and the contents of BOARD_BLACKLIST to BOARDS_UNSUPPORTED for compatibility." 1>&2)
./Makefile.include:1006:                          "$(FEATURES_CONFLICTING)" 1>&2)
./Makefile.include:1008:        $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)Rationale: $(COLOR_RESET)$(FEATURES_CONFLICT_MSG)" 1>&2)
./Makefile.include:1015:      $(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is not listed in BOARDS_SUPPORTED$(COLOR_RESET)." 1>&2)
./Makefile.include:1016:      $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)When the list BOARDS_SUPPORTED is not empty, only boards explicitly listed there are supported.$(COLOR_RESET)" 1>&2)
./Makefile.include:1017:      $(shell $(COLOR_ECHO) "BOARDS_SUPPORTED = \"$(BOARDS_SUPPORTED)\"" 1>&2)
./Makefile.include:1024:    $(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is listed in BOARDS_UNSUPPORTED.$(COLOR_RESET)" 1>&2)
./Makefile.include:1025:    $(shell $(COLOR_ECHO) "BOARDS_UNSUPPORTED = $(BOARDS_UNSUPPORTED)" 1>&2)
./Makefile.include:1031:    $(shell $(COLOR_ECHO) "$(COLOR_RED)The selected TOOLCHAIN=$(TOOLCHAIN) is not supported.$(COLOR_RESET)\nSupported toolchains: $(TOOLCHAINS_SUPPORTED)" 1>&2)
./Makefile.include:1038:      $(shell $(COLOR_ECHO) "$(COLOR_RED)The selected TOOLCHAIN=$(TOOLCHAIN) is blacklisted:$(COLOR_RESET) $(TOOLCHAINS_BLACKLIST)" 1>&2)
./Makefile.include:1049:    $(shell $(COLOR_ECHO) "\n\n$(COLOR_RED)EXPECT ERRORS!$(COLOR_RESET)\n\n" 1>&2)
./boards/seeedstudio-xiao-esp32c3/Makefile.dep:8:      $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)$(MSG)$(COLOR_RESET)" 1>&2)
./boards/common/nucleo64/Makefile.dep:13:      $(shell $(COLOR_ECHO) "$(COLOR_YELLOW)$(MSG)$(COLOR_RESET)" 1>&2)
./sys/shell_lock/Makefile.include:4:  used connection method!$(COLOR_RESET)" 1>&2)
./sys/net/application_layer/gcoap/Makefile.include:3:                         possible to use a dual stack setup$(COLOR_RESET)" 1>&2)

cbuec@W11nMate:~/RIOTstuff/riot-vanillaice/RIOT$ grep -RnwI "1>&2" . | grep ".inc.mk"
./makefiles/deprecated_cpus.inc.mk:6:                          "$(CPU)" 1>&2)
./makefiles/usb-codes.inc.mk:23:                $(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \
./makefiles/usb-codes.inc.mk:24:                $(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \
./makefiles/usb-codes.inc.mk:27:                $(COLOR_ECHO) "$(COLOR_RED)RIOT standard peripherals code (1209/7D00) cannot be set explicitly.$(COLOR_RESET)" 1>&2 ; \
./makefiles/usb-codes.inc.mk:28:                $(COLOR_ECHO) "$(COLOR_RED)Unset USB_VID / USB_PID for the code to be picked automatically, or set$(COLOR_RESET)" 1>&2 ; \
./makefiles/usb-codes.inc.mk:29:                $(COLOR_ECHO) "$(COLOR_RED)them to \$${USB_VID_TESTING} / \$${USB_PID_TESTING} during development.$(COLOR_RESET)" 1>&2 ; \
./makefiles/deprecated_boards.inc.mk:7:                          "$(BOARD)" 1>&2)
./makefiles/dependency_resolution.inc.mk:72:                          "$(DEPRECATED_MODULES_USED)" 1>&2)
./makefiles/dependency_resolution.inc.mk:104:                              "is a REALLY BAD idea before proceeding!$(COLOR_RESET)" 1>&2)
./makefiles/dependency_resolution.inc.mk:108:                              "don't run this on public networks!$(COLOR_RESET)" 1>&2)
./makefiles/dependency_resolution.inc.mk:117:                              "is a REALLY BAD idea before proceeding!$(COLOR_RESET)" 1>&2)
./makefiles/dependency_resolution.inc.mk:121:                              "don't run this on public networks!$(COLOR_RESET)" 1>&2)
./makefiles/dependency_resolution.inc.mk:130:                            "security issues!$(COLOR_RESET)" 1>&2)
./makefiles/board_alias.inc.mk:30:    $(shell echo 'using BOARD="$(_board)" as "$(_alias)" on a $(_platform_bits)-bit system' 1>&2)
./makefiles/board_alias.inc.mk:33:    $(shell $(COLOR_ECHO) "$(COLOR_RED)$(MSG)$(COLOR_RESET)" 1>&2)

Useful links

https://www.gnu.org/software/make/manual/html_node/Call-Function.html#Call-Function

Found/discussed in #22491 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI: Not UsedAI was stated to not be used in this PR/IssueArea: build systemArea: Build systemCommunity: Hack'n'ACK candidateThis PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK partiesCommunity: help wantedThe contributors require help from other members of the communityType: cleanupThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions