From 2219d726009b023216191a525ac54530eefce4f2 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 7 Jan 2021 10:32:57 -0600 Subject: [PATCH] bricks: fix broken build due to micropython/ subdirectory 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 --- bricks/ev3dev/Makefile | 25 ++++++++++++++++--------- bricks/nxt/Makefile | 12 ++++++++++-- bricks/stm32/stm32.mk | 18 +++++++++++++----- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/bricks/ev3dev/Makefile b/bricks/ev3dev/Makefile index 50b8a0b63..cdaf1d62a 100644 --- a/bricks/ev3dev/Makefile +++ b/bricks/ev3dev/Makefile @@ -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 \ @@ -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 \ @@ -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 \ diff --git a/bricks/nxt/Makefile b/bricks/nxt/Makefile index 91068d0b2..7c629ab18 100644 --- a/bricks/nxt/Makefile +++ b/bricks/nxt/Makefile @@ -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 \ @@ -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 \ diff --git a/bricks/stm32/stm32.mk b/bricks/stm32/stm32.mk index cfe552fb3..516bc2d21 100644 --- a/bricks/stm32/stm32.mk +++ b/bricks/stm32/stm32.mk @@ -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 \ @@ -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 @@ -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 \ @@ -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 \