Commit d553be59 authored by Damien George's avatar Damien George
Browse files

build: Simplify build directory layout by putting all headers in genhdr.

Any generated headers go in $(BUILD)/genhdr/, and are #included as
'genhdr/xxx.h'.
parent 2d1f865d
...@@ -10,7 +10,7 @@ CROSS_COMPILE = arm-none-eabi- ...@@ -10,7 +10,7 @@ CROSS_COMPILE = arm-none-eabi-
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT) CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
......
...@@ -51,24 +51,21 @@ $(BUILD)/%.pp: %.c ...@@ -51,24 +51,21 @@ $(BUILD)/%.pp: %.c
# The following rule uses | to create an order only prereuisite. Order only # The following rule uses | to create an order only prereuisite. Order only
# prerequisites only get built if they don't exist. They don't cause timestamp # prerequisites only get built if they don't exist. They don't cause timestamp
# checkng to be performed. # checking to be performed.
# #
# $(sort $(var)) removes duplicates # $(sort $(var)) removes duplicates
# #
# The net effect of this, is it causes the objects to depend on the # The net effect of this, is it causes the objects to depend on the
# object directories (but only for existance), and the object directories # object directories (but only for existence), and the object directories
# will be created if they don't exist. # will be created if they don't exist.
OBJ_DIRS = $(sort $(dir $(OBJ))) OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): $(HEADER_PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS) $(OBJ): $(HEADER_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
$(OBJ_DIRS): $(OBJ_DIRS):
$(MKDIR) -p $@ $(MKDIR) -p $@
$(HEADER_BUILD): $(HEADER_BUILD):
$(MKDIR) -p $@ $(MKDIR) -p $@
$(HEADER_PY_BUILD):
$(MKDIR) -p $@
ifneq ($(PROG),) ifneq ($(PROG),)
# Build a standalone executable (unix and unix-cpy do this) # Build a standalone executable (unix and unix-cpy do this)
......
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
PY_BUILD = $(BUILD)/py PY_BUILD = $(BUILD)/py
# where autogenerated header files go # where autogenerated header files go
HEADER_BUILD = $(BUILD)/includes/build HEADER_BUILD = $(BUILD)/genhdr
# where autogenerated py header files go
HEADER_PY_BUILD = $(HEADER_BUILD)/py
# file containing qstr defs for the core Python bit # file containing qstr defs for the core Python bit
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
...@@ -105,25 +102,26 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) ...@@ -105,25 +102,26 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
FORCE: FORCE:
.PHONY: FORCE .PHONY: FORCE
$(HEADER_PY_BUILD)/py-version.h: FORCE $(HEADER_BUILD)/py-version.h: FORCE
$(Q)$(PY_SRC)/py-version.sh > $@.tmp $(Q)$(PY_SRC)/py-version.sh > $@.tmp
$(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi $(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi
# qstr data # qstr data
# Adding an order only dependency on $(HEADER_PY_BUILD) causes $(HEADER_PY_BUILD) to get # Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
# created before we run the script to generate the .h # created before we run the script to generate the .h
$(HEADER_PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_PY_BUILD) $(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
$(ECHO) "CPP $<"
$(Q)$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_BUILD)/qstrdefs.preprocessed.h
$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)" $(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
# We don't know which source files actually need the generated.h (since # We don't know which source files actually need the generated.h (since
# it is #included from str.h). The compiler generated dependencies will cause # it is #included from str.h). The compiler generated dependencies will cause
# the right .o's to get recompiled if the generated.h file changes. Adding # the right .o's to get recompiled if the generated.h file changes. Adding
# an order-only dependendency to all of the .o's will cause the generated .h # an order-only dependendency to all of the .o's will cause the generated .h
# to get built before we try to compile any of them. # to get built before we try to compile any of them.
$(PY_O): | $(HEADER_PY_BUILD)/qstrdefs.generated.h $(HEADER_PY_BUILD)/py-version.h $(PY_O): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/py-version.h
# emitters # emitters
......
...@@ -60,7 +60,7 @@ const static qstr_pool_t const_pool = { ...@@ -60,7 +60,7 @@ const static qstr_pool_t const_pool = {
(const byte*) "\0\0\0\0", // invalid/no qstr has empty data (const byte*) "\0\0\0\0", // invalid/no qstr has empty data
(const byte*) "\0\0\0\0", // empty qstr (const byte*) "\0\0\0\0", // empty qstr
#define Q(id, str) str, #define Q(id, str) str,
#include "build/py/qstrdefs.generated.h" #include "genhdr/qstrdefs.generated.h"
#undef Q #undef Q
}, },
}; };
......
...@@ -8,7 +8,7 @@ enum { ...@@ -8,7 +8,7 @@ enum {
MP_QSTR_NULL = 0, // indicates invalid/no qstr MP_QSTR_NULL = 0, // indicates invalid/no qstr
MP_QSTR_ = 1, // the empty qstr MP_QSTR_ = 1, // the empty qstr
#define Q(id, str) MP_QSTR_##id, #define Q(id, str) MP_QSTR_##id,
#include "build/py/qstrdefs.generated.h" #include "genhdr/qstrdefs.generated.h"
#undef Q #undef Q
MP_QSTR_number_of, MP_QSTR_number_of,
}; };
......
...@@ -19,7 +19,7 @@ CROSS_COMPILE = arm-none-eabi- ...@@ -19,7 +19,7 @@ CROSS_COMPILE = arm-none-eabi-
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
INC += -I$(CMSIS_DIR) INC += -I$(CMSIS_DIR)
INC += -I$(STMPERIPH_DIR) INC += -I$(STMPERIPH_DIR)
INC += -I$(STMUSB_DIR) INC += -I$(STMUSB_DIR)
......
...@@ -18,7 +18,7 @@ CROSS_COMPILE = arm-none-eabi- ...@@ -18,7 +18,7 @@ CROSS_COMPILE = arm-none-eabi-
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
INC += -I$(CMSIS_DIR)/inc INC += -I$(CMSIS_DIR)/inc
INC += -I$(CMSIS_DIR)/devinc INC += -I$(CMSIS_DIR)/devinc
INC += -I$(HAL_DIR)/inc INC += -I$(HAL_DIR)/inc
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "runtime.h" #include "runtime.h"
#include "adc.h" #include "adc.h"
#include "pin.h" #include "pin.h"
#include "build/pins.h" #include "genhdr/pins.h"
#include "timer.h" #include "timer.h"
// Usage Model: // Usage Model:
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "timer.h" #include "timer.h"
#include "led.h" #include "led.h"
#include "pin.h" #include "pin.h"
#include "build/pins.h" #include "genhdr/pins.h"
typedef struct _pyb_led_obj_t { typedef struct _pyb_led_obj_t {
mp_obj_base_t base; mp_obj_base_t base;
......
...@@ -134,7 +134,7 @@ static const char fresh_main_py[] = ...@@ -134,7 +134,7 @@ static const char fresh_main_py[] =
; ;
static const char fresh_pybcdc_inf[] = static const char fresh_pybcdc_inf[] =
#include "build/pybcdc_inf.h" #include "genhdr/pybcdc_inf.h"
; ;
static const char fresh_readme_txt[] = static const char fresh_readme_txt[] =
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "readline.h" #include "readline.h"
#include "pyexec.h" #include "pyexec.h"
#include "usb.h" #include "usb.h"
#include "build/py/py-version.h" #include "genhdr/py-version.h"
pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL; pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL;
STATIC bool repl_display_debugging_info = 0; STATIC bool repl_display_debugging_info = 0;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "runtime.h" #include "runtime.h"
#include "sdcard.h" #include "sdcard.h"
#include "pin.h" #include "pin.h"
#include "build/pins.h" #include "genhdr/pins.h"
#if MICROPY_HW_HAS_SDCARD #if MICROPY_HW_HAS_SDCARD
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "exti.h" #include "exti.h"
#include "gpio.h" #include "gpio.h"
#include "pin.h" #include "pin.h"
#include "build/pins.h" #include "genhdr/pins.h"
// Usage Model: // Usage Model:
// //
......
...@@ -20,7 +20,7 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-c ...@@ -20,7 +20,7 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-c
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
INC += -I$(CORE_PATH) INC += -I$(CORE_PATH)
CFLAGS = $(INC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) CFLAGS = $(INC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
......
...@@ -8,7 +8,7 @@ include ../py/py.mk ...@@ -8,7 +8,7 @@ include ../py/py.mk
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
# compiler settings # compiler settings
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
......
...@@ -12,7 +12,7 @@ include ../py/py.mk ...@@ -12,7 +12,7 @@ include ../py/py.mk
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
# compiler settings # compiler settings
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "runtime.h" #include "runtime.h"
#include "repl.h" #include "repl.h"
#include "gc.h" #include "gc.h"
#include "build/py/py-version.h" #include "genhdr/py-version.h"
#if MICROPY_USE_READLINE #if MICROPY_USE_READLINE
#include <readline/readline.h> #include <readline/readline.h>
......
...@@ -11,7 +11,7 @@ include ../py/py.mk ...@@ -11,7 +11,7 @@ include ../py/py.mk
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes INC += -I$(BUILD)
# compiler settings # compiler settings
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment