Skip to content

Commit 62baff8

Browse files
committed
bricks/virtualhub: Replace with embedded simulation.
Instead of using the newly introduced simhub alongside the virtualhub, we'll just replace the old one entirely now that it has reached feature parity. We can keep calling it the virtualhub.
1 parent 945b443 commit 62baff8

31 files changed

+148
-1024
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
uses: coverallsapp/github-action@v2
174174
with:
175175
github-token: ${{ secrets.GITHUB_TOKEN }}
176-
file: bricks/simhub/build-coverage/lcov.info
176+
file: bricks/virtualhub/build-coverage/lcov.info
177177
flag-name: virtualhub
178178
parallel: true
179179

.vscode/c_cpp_properties.json

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -341,31 +341,6 @@
341341
"cStandard": "c11",
342342
"intelliSenseMode": "gcc-arm"
343343
},
344-
{
345-
"name": "virtualhub",
346-
"includePath": [
347-
"${workspaceFolder}/bricks/virtualhub",
348-
"${workspaceFolder}/bricks/virtualhub/build",
349-
"${workspaceFolder}/lib/contiki-core",
350-
"${workspaceFolder}/lib/lego",
351-
"${workspaceFolder}/lib/lwrb/src/include",
352-
"${workspaceFolder}/lib/pbio",
353-
"${workspaceFolder}/lib/pbio/include",
354-
"${workspaceFolder}/lib/pbio/platform/virtual_hub",
355-
"${workspaceFolder}/micropython/ports/unix",
356-
"${workspaceFolder}/micropython",
357-
"${workspaceFolder}",
358-
"/usr/include/python3.10"
359-
],
360-
"defines": [
361-
"UNIX",
362-
"MICROPY_MODULE_FROZEN_MPY",
363-
"MICROPY_USE_READLINE=1"
364-
],
365-
"compilerPath": "/usr/bin/gcc",
366-
"cStandard": "c11",
367-
"intelliSenseMode": "gcc-x64"
368-
},
369344
{
370345
"name": "pbio/test",
371346
"includePath": [
@@ -388,16 +363,16 @@
388363
"cStandard": "c11"
389364
},
390365
{
391-
"name": "simhub",
366+
"name": "virtualhub",
392367
"includePath": [
393-
"${workspaceFolder}/bricks/simhub",
394-
"${workspaceFolder}/bricks/simhub/build",
368+
"${workspaceFolder}/bricks/virtualhub",
369+
"${workspaceFolder}/bricks/virtualhub/build",
395370
"${workspaceFolder}/lib/contiki-core",
396371
"${workspaceFolder}/lib/lego",
397372
"${workspaceFolder}/lib/lwrb/src/include",
398373
"${workspaceFolder}/lib/pbio",
399374
"${workspaceFolder}/lib/pbio/include",
400-
"${workspaceFolder}/lib/pbio/platform/sim_hub",
375+
"${workspaceFolder}/lib/pbio/platform/virtual_hub",
401376
"${workspaceFolder}/micropython",
402377
"${workspaceFolder}",
403378
"/usr/include/python3.10"

.vscode/launch.json

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,38 +53,6 @@
5353
"args": [],
5454
"console": "integratedTerminal"
5555
},
56-
{
57-
"name": "virtualhub",
58-
"type": "cppdbg",
59-
"request": "launch",
60-
"program": "${workspaceFolder}/bricks/virtualhub/build-debug/virtualhub-micropython",
61-
"args": [
62-
"${workspaceFolder}/tests/virtualhub/motor/car.py"
63-
],
64-
"stopAtEntry": false,
65-
"cwd": "${workspaceFolder}",
66-
"environment": [
67-
{
68-
"name": "PBIO_TEST_CONNECT_SOCKET",
69-
"value": "true"
70-
},
71-
],
72-
"externalConsole": false,
73-
"MIMode": "gdb",
74-
"setupCommands": [
75-
{
76-
"description": "Enable pretty-printing for gdb",
77-
"text": "-enable-pretty-printing",
78-
"ignoreFailures": true
79-
},
80-
{
81-
"description": "Ignore timer signal",
82-
"text": "handle SIG34 noprint pass",
83-
"ignoreFailures": false
84-
}
85-
],
86-
"preLaunchTask": "build virtualhub"
87-
},
8856
{
8957
"name":"Virtual Hub Animation",
9058
"type":"debugpy",
@@ -93,12 +61,12 @@
9361
"console":"integratedTerminal"
9462
},
9563
{
96-
"name": "simhub",
64+
"name": "virtualhub",
9765
"type": "cppdbg",
9866
"request": "launch",
99-
"program": "${workspaceFolder}/bricks/simhub/build-debug/firmware.elf",
67+
"program": "${workspaceFolder}/bricks/virtualhub/build-debug/firmware.elf",
10068
"args": [
101-
"${workspaceFolder}/tests/virtualhub/basics/hello.py",
69+
"${workspaceFolder}/tests/virtualhub/motor/car.py",
10270
],
10371
"stopAtEntry": false,
10472
"cwd": "${workspaceFolder}",
@@ -122,7 +90,7 @@
12290
"ignoreFailures": false
12391
}
12492
],
125-
"preLaunchTask": "build simhub (debug)"
93+
"preLaunchTask": "build virtualhub (debug)"
12694
},
12795
{
12896
"name": "test-pbio",

.vscode/tasks.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,11 @@
3636
],
3737
"detail": "Build the PrimeHub project"
3838
},
39-
{
40-
"label": "build virtualhub",
41-
"type": "shell",
42-
"command": "poetry run make -C bricks/virtualhub DEBUG=1 COPT=-O0 CROSS_COMPILE= -j"
43-
},
4439
{
4540
"options": {
46-
"cwd": "${workspaceFolder}/bricks/simhub"
41+
"cwd": "${workspaceFolder}/bricks/virtualhub"
4742
},
48-
"label": "build simhub (debug)",
43+
"label": "build virtualhub (debug)",
4944
"type": "shell",
5045
"command": "make -C ../../micropython/mpy-cross -j && poetry run make DEBUG=1 BUILD=build-debug -j",
5146
},

