diff options
author | Viktor Söderqvist <viktor@zuiderkwast.se> | 2022-01-06 16:59:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 17:59:37 +0200 |
commit | e88f6acb94c77c9a5b81f0b2a8bd132b2a5c3d3c (patch) | |
tree | d8da3bf4f76dcc17fa05280f74ac16b33e636f1d /src/Makefile | |
parent | 885f6b5cebf80108a857cd50a4b84f5daf013e29 (diff) | |
download | redis-e88f6acb94c77c9a5b81f0b2a8bd132b2a5c3d3c.tar.gz |
Build commands.c in Makefile (#10039)
With this rule, the script to generate commands.c from JSON runs whenever commands.o is built if any of commands/*.json are modified. Without such rule, it's easy to forget to run the script when updating the JSON files.
It's a follow-up on #9656 and #9951.
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile index 9c6eab4f8..2a0d74d82 100644 --- a/src/Makefile +++ b/src/Makefile @@ -51,6 +51,10 @@ INSTALL_BIN=$(PREFIX)/bin INSTALL=install PKG_CONFIG?=pkg-config +ifndef PYTHON +PYTHON := $(shell which python3 || which python) +endif + # Default allocator defaults to Jemalloc if it's not an ARM MALLOC=libc ifneq ($(uname_M),armv6l) @@ -305,6 +309,7 @@ ENDCOLOR="\033[0m" ifndef V QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2; +QUIET_GEN = @printf ' %b %b\n' $(CCCOLOR)GEN$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2; QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2; endif @@ -396,6 +401,13 @@ DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ %.o: %.c .make-prerequisites $(REDIS_CC) -MMD -o $@ -c $< +# The file commands.c is checked in and doesn't normally need to be rebuilt. It +# is built only if python is available and its prereqs are modified. +ifneq (,$(PYTHON)) +commands.c: commands/*.json ../utils/generate-command-code.py + $(QUIET_GEN)$(PYTHON) ../utils/generate-command-code.py +endif + clean: rm -rf $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME) *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep rm -f $(DEP) |