Skip to content

Commit

Permalink
make: add targets to debug dependencies variables
Browse files Browse the repository at this point in the history
Add a 'dependency_debug' and a 'DEPENDENCY_DEBUG=1' option for
'info-boards-supported' to save some variables used when resolving
dependencies.

This should help tracking changes introduced when refactoring the
dependency parsing.
  • Loading branch information
cladmi committed Aug 15, 2019
1 parent 3e75383 commit da3c73e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ include $(RIOTMAKE)/info-nproc.inc.mk
# List of boards variables
include $(RIOTMAKE)/boards.inc.mk

# Debug targets for build system migration
include $(RIOTMAKE)/dependencies_debug.inc.mk

GLOBAL_GOALS += buildtest buildtest-indocker info-boards-supported info-boards-features-missing info-buildsizes info-buildsizes-diff
ifneq (, $(filter $(GLOBAL_GOALS), $(MAKECMDGOALS)))
BOARD=none
Expand Down
42 changes: 42 additions & 0 deletions makefiles/dependencies_debug.inc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Debug targets to evaluate dependency migrations
#
# The goal is to get the value of variables used for dependency resolution
# and the impact of refactoring

# Files output can be generated through `info-boards-supported` evaluation with
#
# DEPENDENCY_DEBUG=1 make info-boards-supported
#
# And for each board in the normal make context with
#
# BOARD=board_name make dependency_debug
#
# To compare in an aggregated file, you can run in an application directory:
#
# for board in $(make info-boards); do DEPENDENCY_DEBUG_OUTPUT_DIR=bin/info BOARD=${board} make dependency_debug; done; cat bin/info/* > bin/deps_info
# DEPENDENCY_DEBUG=1 DEPENDENCY_DEBUG_OUTPUT_DIR=bin/info-global make info-boards-supported; cat bin/info-global/* > bin/deps_info-boards-supported
# # And compare both files
# diff -u bin/deps_info bin/deps_info-boards-supported
#
# And when comparing two revisions, include the revision in the file names

.PHONY: dependency_debug
dependency_debug:
$(call file_save_dependencies_variables,dependencies_info)
@:

DEPENDENCY_DEBUG_OUTPUT_DIR ?= $(CURDIR)

# Save variables that are used for parsing dependencies
_DEPS_DEBUG_VARS += BOARD CPU CPU_MODEL CPU_FAM
_DEPS_DEBUG_VARS += FEATURES_PROVIDED FEATURES_REQUIRED FEATURES_OPTIONAL FEATURES_USED FEATURES_MISSING FEATURES_CONFLICT FEATURES_CONFLICTING
_DEPS_DEBUG_VARS += USEMODULE DEFAULT_MODULE DISABLE_MODULE
DEPS_DEBUG_VARS ?= $(_DEPS_DEBUG_VARS)

# Put some dummy first line to be sure the file is create from scratch
file_save_dependencies_variables = $(call file_save_variable,$(DEPENDENCY_DEBUG_OUTPUT_DIR)/$1_$(BOARD),$(DEPS_DEBUG_VARS))
file_save_variable = $(shell mkdir -p $(dir $1); rm -f $1)$(foreach v,$2,$(file >>$1,$(call _print_var,$v)))

# Remove spaces in case of empty value
# Remove spaces around value as it happens
_print_var = $(strip $1 = $(strip $($1)))
4 changes: 4 additions & 0 deletions makefiles/info-global.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ define board_missing_features
BOARDS_FEATURES_MISSING += "$(1) $$(FEATURES_MISSING)"
BOARDS_WITH_MISSING_FEATURES += $(1)
endif

ifneq (,$$(DEPENDENCY_DEBUG))
$$(call file_save_dependencies_variables,dependencies_info-boards-supported)
endif
endef

BOARDS := $(filter $(if $(BOARD_WHITELIST), $(BOARD_WHITELIST), %), $(BOARDS))
Expand Down

0 comments on commit da3c73e

Please sign in to comment.