11# SPDX-License-Identifier: MIT
22# Copyright (c) 2013, 2014 Damien P. George
3-
4- # Sanity check
5- include ../check.mk
6-
7- # Environment
8- -include mpconfigport.mk
9- include ../../../../py/mkenv.mk
3+ # Copyright (c) 2019-2020 The Pybricks Authors
104
115# ensure required git submodules checked out
12- ifeq ("$(wildcard $(TOP ) /lib/axtls/README) ","")
6+ ifeq ("$(wildcard ../../micropython/README.md) ","")
7+ $(info GIT cloning micropython submodule)
8+ $(info $(shell cd ../.. && git submodule update --init micropython))
9+ ifeq ("$(wildcard ../../micropython/README.md) ","")
10+ $(error failed)
11+ endif
12+ endif
13+ ifeq ("$(wildcard ../../micropython/lib/axtls/README) ","")
1314$(info GIT cloning axtls submodule)
14- $(shell cd $(TOP) && git submodule update --init lib/axtls)
15+ $(info $(shell cd ../../micropython && git submodule update --init lib/axtls))
16+ ifeq ("$(wildcard ../../micropython/lib/axtls/README) ","")
17+ $(error failed)
18+ endif
1519endif
16- ifeq ("$(wildcard $( TOP ) /lib/berkeley-db-1.xx/README) ","")
20+ ifeq ("$(wildcard ../../micropython /lib/berkeley-db-1.xx/README) ","")
1721$(info GIT cloning berkeley-db-1.xx submodule)
18- $(shell cd $(TOP) && git submodule update --init lib/berkeley-db-1.xx)
22+ $(info $(shell cd ../../micropython && git submodule update --init lib/berkeley-db-1.xx))
23+ ifeq ("$(wildcard ../../micropython/lib/berkeley-db-1.xx/README) ","")
24+ $(error failed)
1925endif
20- ifeq ("$(wildcard $(TOP ) /ports/pybricks/lib/libfixmath/README.md) ","")
26+ endif
27+ ifeq ("$(wildcard ../../lib/libfixmath/README.md) ","")
2128$(info GIT cloning libfixmath submodule)
22- $(shell cd $(TOP)/ports/pybricks && git submodule update --init lib/libfixmath)
29+ $(info $(shell cd ../.. && git submodule update --init lib/libfixmath))
30+ ifeq ("$(wildcard ../../lib/libfixmath/README.md) ","")
31+ $(error failed)
32+ endif
2333endif
2434
35+ # lets micropython make files work with external files
36+ USER_C_MODULES = ../..
37+
38+ # Environment
39+ -include mpconfigport.mk
40+ include ../../micropython/py/mkenv.mk
41+
2542FROZEN_DIR = scripts
2643FROZEN_MPY_DIR = modules
2744QSTR_GLOBAL_DEPENDENCIES = brickconfig.h
@@ -38,19 +55,19 @@ UNAME_S := $(shell uname -s)
3855# include py core make definitions
3956include $(TOP ) /py/py.mk
4057
41- INC += -I.
42- INC += -I$(TOP )
58+ INC += -I.
59+ INC += -I$(TOP )
4360INC += -I$(BUILD )
44- INC += -I$( TOP ) /ports/pybricks /lib/contiki-core
45- INC += -I$( TOP ) /ports/pybricks /lib/ev3dev
46- INC += -I$( TOP ) /ports/pybricks /lib/ev3dev/include
47- INC += -I$( TOP ) /ports/pybricks /lib/lego
48- INC += -I$( TOP ) /ports/pybricks /lib/libfixmath/libfixmath
49- INC += -I$( TOP ) /ports/pybricks /lib/pbio
50- INC += -I$( TOP ) /ports/pybricks /lib/pbio/include
51- INC += -I$( TOP ) /ports/pybricks /lib/pbio/platform/ev3dev_stretch
52- INC += -I$( TOP ) /ports/pybricks /extmod
53- INC += -I$( TOP ) /ports/pybricks /py
61+ INC += -I../.. /lib/contiki-core
62+ INC += -I../.. /lib/ev3dev
63+ INC += -I../.. /lib/ev3dev/include
64+ INC += -I../.. /lib/lego
65+ INC += -I../.. /lib/libfixmath/libfixmath
66+ INC += -I../.. /lib/pbio
67+ INC += -I../.. /lib/pbio/include
68+ INC += -I../.. /lib/pbio/platform/ev3dev_stretch
69+ INC += -I../.. /extmod
70+ INC += -I../.. /py
5471INC += -I$(TOP ) /ports/unix
5572
5673# compiler settings
@@ -165,7 +182,7 @@ LDFLAGS_MOD += -li2c
165182endif
166183
167184# source files
168- SRC_C = $(addprefix ports/unix/,\
185+ SRC_C = $(addprefix micropython/ ports/unix/,\
169186 main.c \
170187 gccollect.c \
171188 mpthreadport.c \
@@ -196,14 +213,14 @@ PYBRICKS_SRC_C += \
196213 pbinit.c \
197214 pbsmbus.c \
198215
199- LIB_SRC_C = $(addprefix lib/,\
216+ LIB_SRC_C = $(addprefix micropython/ lib/,\
200217 $(LIB_SRC_C_EXTRA ) \
201218 timeutils/timeutils.c \
202219 utils/pyexec.c \
203220 )
204221
205222# Pybricks drivers and modules
206- PYBRICKS_EXTMOD_SRC_C = $(addprefix ports/pybricks/ extmod/,\
223+ PYBRICKS_EXTMOD_SRC_C = $(addprefix extmod/,\
207224 modbattery.c \
208225 modbuiltins.c \
209226 modbuttons.c \
@@ -221,14 +238,14 @@ PYBRICKS_EXTMOD_SRC_C = $(addprefix ports/pybricks/extmod/,\
221238 moduos.c \
222239 )
223240
224- PYBRICKS_PY_SRC_C = $(addprefix ports/pybricks/ py/,\
241+ PYBRICKS_PY_SRC_C = $(addprefix py/,\
225242 pb_type_enum.c \
226243 pberror.c \
227244 pbobj.c \
228245 pbthread.c \
229246 )
230247
231- PYBRICKS_LIB_SRC_C = $(addprefix ports/pybricks/ lib/,\
248+ PYBRICKS_LIB_SRC_C = $(addprefix lib/,\
232249 contiki-core/sys/autostart.c \
233250 contiki-core/sys/etimer.c \
234251 contiki-core/sys/process.c \
@@ -296,7 +313,7 @@ include $(TOP)/py/mkrules.mk
296313
297314.PHONY : test
298315
299- EV3DEV_TEST_DIRS = $(addprefix ../ports/pybricks /tests/ev3dev/, \
316+ EV3DEV_TEST_DIRS = $(addprefix ../.. /tests/ev3dev/, \
300317 brick \
301318 experimental \
302319 media \
@@ -317,12 +334,12 @@ $(GRX_TEST_PLUGIN_LIB): $(GRX_TEST_PLUGIN_OBJ)
317334 $(Q )$(CC ) -shared -o $@ $^ $(LDFLAGS )
318335
319336test-ev3dev : $(PROG ) $(TOP ) /tests/run-tests $(GRX_TEST_PLUGIN_LIB )
320- cd $(TOP ) /tests && MICROPY_MICROPYTHON=" ../ports/pybricks /tests/ev3dev/test-wrapper.sh" \
337+ cd $(TOP ) /tests && MICROPY_MICROPYTHON=" ../.. /tests/ev3dev/test-wrapper.sh" \
321338 GRX_PLUGIN_PATH=$(realpath $(BUILD ) ) GRX_DRIVER=test \
322339 ./run-tests --test-dirs $(EV3DEV_TEST_DIRS )
323340
324341test : $(PROG ) $(TOP ) /tests/run-tests $(GRX_TEST_PLUGIN_LIB )
325- $(eval DIRNAME=ports/pybricks /bricks/$(notdir $(CURDIR ) ) )
342+ $(eval DIRNAME=.. /bricks/$(notdir $(CURDIR ) ) )
326343 cd $(TOP ) /tests && MICROPY_MICROPYTHON=../$(DIRNAME ) /$(PROG ) \
327344 GRX_PLUGIN_PATH=$(realpath $(BUILD ) ) GRX_DRIVER=test \
328345 ./run-tests
0 commit comments