Makefile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ doc:
2828
clean-doc:
2929
@$(MAKE) -C lib/pbio/doc clean
3030

31-
all: movehub cityhub technichub primehub essentialhub virtualhub simhub nxt ev3 doc
31+
all: movehub cityhub technichub primehub essentialhub virtualhub nxt ev3 doc
3232

33-
clean-all: clean-movehub clean-cityhub clean-technichub clean-primehub clean-essentialhub clean-virtualhub clean-simhub clean-nxt clean-ev3 clean-doc
33+
clean-all: clean-movehub clean-cityhub clean-technichub clean-primehub clean-essentialhub clean-virtualhub clean-nxt clean-ev3 clean-doc
3434

3535
ev3: mpy-cross
3636
@$(MAKE) -C bricks/ev3
@@ -78,15 +78,8 @@ virtualhub: mpy-cross
7878
@$(MAKE) -C bricks/virtualhub CROSS_COMPILE=
7979

8080
clean-virtualhub: clean-mpy-cross
81-
@$(MAKE) -C bricks/virtualhub clean CROSS_COMPILE=
82-
@$(MAKE) -C bricks/virtualhub clean DEBUG=1
83-
84-
simhub: mpy-cross
85-
@$(MAKE) -C bricks/simhub CROSS_COMPILE=
86-
87-
clean-simhub: clean-mpy-cross
88-
@$(MAKE) -C bricks/simhub clean
89-
@$(MAKE) -C bricks/simhub clean BUILD=build-debug
81+
@$(MAKE) -C bricks/virtualhub clean
82+
@$(MAKE) -C bricks/virtualhub clean BUILD=build-debug
9083

9184
mpy-cross:
9285
@$(MAKE) -C micropython/mpy-cross CROSS_COMPILE=$(HOST_CROSS_COMPILE)

bricks/_common/common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ PY_EXTRA_SRC_C += $(addprefix shared/,\
258258
runtime/gchelper_generic.c \
259259
runtime/sys_stdio_mphal.c \
260260
)
261-
PY_EXTRA_SRC_C += $(addprefix bricks/simhub/,\
261+
PY_EXTRA_SRC_C += $(addprefix bricks/virtualhub/,\
262262
pbio_os_hook.c \
263263
)
264264
else

bricks/simhub/Makefile

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

bricks/simhub/qstrdefsport.h

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.

bricks/virtualhub/Makefile

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,10 @@
11
# SPDX-License-Identifier: MIT
2-
# Copyright (c) 2022 The Pybricks Authors
2+
# Copyright (c) 2025 The Pybricks Authors
33

4-
# Need a default target so that make can be called without specifying one.
5-
all:
4+
PBIO_PLATFORM = virtual_hub
5+
PB_MCU_FAMILY = native
6+
PB_FROZEN_MODULES = 1
7+
MICROPY_ROM_TEXT_COMPRESSION = 1
68

7-
# place coverage/debug build in separate folder so we don't have to remember to clean and rebuild
8-
ifeq ($(COVERAGE),1)
9-
BUILD_DIR = build-coverage
10-
export CFLAGS = --coverage
11-
export LDFLAGS = --coverage
12-
else
13-
ifeq ($(DEBUG),1)
14-
BUILD_DIR = build-debug
15-
export COPT = -O0
16-
else
17-
BUILD_DIR = build
18-
endif
19-
endif
209

21-
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
22-
PBTOP := $(patsubst %/bricks/virtualhub/Makefile,%,$(mkfile_path))
23-
ifeq ("$(wildcard $(PBTOP)/micropython/lib/micropython-lib/README.md)","")
24-
$(info GIT cloning micropython-lib submodule)
25-
$(info $(shell cd $(PBTOP)/micropython && git submodule update --init lib/micropython-lib))
26-
ifeq ("$(wildcard $(PBTOP)/micropython/lib/micropython-lib/README.md)","")
27-
$(error failed)
28-
endif
29-
endif
30-
31-
# Include frozen manifest only if there is anything to freeze.
32-
ifneq ("$(wildcard ../../bricks/_common/modules/*.py)","")
33-
FROZEN_MANIFEST ?= ../../../bricks/_common/manifest.py
34-
else
35-
FROZEN_MANIFEST =
36-
endif
37-
38-
# The virtual hub is a unix port variant, so pass everything to the upstream
39-
# MicroPython makefile.
40-
%:
41-
$(MAKE) -C ../../micropython/ports/unix \
42-
VARIANT=virtualhub \
43-
VARIANT_DIR=../../../bricks/virtualhub \
44-
BUILD=../../../bricks/virtualhub/$(BUILD_DIR) \
45-
PROG=../../../bricks/virtualhub/$(BUILD_DIR)/virtualhub-micropython \
46-
FROZEN_MANIFEST=$(FROZEN_MANIFEST) \
47-
QSTR_DEFS=../../../bricks/_common/qstrdefs.h \
48-
QSTR_GLOBAL_DEPENDENCIES=../../../bricks/virtualhub/mpconfigvariant.h \
49-
$@
10+
include ../_common/common.mk

0 commit comments

Comments
 (0)