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'.
This commit is contained in:
parent
2d1f865d16
commit
d553be5982
|
@ -10,7 +10,7 @@ CROSS_COMPILE = arm-none-eabi-
|
|||
|
||||
INC = -I.
|
||||
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 = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
|
||||
|
|
|
@ -51,24 +51,21 @@ $(BUILD)/%.pp: %.c
|
|||
|
||||
# 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
|
||||
# checkng to be performed.
|
||||
# checking to be performed.
|
||||
#
|
||||
# $(sort $(var)) removes duplicates
|
||||
#
|
||||
# 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.
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): $(HEADER_PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
|
||||
$(OBJ): $(HEADER_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
$(MKDIR) -p $@
|
||||
|
||||
$(HEADER_BUILD):
|
||||
$(MKDIR) -p $@
|
||||
|
||||
$(HEADER_PY_BUILD):
|
||||
$(MKDIR) -p $@
|
||||
|
||||
ifneq ($(PROG),)
|
||||
# Build a standalone executable (unix and unix-cpy do this)
|
||||
|
||||
|
|
18
py/py.mk
18
py/py.mk
|
@ -2,10 +2,7 @@
|
|||
PY_BUILD = $(BUILD)/py
|
||||
|
||||
# where autogenerated header files go
|
||||
HEADER_BUILD = $(BUILD)/includes/build
|
||||
|
||||
# where autogenerated py header files go
|
||||
HEADER_PY_BUILD = $(HEADER_BUILD)/py
|
||||
HEADER_BUILD = $(BUILD)/genhdr
|
||||
|
||||
# file containing qstr defs for the core Python bit
|
||||
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
|
||||
|
@ -105,25 +102,26 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
|
|||
FORCE:
|
||||
.PHONY: FORCE
|
||||
|
||||
$(HEADER_PY_BUILD)/py-version.h: FORCE
|
||||
$(HEADER_BUILD)/py-version.h: FORCE
|
||||
$(Q)$(PY_SRC)/py-version.sh > $@.tmp
|
||||
$(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi
|
||||
|
||||
# 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
|
||||
$(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)"
|
||||
$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h
|
||||
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
|
||||
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
|
||||
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
|
||||
|
|
|
@ -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", // empty qstr
|
||||
#define Q(id, str) str,
|
||||
#include "build/py/qstrdefs.generated.h"
|
||||
#include "genhdr/qstrdefs.generated.h"
|
||||
#undef Q
|
||||
},
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ enum {
|
|||
MP_QSTR_NULL = 0, // indicates invalid/no qstr
|
||||
MP_QSTR_ = 1, // the empty qstr
|
||||
#define Q(id, str) MP_QSTR_##id,
|
||||
#include "build/py/qstrdefs.generated.h"
|
||||
#include "genhdr/qstrdefs.generated.h"
|
||||
#undef Q
|
||||
MP_QSTR_number_of,
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ CROSS_COMPILE = arm-none-eabi-
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
INC += -I$(CMSIS_DIR)
|
||||
INC += -I$(STMPERIPH_DIR)
|
||||
INC += -I$(STMUSB_DIR)
|
||||
|
|
|
@ -18,7 +18,7 @@ CROSS_COMPILE = arm-none-eabi-
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
INC += -I$(CMSIS_DIR)/inc
|
||||
INC += -I$(CMSIS_DIR)/devinc
|
||||
INC += -I$(HAL_DIR)/inc
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "runtime.h"
|
||||
#include "adc.h"
|
||||
#include "pin.h"
|
||||
#include "build/pins.h"
|
||||
#include "genhdr/pins.h"
|
||||
#include "timer.h"
|
||||
|
||||
// Usage Model:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "timer.h"
|
||||
#include "led.h"
|
||||
#include "pin.h"
|
||||
#include "build/pins.h"
|
||||
#include "genhdr/pins.h"
|
||||
|
||||
typedef struct _pyb_led_obj_t {
|
||||
mp_obj_base_t base;
|
||||
|
|
|
@ -134,7 +134,7 @@ static const char fresh_main_py[] =
|
|||
;
|
||||
|
||||
static const char fresh_pybcdc_inf[] =
|
||||
#include "build/pybcdc_inf.h"
|
||||
#include "genhdr/pybcdc_inf.h"
|
||||
;
|
||||
|
||||
static const char fresh_readme_txt[] =
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "readline.h"
|
||||
#include "pyexec.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;
|
||||
STATIC bool repl_display_debugging_info = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "runtime.h"
|
||||
#include "sdcard.h"
|
||||
#include "pin.h"
|
||||
#include "build/pins.h"
|
||||
#include "genhdr/pins.h"
|
||||
|
||||
#if MICROPY_HW_HAS_SDCARD
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "exti.h"
|
||||
#include "gpio.h"
|
||||
#include "pin.h"
|
||||
#include "build/pins.h"
|
||||
#include "genhdr/pins.h"
|
||||
|
||||
// Usage Model:
|
||||
//
|
||||
|
|
|
@ -20,7 +20,7 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-c
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
INC += -I$(CORE_PATH)
|
||||
|
||||
CFLAGS = $(INC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
|
||||
|
|
|
@ -8,7 +8,7 @@ include ../py/py.mk
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
|
||||
# compiler settings
|
||||
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
|
||||
|
|
|
@ -12,7 +12,7 @@ include ../py/py.mk
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
|
||||
# compiler settings
|
||||
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "runtime.h"
|
||||
#include "repl.h"
|
||||
#include "gc.h"
|
||||
#include "build/py/py-version.h"
|
||||
#include "genhdr/py-version.h"
|
||||
|
||||
#if MICROPY_USE_READLINE
|
||||
#include <readline/readline.h>
|
||||
|
|
|
@ -11,7 +11,7 @@ include ../py/py.mk
|
|||
|
||||
INC = -I.
|
||||
INC += -I$(PY_SRC)
|
||||
INC += -I$(BUILD)/includes
|
||||
INC += -I$(BUILD)
|
||||
|
||||
# compiler settings
|
||||
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
|
||||
|
|
Loading…
Reference in New Issue