Skip to content

Commit

Permalink
feat(Build): Add Ability to Selectively Introspect Build Variables (#931
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Jake-Carter authored Feb 27, 2024
1 parent c7dc246 commit 47ac9e5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Libraries/CMSIS/Device/Maxim/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,27 @@ $(BUILD_DIR)/project_defines.h: $(BUILD_DIR)/_empty_tmp_file.c $(PROJECTMK) | $(
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(filter-out -MD,$(CFLAGS)) >> $@

################################################################################
# Add a rule for querying the value of any Makefile variable. This is useful for
# IDEs when they need to figure out include paths, value of the target, etc. for a
# project
# Set QUERY_VAR to the variable to inspect.
# The output must be parsed, since other Makefiles may print additional info strings.
# The relevant content will be on its own line, and separated by an '=' character.
# Ex: make query QUERY_VAR=TARGET
# will return
# TARGET=MAXxxxxx
ifeq "$(MAKECMDGOALS)" "query"
SUPPRESS_HELP := 1
endif
.PHONY: query
query:
ifneq "$(QUERY_VAR)" ""
@echo $(QUERY_VAR)=$($(QUERY_VAR))
else
$(MAKE) debug
endif

#################################################################################
SUPPRESS_HELP ?= 0
ifeq "$(SUPPRESS_HELP)" "0"
Expand All @@ -635,4 +656,5 @@ $(info *************************************************************************
HELP_COMPLETE = 1
export HELP_COMPLETE
endif
endif
endif

21 changes: 21 additions & 0 deletions Libraries/CMSIS/Device/Maxim/GCC/gcc_riscv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,27 @@ $(BUILD_DIR)/project_defines.h: $(BUILD_DIR)/_empty_tmp_file.c $(PROJECTMK) | $(
@echo "// This is a generated file that's used to detect definitions that have been set by the compiler and build system." > $@
@$(CC) -E -P -dD $(BUILD_DIR)/_empty_tmp_file.c $(filter-out -MD,$(CFLAGS)) >> $@

################################################################################
# Add a rule for querying the value of any Makefile variable. This is useful for
# IDEs when they need to figure out include paths, value of the target, etc. for a
# project
# Set QUERY_VAR to the variable to inspect.
# The output must be parsed, since other Makefiles may print additional info strings.
# The relevant content will be on its own line, and separated by an '=' character.
# Ex: make query QUERY_VAR=TARGET
# will return
# TARGET=MAXxxxxx
ifeq "$(MAKECMDGOALS)" "query"
SUPPRESS_HELP := 1
endif
.PHONY: query
query:
ifneq "$(QUERY_VAR)" ""
@echo $(QUERY_VAR)=$($(QUERY_VAR))
else
$(MAKE) debug
endif

#################################################################################
SUPPRESS_HELP ?= 0
ifeq "$(SUPPRESS_HELP)" "0"
Expand Down

0 comments on commit 47ac9e5

Please sign in to comment.