From d553be5982722fc5ee5240fbfb15697849881ced Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 17 Apr 2014 18:03:27 +0100 Subject: [PATCH] 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'. --- bare-arm/Makefile | 2 +- py/mkrules.mk | 9 +++------ py/py.mk | 18 ++++++++---------- py/qstr.c | 2 +- py/qstr.h | 2 +- stm/Makefile | 2 +- stmhal/Makefile | 2 +- stmhal/adc.c | 2 +- stmhal/led.c | 2 +- stmhal/main.c | 2 +- stmhal/pyexec.c | 2 +- stmhal/sdcard.c | 2 +- stmhal/usrsw.c | 2 +- teensy/Makefile | 2 +- unix-cpy/Makefile | 2 +- unix/Makefile | 2 +- unix/main.c | 2 +- windows/Makefile | 2 +- 18 files changed, 27 insertions(+), 32 deletions(-) diff --git a/bare-arm/Makefile b/bare-arm/Makefile index ace508ebd8..f9c9fb9a31 100644 --- a/bare-arm/Makefile +++ b/bare-arm/Makefile @@ -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) diff --git a/py/mkrules.mk b/py/mkrules.mk index 63a98a8ec6..9592d6c590 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -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) diff --git a/py/py.mk b/py/py.mk index 01a5fd1c2b..dd6ddd0b35 100644 --- a/py/py.mk +++ b/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 diff --git a/py/qstr.c b/py/qstr.c index 2b14065fa6..f9f63da391 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -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 }, }; diff --git a/py/qstr.h b/py/qstr.h index 6bcb1707fb..7cb6ae2e98 100644 --- a/py/qstr.h +++ b/py/qstr.h @@ -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, }; diff --git a/stm/Makefile b/stm/Makefile index 384ecd6304..ab4d0ff3ff 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -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) diff --git a/stmhal/Makefile b/stmhal/Makefile index 27caaca016..5501c4b8d9 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -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 diff --git a/stmhal/adc.c b/stmhal/adc.c index dafa3f7bce..b0a7a0749a 100644 --- a/stmhal/adc.c +++ b/stmhal/adc.c @@ -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: diff --git a/stmhal/led.c b/stmhal/led.c index 5c2d2c60a4..52a787eede 100644 --- a/stmhal/led.c +++ b/stmhal/led.c @@ -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; diff --git a/stmhal/main.c b/stmhal/main.c index 2d7e76172f..4fa5b2a436 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -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[] = diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c index 9821e6a929..3f9482ec58 100644 --- a/stmhal/pyexec.c +++ b/stmhal/pyexec.c @@ -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; diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c index 994eb26c2a..4c8e3d990b 100644 --- a/stmhal/sdcard.c +++ b/stmhal/sdcard.c @@ -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 diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c index 5133392ccd..0ab407cd96 100644 --- a/stmhal/usrsw.c +++ b/stmhal/usrsw.c @@ -11,7 +11,7 @@ #include "exti.h" #include "gpio.h" #include "pin.h" -#include "build/pins.h" +#include "genhdr/pins.h" // Usage Model: // diff --git a/teensy/Makefile b/teensy/Makefile index bd01f7e2b1..00f3514724 100644 --- a/teensy/Makefile +++ b/teensy/Makefile @@ -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) diff --git a/unix-cpy/Makefile b/unix-cpy/Makefile index 8db8c2069a..0376932d6a 100644 --- a/unix-cpy/Makefile +++ b/unix-cpy/Makefile @@ -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 diff --git a/unix/Makefile b/unix/Makefile index 1a29363c91..ec02ad5004 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -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) diff --git a/unix/main.c b/unix/main.c index e582244b39..b9b8fe0b9f 100644 --- a/unix/main.c +++ b/unix/main.c @@ -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 diff --git a/windows/Makefile b/windows/Makefile index ad4c82c128..651de7c7f1 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -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