Skip to content

Commit

Permalink
bricks: fix broken build due to micropython/ subdirectory
Browse files Browse the repository at this point in the history
The MicroPython build system expects MicroPython source code to be in
the top level directory, but in Pybricks it is not. Since we were adding
`micropython/` to the path, it was causing certain extra build options
to be missed, like the fix for micropython/micropython#6053.

Removing `micropython/` fixes this.

Fixes: pybricks/pybricks-micropython#40
  • Loading branch information
dlech committed Jan 7, 2021
1 parent 5ab82ef commit 2219d72
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
25 changes: 16 additions & 9 deletions bricks/ev3dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,15 @@ CFLAGS_MOD += -DPB_HAVE_LIBI2C=1
LDFLAGS_MOD += -li2c
endif

# source files
SRC_C = $(addprefix micropython/ports/unix/,\
# Extra core MicroPython files

# NB: Since we are using MicroPython's build system, files in the micropython/
# directory have the micropython/ prefix excluded. It is very important to do
# it that way since there is special handling of certain files that will break
# if we don't do it this way. So we need to be very careful about name clashes
# between the top level directory and the micropython/ subdirectory.

SRC_C = $(addprefix ports/unix/,\
alloc.c \
coverage.c \
gccollect.c \
Expand All @@ -209,6 +216,13 @@ SRC_C = $(addprefix micropython/ports/unix/,\

SRC_C += $(SRC_MOD)

LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
timeutils/timeutils.c \
utils/gchelper_generic.c \
utils/pyexec.c \
)

# Pybricks port core source files
PYBRICKS_SRC_C += \
ev3dev_mphal.c \
Expand All @@ -221,13 +235,6 @@ PYBRICKS_SRC_C += \
pbinit.c \
pbsmbus.c \

LIB_SRC_C = $(addprefix micropython/lib/,\
$(LIB_SRC_C_EXTRA) \
timeutils/timeutils.c \
utils/gchelper_generic.c \
utils/pyexec.c \
)

# Pybricks drivers and modules
PYBRICKS_PYBRICKS_SRC_C = $(addprefix pybricks/,\
pybricks.c \
Expand Down
12 changes: 10 additions & 2 deletions bricks/nxt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ SRC_C = \
main.c \
systick.c \

SRC_C += $(addprefix micropython/lib/,\
# Extra core MicroPython files

# NB: Since we are using MicroPython's build system, files in the micropython/
# directory have the micropython/ prefix excluded. It is very important to do
# it that way since there is special handling of certain files that will break
# if we don't do it this way. So we need to be very careful about name clashes
# between the top level directory and the micropython/ subdirectory.

SRC_C += $(addprefix lib/,\
libc/string0.c \
mp-readline/readline.c \
utils/interrupt_char.c \
Expand All @@ -96,7 +104,7 @@ SRC_C += $(addprefix micropython/lib/,\
)

SRC_S = \
micropython/lib/utils/gchelper_arm7tdmi.s \
lib/utils/gchelper_arm7tdmi.s \

SRC_C_NXT := $(addprefix nxt-firmware-drivers/nxt/,\
aic.c \
Expand Down
18 changes: 13 additions & 5 deletions bricks/stm32/stm32.mk
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,15 @@ SRC_C = $(addprefix bricks/stm32/,\
uart_core.c \
)

SRC_C += $(addprefix micropython/lib/,\
# Extra core MicroPython files

# NB: Since we are using MicroPython's build system, files in the micropython/
# directory have the micropython/ prefix excluded. It is very important to do
# it that way since there is special handling of certain files that will break
# if we don't do it this way. So we need to be very careful about name clashes
# between the top level directory and the micropython/ subdirectory.

SRC_C += $(addprefix lib/,\
libc/string0.c \
mp-readline/readline.c \
utils/interrupt_char.c \
Expand All @@ -172,9 +180,9 @@ SRC_S = \
lib/pbio/platform/$(PBIO_PLATFORM)/startup.s \

ifeq ($(PB_MCU_SERIES),F0)
SRC_S += micropython/lib/utils/gchelper_m0.s
SRC_S += lib/utils/gchelper_m0.s
else
SRC_S += micropython/lib/utils/gchelper_m0.s
SRC_S += lib/utils/gchelper_m0.s
endif

# Pybricks modules
Expand Down Expand Up @@ -318,7 +326,7 @@ CONTIKI_SRC_C = $(addprefix lib/contiki-core/,\

COPT += -DUSE_FULL_LL_DRIVER

HAL_SRC_C = $(addprefix micropython/lib/stm32lib/STM32$(PB_MCU_SERIES)xx_HAL_Driver/Src/,\
HAL_SRC_C = $(addprefix lib/stm32lib/STM32$(PB_MCU_SERIES)xx_HAL_Driver/Src/,\
stm32$(PB_MCU_SERIES_LCASE)xx_hal_adc_ex.c \
stm32$(PB_MCU_SERIES_LCASE)xx_hal_adc.c \
stm32$(PB_MCU_SERIES_LCASE)xx_hal_cortex.c \
Expand Down Expand Up @@ -453,7 +461,7 @@ LSM6DS3TR_C_SRC_C = lib/lsm6ds3tr_c_STdC/driver/lsm6ds3tr_c_reg.c

# MicroPython math library

SRC_LIBM = $(addprefix micropython/lib/libm/,\
SRC_LIBM = $(addprefix lib/libm/,\
acoshf.c \
asinfacosf.c \
asinhf.c \
Expand Down

0 comments on commit 2219d72

Please sign in to comment.