Skip to content

Commit 2219d72

Browse files
committed
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
1 parent 5ab82ef commit 2219d72

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

bricks/ev3dev/Makefile

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ CFLAGS_MOD += -DPB_HAVE_LIBI2C=1
190190
LDFLAGS_MOD += -li2c
191191
endif
192192

193-
# source files
194-
SRC_C = $(addprefix micropython/ports/unix/,\
193+
# Extra core MicroPython files
194+
195+
# NB: Since we are using MicroPython's build system, files in the micropython/
196+
# directory have the micropython/ prefix excluded. It is very important to do
197+
# it that way since there is special handling of certain files that will break
198+
# if we don't do it this way. So we need to be very careful about name clashes
199+
# between the top level directory and the micropython/ subdirectory.
200+
201+
SRC_C = $(addprefix ports/unix/,\
195202
alloc.c \
196203
coverage.c \
197204
gccollect.c \
@@ -209,6 +216,13 @@ SRC_C = $(addprefix micropython/ports/unix/,\
209216

210217
SRC_C += $(SRC_MOD)
211218

219+
LIB_SRC_C = $(addprefix lib/,\
220+
$(LIB_SRC_C_EXTRA) \
221+
timeutils/timeutils.c \
222+
utils/gchelper_generic.c \
223+
utils/pyexec.c \
224+
)
225+
212226
# Pybricks port core source files
213227
PYBRICKS_SRC_C += \
214228
ev3dev_mphal.c \
@@ -221,13 +235,6 @@ PYBRICKS_SRC_C += \
221235
pbinit.c \
222236
pbsmbus.c \
223237

224-
LIB_SRC_C = $(addprefix micropython/lib/,\
225-
$(LIB_SRC_C_EXTRA) \
226-
timeutils/timeutils.c \
227-
utils/gchelper_generic.c \
228-
utils/pyexec.c \
229-
)
230-
231238
# Pybricks drivers and modules
232239
PYBRICKS_PYBRICKS_SRC_C = $(addprefix pybricks/,\
233240
pybricks.c \

bricks/nxt/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ SRC_C = \
8787
main.c \
8888
systick.c \
8989

90-
SRC_C += $(addprefix micropython/lib/,\
90+
# Extra core MicroPython files
91+
92+
# NB: Since we are using MicroPython's build system, files in the micropython/
93+
# directory have the micropython/ prefix excluded. It is very important to do
94+
# it that way since there is special handling of certain files that will break
95+
# if we don't do it this way. So we need to be very careful about name clashes
96+
# between the top level directory and the micropython/ subdirectory.
97+
98+
SRC_C += $(addprefix lib/,\
9199
libc/string0.c \
92100
mp-readline/readline.c \
93101
utils/interrupt_char.c \
@@ -96,7 +104,7 @@ SRC_C += $(addprefix micropython/lib/,\
96104
)
97105

98106
SRC_S = \
99-
micropython/lib/utils/gchelper_arm7tdmi.s \
107+
lib/utils/gchelper_arm7tdmi.s \
100108

101109
SRC_C_NXT := $(addprefix nxt-firmware-drivers/nxt/,\
102110
aic.c \

bricks/stm32/stm32.mk

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ SRC_C = $(addprefix bricks/stm32/,\
160160
uart_core.c \
161161
)
162162

163-
SRC_C += $(addprefix micropython/lib/,\
163+
# Extra core MicroPython files
164+
165+
# NB: Since we are using MicroPython's build system, files in the micropython/
166+
# directory have the micropython/ prefix excluded. It is very important to do
167+
# it that way since there is special handling of certain files that will break
168+
# if we don't do it this way. So we need to be very careful about name clashes
169+
# between the top level directory and the micropython/ subdirectory.
170+
171+
SRC_C += $(addprefix lib/,\
164172
libc/string0.c \
165173
mp-readline/readline.c \
166174
utils/interrupt_char.c \
@@ -172,9 +180,9 @@ SRC_S = \
172180
lib/pbio/platform/$(PBIO_PLATFORM)/startup.s \
173181

174182
ifeq ($(PB_MCU_SERIES),F0)
175-
SRC_S += micropython/lib/utils/gchelper_m0.s
183+
SRC_S += lib/utils/gchelper_m0.s
176184
else
177-
SRC_S += micropython/lib/utils/gchelper_m0.s
185+
SRC_S += lib/utils/gchelper_m0.s
178186
endif
179187

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

319327
COPT += -DUSE_FULL_LL_DRIVER
320328

321-
HAL_SRC_C = $(addprefix micropython/lib/stm32lib/STM32$(PB_MCU_SERIES)xx_HAL_Driver/Src/,\
329+
HAL_SRC_C = $(addprefix lib/stm32lib/STM32$(PB_MCU_SERIES)xx_HAL_Driver/Src/,\
322330
stm32$(PB_MCU_SERIES_LCASE)xx_hal_adc_ex.c \
323331
stm32$(PB_MCU_SERIES_LCASE)xx_hal_adc.c \
324332
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
453461

454462
# MicroPython math library
455463

456-
SRC_LIBM = $(addprefix micropython/lib/libm/,\
464+
SRC_LIBM = $(addprefix lib/libm/,\
457465
acoshf.c \
458466
asinfacosf.c \
459467
asinhf.c \

0 commit comments

Comments
 (0)