Skip to content

Commit d553be5

Browse files
committed
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'.
1 parent 2d1f865 commit d553be5

18 files changed

Lines changed: 27 additions & 32 deletions

File tree

bare-arm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CROSS_COMPILE = arm-none-eabi-
1010

1111
INC = -I.
1212
INC += -I$(PY_SRC)
13-
INC += -I$(BUILD)/includes
13+
INC += -I$(BUILD)
1414

1515
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
1616
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)

py/mkrules.mk

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,21 @@ $(BUILD)/%.pp: %.c
5151

5252
# The following rule uses | to create an order only prereuisite. Order only
5353
# prerequisites only get built if they don't exist. They don't cause timestamp
54-
# checkng to be performed.
54+
# checking to be performed.
5555
#
5656
# $(sort $(var)) removes duplicates
5757
#
5858
# The net effect of this, is it causes the objects to depend on the
59-
# object directories (but only for existance), and the object directories
59+
# object directories (but only for existence), and the object directories
6060
# will be created if they don't exist.
6161
OBJ_DIRS = $(sort $(dir $(OBJ)))
62-
$(OBJ): $(HEADER_PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
62+
$(OBJ): $(HEADER_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
6363
$(OBJ_DIRS):
6464
$(MKDIR) -p $@
6565

6666
$(HEADER_BUILD):
6767
$(MKDIR) -p $@
6868

69-
$(HEADER_PY_BUILD):
70-
$(MKDIR) -p $@
71-
7269
ifneq ($(PROG),)
7370
# Build a standalone executable (unix and unix-cpy do this)
7471

py/py.mk

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
PY_BUILD = $(BUILD)/py
33

44
# where autogenerated header files go
5-
HEADER_BUILD = $(BUILD)/includes/build
6-
7-
# where autogenerated py header files go
8-
HEADER_PY_BUILD = $(HEADER_BUILD)/py
5+
HEADER_BUILD = $(BUILD)/genhdr
96

107
# file containing qstr defs for the core Python bit
118
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
@@ -105,25 +102,26 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
105102
FORCE:
106103
.PHONY: FORCE
107104

108-
$(HEADER_PY_BUILD)/py-version.h: FORCE
105+
$(HEADER_BUILD)/py-version.h: FORCE
109106
$(Q)$(PY_SRC)/py-version.sh > $@.tmp
110107
$(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi
111108

112109
# qstr data
113110

114-
# Adding an order only dependency on $(HEADER_PY_BUILD) causes $(HEADER_PY_BUILD) to get
111+
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
115112
# created before we run the script to generate the .h
116-
$(HEADER_PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_PY_BUILD)
113+
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
114+
$(ECHO) "CPP $<"
115+
$(Q)$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_BUILD)/qstrdefs.preprocessed.h
117116
$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
118-
$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h
119-
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
117+
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
120118

121119
# We don't know which source files actually need the generated.h (since
122120
# it is #included from str.h). The compiler generated dependencies will cause
123121
# the right .o's to get recompiled if the generated.h file changes. Adding
124122
# an order-only dependendency to all of the .o's will cause the generated .h
125123
# to get built before we try to compile any of them.
126-
$(PY_O): | $(HEADER_PY_BUILD)/qstrdefs.generated.h $(HEADER_PY_BUILD)/py-version.h
124+
$(PY_O): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/py-version.h
127125

128126
# emitters
129127

py/qstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const static qstr_pool_t const_pool = {
6060
(const byte*) "\0\0\0\0", // invalid/no qstr has empty data
6161
(const byte*) "\0\0\0\0", // empty qstr
6262
#define Q(id, str) str,
63-
#include "build/py/qstrdefs.generated.h"
63+
#include "genhdr/qstrdefs.generated.h"
6464
#undef Q
6565
},
6666
};

py/qstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum {
88
MP_QSTR_NULL = 0, // indicates invalid/no qstr
99
MP_QSTR_ = 1, // the empty qstr
1010
#define Q(id, str) MP_QSTR_##id,
11-
#include "build/py/qstrdefs.generated.h"
11+
#include "genhdr/qstrdefs.generated.h"
1212
#undef Q
1313
MP_QSTR_number_of,
1414
};

stm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CROSS_COMPILE = arm-none-eabi-
1919

2020
INC = -I.
2121
INC += -I$(PY_SRC)
22-
INC += -I$(BUILD)/includes
22+
INC += -I$(BUILD)
2323
INC += -I$(CMSIS_DIR)
2424
INC += -I$(STMPERIPH_DIR)
2525
INC += -I$(STMUSB_DIR)

stmhal/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CROSS_COMPILE = arm-none-eabi-
1818

1919
INC = -I.
2020
INC += -I$(PY_SRC)
21-
INC += -I$(BUILD)/includes
21+
INC += -I$(BUILD)
2222
INC += -I$(CMSIS_DIR)/inc
2323
INC += -I$(CMSIS_DIR)/devinc
2424
INC += -I$(HAL_DIR)/inc

stmhal/adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "runtime.h"
1111
#include "adc.h"
1212
#include "pin.h"
13-
#include "build/pins.h"
13+
#include "genhdr/pins.h"
1414
#include "timer.h"
1515

1616
// Usage Model:

stmhal/led.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "timer.h"
1111
#include "led.h"
1212
#include "pin.h"
13-
#include "build/pins.h"
13+
#include "genhdr/pins.h"
1414

1515
typedef struct _pyb_led_obj_t {
1616
mp_obj_base_t base;

stmhal/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static const char fresh_main_py[] =
134134
;
135135

136136
static const char fresh_pybcdc_inf[] =
137-
#include "build/pybcdc_inf.h"
137+
#include "genhdr/pybcdc_inf.h"
138138
;
139139

140140
static const char fresh_readme_txt[] =

0 commit comments

Comments
 (0)