build: generate config.h and implicitly include it
All source files will now depend on config.h, which is generated based on the defaults in CONFIG and the command line arguments passed to make. This ensures that any configuration changes, including on the command line, cause a full rebuild. Change-Id: I6b6fa3290941200dbcf32297c66df8dc5ee18e94 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
34731b0b17
commit
92a02f580c
10
Makefile
10
Makefile
@ -38,13 +38,21 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
DIRS-y += lib test examples app
|
||||
|
||||
.PHONY: all clean $(DIRS-y)
|
||||
.PHONY: all clean $(DIRS-y) config.h
|
||||
|
||||
all: $(DIRS-y)
|
||||
clean: $(DIRS-y)
|
||||
$(Q)rm -f config.h
|
||||
|
||||
app: lib
|
||||
test: lib
|
||||
examples: lib
|
||||
|
||||
$(DIRS-y): config.h
|
||||
|
||||
config.h: CONFIG scripts/genconfig.py
|
||||
$(Q)python scripts/genconfig.py $(MAKEFLAGS) > $@.tmp; \
|
||||
cmp -s $@.tmp $@ || mv $@.tmp $@ ; \
|
||||
rm -f $@.tmp
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
|
||||
|
@ -45,6 +45,8 @@ OS := $(shell uname)
|
||||
|
||||
COMMON_CFLAGS = -g $(C_OPT) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -fno-strict-aliasing -march=native -m64 -I$(SPDK_ROOT_DIR)/include
|
||||
|
||||
COMMON_CFLAGS += -include $(SPDK_ROOT_DIR)/config.h
|
||||
|
||||
ifeq ($(CONFIG_WERROR), y)
|
||||
COMMON_CFLAGS += -Werror
|
||||
endif
|
||||
|
33
scripts/genconfig.py
Executable file
33
scripts/genconfig.py
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
comment = re.compile('^\s*#')
|
||||
assign = re.compile('^\s*([a-zA-Z_]+)\s*(\?)?=\s*([^#]*)')
|
||||
|
||||
with open('CONFIG') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not comment.match(line):
|
||||
m = assign.match(line)
|
||||
if m:
|
||||
var = m.group(1).strip()
|
||||
default = m.group(3).strip()
|
||||
val = default
|
||||
for arg in sys.argv:
|
||||
m = assign.match(arg)
|
||||
if m:
|
||||
argvar = m.group(1).strip()
|
||||
argval = m.group(3).strip()
|
||||
if argvar == var:
|
||||
val = argval
|
||||
if default.lower() == 'y' or default.lower() == 'n':
|
||||
if val.lower() == 'y':
|
||||
boolval = 1
|
||||
else:
|
||||
boolval = 0
|
||||
print "#define SPDK_{} {}".format(var, boolval)
|
||||
else:
|
||||
strval = val.replace('"', '\"')
|
||||
print "#define SPDK_{} \"{}\"".format(var, strval)
|
Loading…
Reference in New Issue
Block a user