summaryrefslogtreecommitdiff
path: root/Makefile.rules
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2020-02-12 10:03:42 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-14 22:59:14 +0000
commit0d469f9addbda7c768b5ed1fdae62d81ebfa5997 (patch)
tree0a9c6b155fec96e3417350ae0c899fd23828eff5 /Makefile.rules
parentc487d8ad9b1d6ce2fd1729ef16d218949236b2a3 (diff)
downloadchrome-ec-0d469f9addbda7c768b5ed1fdae62d81ebfa5997.tar.gz
make: Add print-defines and print-includes
This allows for automated IDE toolchain setup. Note, print-defines simply assumes you want to work on the RW section, thus it sets BLD=RW. If you want the defines for RO, simply set BLD=RO. Unfortunately, I needed to use CFLAGS, since some people abuse other compilation flags to add -D and -I flags. This should be cleaned up. BRANCH=none BUG=none TEST=make help TEST=make print-tests TEST=make print-host-tests TEST=make print-host-fuzzers TEST=make print-host-fuzzers | cat TEST=make print-boards TEST=make print-boards | cat TEST=make BOARD=nocturne_fp print-defines TEST=make BOARD=nocturne_fp print-includes TEST=make BOARD=nocturne print-defines TEST=make BOARD=nocturne BLD=RO print-defines TEST=make BOARD=nocturne print-includes TEST=make BOARD=nocturne print-defines | cat TEST=make BOARD=nocturne print-includes | cat TEST=make buildall -j Change-Id: I8ca729781201bad241f978407bfef54cad79ae80 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051450 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'Makefile.rules')
-rw-r--r--Makefile.rules19
1 files changed, 16 insertions, 3 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 44897ebc24..4fb430000e 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -167,11 +167,11 @@ targ_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
# If outputing to tty and column command exists, pipe into column.
# Otherwise, print in newline format.
-cmd_pretty_print_list = @echo $(1) \
- | tr ' ' '\n' \
+cmd_pretty_print_cmd = @$(1) \
| { [ -t 1 ] \
&& which column 1>/dev/null 2>&1 \
&& column || cat ; }
+cmd_pretty_print_list = $(call cmd_pretty_print_cmd,echo $(1) | tr ' ' '\n')
# By default, the "build_boards" and "try_build_boards" targets will build all
# of the boards listed in $(boards). However, the invoker can provide a
@@ -688,6 +688,17 @@ print-configs:
-DSECTION_IS_RW=$(EMPTY) include/config.h | \
grep "#define CONFIG_" | cut -c9- | sort
+.PHONY: print-defines
+print-defines: BLD ?= RW
+print-defines:
+ $(call cmd_pretty_print_cmd,echo $(CFLAGS) | tr '[:space:]' '\n' | \
+ sort -u | grep -- '^-D' | sed 's/^-D//' | sed 's/=$$//')
+
+.PHONY: print-includes
+print-includes:
+ $(call cmd_pretty_print_cmd,echo $(CFLAGS) | tr '[:space:]' '\n' | \
+ sort -u | grep -- '^-I' | sed 's/^-I//')
+
.PHONY: clean
clean:
-rm -rf $(out)
@@ -726,7 +737,9 @@ help:
@echo " print-host-tests - Prints all host test targets"
@echo " print-host-fuzzers - Prints all host fuzz targets"
@echo " print-boards - Prints all boards"
- @echo " print-configs [BOARD=] - Print CONFIG_* options for the target board"
+ @echo " print-configs [BOARD=] - Print CONFIG_* options for the target board"
+ @echo " print-defines [BOARD=] - Print forced defines passed to the compiler"
+ @echo " print-includes [BOARD=] - Print include paths passed to the compiler"
@echo "Common Variables:"
@echo " V=1 - Show make output"
@echo " BOARD= - Set the board name to build (Default is $(BOARD))"