Skip to content

Commit 2f42cc7

Browse files
committed
git: invert submodule depedency
This make micropython a submodule of pybricks-micropython instead of the other way around. This makes it quite a bit simpler to checkout the code and keep the submodules in sync.
1 parent b14675a commit 2f42cc7

File tree

17 files changed

+246
-458
lines changed

17 files changed

+246
-458
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 272 deletions
Large diffs are not rendered by default.

.github/workflows/format.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,9 @@ jobs:
2222
- name: Checkout repo
2323
uses: actions/checkout@v2
2424
with:
25-
path: tmp
26-
- name: Get tag
27-
id: get_tag
28-
run: echo ::set-output name=micropython_tag::$(cat tmp/micropython-tag)
29-
- name: Checkout MicroPython
30-
uses: actions/checkout@v2
31-
with:
32-
repository: pybricks/micropython
33-
ref: ${{ steps.get_tag.outputs.micropython_tag }}
34-
path: micropython
25+
submodules: true
3526
token: ${{ secrets.GITHUB_TOKEN2 }}
36-
- name: Checkout Pybricks
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN2 }}
39-
run: |
40-
cd micropython
41-
git config submodule.ports/pybricks.url https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
42-
git submodule update --init --no-fetch ports/pybricks
43-
cd ports/pybricks
44-
git fetch --depth=1 origin $GITHUB_SHA
45-
git checkout FETCH_HEAD
4627
- name: Run codeformat.py
4728
run: |
48-
cd micropython/ports/pybricks
4929
./tools/codeformat.py
5030
git diff --exit-code

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
###################
33
*.o
44
*.a
5+
*.P
56
*.elf
67
*.bin
78
*.map
@@ -31,6 +32,10 @@ _build/
3132
tests/*.exp
3233
tests/*.out
3334

35+
# Python virtual environment
36+
############################
37+
.venv/
38+
3439
# Python cache files
3540
######################
3641
__pycache__/

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
[submodule "bricks/nxt/nxt-firmware-drivers"]
99
path = bricks/nxt/nxt-firmware-drivers
1010
url = https://github.com/pybricks/nxt-firmware-drivers.git
11+
update = none
12+
[submodule "micropython"]
13+
path = micropython
14+
url = https://github.com/pybricks/micropython
15+
branch = master

README.md

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,12 @@ our site, [pybricks.com].
6262

6363
But since you're reading this, you might be interested in building the code
6464
yourself, or start tweaking and hacking. We don't have step-by-step guides
65-
for installing all the developer tools just yet. But we build all targets
66-
from scratch using Travis CI, so you can get the complete recipes for each
67-
build in the [.travis file](.travis.yml).
65+
for installing all the developer tools just yet.
6866

6967
## Pybricks and Upstream MicroPython
7068

7169
We are actively contributing to upstream MicroPython instead of forking it into
72-
a whole new project. We are adding Pybricks as a new family of ports. Similar
73-
to how MicroPython already has a `ports/stm32` folder with multiple
74-
`boards`, we add a `ports/pybricks` folder with multiple programmable `bricks`.
70+
a whole new project.
7571

7672
To streamline development and releases, we do maintain a fork of `micropython`
7773
[here][pybricks/micropython]. It essentially just adds the repository that you
@@ -82,32 +78,20 @@ greatest that upstream [`micropython`][micropython/micropython] has to offer.
8278
Summing up:
8379

8480
- [`pybricks/micropython`][pybricks/micropython]: fork of
85-
[upstream MicroPython][micropython/micropython] that just adds the repo below
86-
as a submodule at `ports/pybricks`. It does not have a continuous master
87-
branch, just versioned tags. So, never do `git pull`, but do `git fetch` and
88-
then check out the tag you want.
81+
[upstream MicroPython][micropython/micropython] that is included as a
82+
submodule in the main `pybricks/micropython` repository.
8983
- [`pybricks/pybricks-micropython`][pybricks-micropython]: Main repo for all
9084
Pybricks firmware. This has a continuous master branch that never breaks.
91-
Always look at the [tag file](micropython-tag) to see which MicroPython tag
92-
must be checked out to build successfully.
9385

9486

9587
## Cloning
9688

97-
As explained above, this
98-
repository ([`pybricks/pybricks-micropython`][pybricks-micropython])
99-
is a submodule to [our fork of MicroPython][pybricks/micropython]. So instead
100-
of cloning this repository directly, do this:
89+
This project uses submodules. However we don't recommend using the
90+
`--recursive` option of `git` since it will clone unnecessary dependencies.
91+
Instead, the required submodules will be automatically cloned the first time
92+
you run `make`.
10193

102-
git clone https://github.com/pybricks/micropython
103-
cd micropython
104-
git submodule update --init --remote ports/pybricks
105-
cd ports/pybricks
106-
107-
Then you will find this repo at `ports/pybricks` in the `micropython` directory
108-
that was just cloned. Almost all development is done in here.
109-
The [`micropython-tag`](micropython-tag) file tells you which tag to checkout
110-
in [`pybricks/micropython`][pybricks/micropython].
94+
git clone https://github.com/pybricks/pybricks-micropython
11195

11296
## What about all the other repositories?
11397
Pybricks includes not just firmware for each LEGO hub, but also various tools,

bricks/check.mk

Lines changed: 0 additions & 14 deletions
This file was deleted.

bricks/ev3dev/Makefile

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
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
1519
endif
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)
1925
endif
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
2333
endif
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+
2542
FROZEN_DIR = scripts
2643
FROZEN_MPY_DIR = modules
2744
QSTR_GLOBAL_DEPENDENCIES = brickconfig.h
@@ -38,19 +55,19 @@ UNAME_S := $(shell uname -s)
3855
# include py core make definitions
3956
include $(TOP)/py/py.mk
4057

41-
INC += -I.
42-
INC += -I$(TOP)
58+
INC += -I.
59+
INC += -I$(TOP)
4360
INC += -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
5471
INC += -I$(TOP)/ports/unix
5572

5673
# compiler settings
@@ -165,7 +182,7 @@ LDFLAGS_MOD += -li2c
165182
endif
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

319336
test-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

324341
test: $(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

bricks/ev3dev/docker/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if ! which docker >/dev/null; then
2626
exit 1
2727
fi
2828

29-
src_dir="${script_dir}/../../../../.."
29+
src_dir="${script_dir}/../../.."
3030
build_dir="${script_dir}/../build-${arch}"
3131
image_name="docker.pkg.github.com/pybricks/pybricks-micropython/${project}-${arch}:latest"
3232
container_name="${project}_${arch}"
@@ -60,7 +60,7 @@ fi
6060
docker rm --force ${container_name} >/dev/null 2>&1 || true
6161
docker run \
6262
--volume "$(abs_path ${src_dir}):/src" \
63-
--workdir /src/ports/pybricks/bricks/ev3dev \
63+
--workdir /src/bricks/ev3dev \
6464
--name ${container_name} \
6565
--env "TERM=${TERM}" \
6666
--env "DESTDIR=/build/dist" \

0 commit comments

Comments
 (0)