mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #15187 from bergzand/pr/info/add_json
info.inc.mk: Add info-build-json as JSON-formatted build info
This commit is contained in:
commit
ee189fa428
@ -14,8 +14,6 @@ priv_symbols += FLUSH_TO_ZERO
|
||||
priv_symbols += FLASH_START APP_START FLASH_APP_START
|
||||
priv_symbols += ISR_VEC_SPACE ISR_VECTOR_COUNT
|
||||
|
||||
comma := ,
|
||||
|
||||
# A bit of makefile magic:
|
||||
# foreach symbol in overridable ld-symbols :
|
||||
# If symbol has a value, produce a linker argument for that symbol.
|
||||
|
@ -114,6 +114,72 @@ info-build:
|
||||
@echo ''
|
||||
@echo -e 'MAKEFILE_LIST:$(patsubst %, \n\t%, $(abspath $(MAKEFILE_LIST)))'
|
||||
|
||||
define json_string_or_null
|
||||
$(or $(1:%="%"), null)
|
||||
endef
|
||||
|
||||
# Convert a space separated list to a JSON array
|
||||
define _to_json_string_list
|
||||
[$(filter-out "","$(subst $(space),"$(comma)$(space)",$(1))")]
|
||||
endef
|
||||
|
||||
# Strips out any existing quotes so that the generated JSON is valid, not necessary sensible
|
||||
define to_json_string_list
|
||||
$(call _to_json_string_list,$(strip $(subst ",,$(subst \",,$(1)))))
|
||||
endef
|
||||
|
||||
# Crude json encoded build info.
|
||||
# The output generated here is a best-effort JSON encoding, it is not perfect,
|
||||
# converting the space separated lists in Make to a JSON array is flawed, it
|
||||
# doesn't consider quoted parts as a single list item. This mainly shows up in
|
||||
# cflags such as: -DNIMBLE_HOST_PRIO="(NIMBLE_CONTROLLER_PRIO + 1)", this is
|
||||
# splitted into 3 array elements. To ensure that the generated JSON is valid,
|
||||
# double quotes are currently stripped before generating the array.
|
||||
info-build-json:
|
||||
@echo '{ '
|
||||
@echo '"APPLICATION": "$(APPLICATION)",'
|
||||
@echo '"APPDIR": "$(APPDIR)",'
|
||||
@echo '"BOARD": "$(BOARD)",'
|
||||
@echo '"CPU": "$(CPU)",'
|
||||
@echo '"MCU": "$(MCU)",'
|
||||
@echo '"RIOTBASE": "$(RIOTBASE)",'
|
||||
@echo '"BOARDDIR": "$(BOARDDIR)",'
|
||||
@echo '"RIOTCPU": "$(RIOTCPU)",'
|
||||
@echo '"RIOTPKG": "$(RIOTPKG)",'
|
||||
@echo '"EXTERNAL_BOARD_DIRS": $(call json_string_or_null $(EXTERNAL_BOARD_DIRS)),'
|
||||
@echo '"BINDIR": "$(BINDIR)",'
|
||||
@echo '"ELFFILE": "$(ELFFILE)",'
|
||||
@echo '"HEXFILE": "$(HEXFILE)",'
|
||||
@echo '"BINFILE": "$(BINFILE)",'
|
||||
@echo '"FLASHFILE": "$(FLASHFILE)",'
|
||||
@echo '"DEFAULT_MODULE": $(call to_json_string_list,$(sort $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)))),'
|
||||
@echo '"DISABLE_MODULE": $(call to_json_string_list,$(sort $(DISABLE_MODULE))),'
|
||||
@echo '"USEMODULE": $(call to_json_string_list,$(sort $(filter-out $(DEFAULT_MODULE), $(USEMODULE)))),'
|
||||
@echo '"FEATURES_USED": $(call to_json_string_list,$(FEATURES_USED)),'
|
||||
@echo '"FEATURES_REQUIRED": $(call to_json_string_list,$(sort $(FEATURES_REQUIRED))),'
|
||||
@echo '"FEATURES_REQUIRED_ANY": $(call to_json_string_list,$(sort $(FEATURES_REQUIRED_ANY))),'
|
||||
@echo '"FEATURES_OPTIONAL_ONLY": $(call to_json_string_list,$(FEATURES_OPTIONAL_ONLY)),'
|
||||
@echo '"FEATURES_OPTIONAL_MISSING": $(call to_json_string_list,$(FEATURES_OPTIONAL_MISSING)),'
|
||||
@echo '"FEATURES_PROVIDED": $(call to_json_string_list,$(sort $(FEATURES_PROVIDED))),'
|
||||
@echo '"FEATURES_MISSING": $(call to_json_string_list,$(FEATURES_MISSING)),'
|
||||
@echo '"FEATURES_BLACKLIST": $(call to_json_string_list,$(sort $(FEATURES_BLACKLIST))),'
|
||||
@echo '"FEATURES_USED_BLACKLISTED": $(call to_json_string_list,$(sort $(FEATURES_USED_BLACKLISTED))),'
|
||||
@echo '"FEATURES_CONFLICT": $(call to_json_string_list,$(FEATURES_CONFLICT)),'
|
||||
@echo '"FEATURES_CONFLICTING": $(call to_json_string_list,$(FEATURES_CONFLICTING)),'
|
||||
@echo '"PREFIX": $(call json_string_or_null,$(PREFIX)),'
|
||||
@echo '"CC": "$(CC)",'
|
||||
@echo '"CXX": "$(CXX)",'
|
||||
@echo '"LINK": "$(LINK)",'
|
||||
@echo '"OBJCOPY": "$(OBJCOPY)",'
|
||||
@echo '"INCLUDES": $(call to_json_string_list,$(strip $(INCLUDES))),'
|
||||
@echo '"OFLAGS": $(call to_json_string_list,$(OFLAGS)),'
|
||||
@echo '"CFLAGS": $(call to_json_string_list,$(CFLAGS)),'
|
||||
@echo '"CXXUWFLAGS": $(call to_json_string_list,$(CXXUWFLAGS)),'
|
||||
@echo '"CXXEXFLAGS": $(call to_json_string_list,$(CXXEXFLAGS)),'
|
||||
@echo '"LINKFLAGS": $(call to_json_string_list,$(LINKFLAGS))'
|
||||
@echo '}'
|
||||
|
||||
|
||||
info-files: QUIET := 0
|
||||
info-files:
|
||||
@( \
|
||||
|
@ -1,6 +1,10 @@
|
||||
# Utilities to set variables and environment for targets
|
||||
# The variables defined here cover edge cases in make string handling.
|
||||
# These functions should help replacing immediate evaluation and global 'export'
|
||||
|
||||
comma := ,
|
||||
blank :=
|
||||
space := $(blank) $(blank)
|
||||
|
||||
# Evaluate a deferred variable only once on its first usage
|
||||
# Uses after that will be as if it was an immediate evaluation
|
||||
|
@ -39,11 +39,9 @@ info-unittests:
|
||||
|
||||
$(UNIT_TESTS): all
|
||||
|
||||
charCOMMA := ,
|
||||
|
||||
ifeq (, $(UNIT_TESTS))
|
||||
CFLAGS += -DNO_TEST_SUITES
|
||||
$(warning There was no test suite specified!)
|
||||
else
|
||||
CFLAGS += -DTEST_SUITES='$(subst $() $(),$(charCOMMA),$(UNIT_TESTS:tests-%=%))'
|
||||
CFLAGS += -DTEST_SUITES='$(subst $() $(),$(comma),$(UNIT_TESTS:tests-%=%))'
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user