Skip to content

Commit a13d7bd

Browse files
committed
adds support for raspberry pi unix compilation.
1 parent 887c659 commit a13d7bd

File tree

3 files changed

+90
-5
lines changed

3 files changed

+90
-5
lines changed

builder/raspberry_pi.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
import os
3+
4+
from .unix import (
5+
parse_args as _parse_args,
6+
build_commands as _build_commands,
7+
build_manifest as _build_manifest,
8+
force_clean as _force_clean,
9+
clean as _clean,
10+
build_sdl as _build_sdl,
11+
submodules as _submodules,
12+
compile as _compile,
13+
mpy_cross as _mpy_cross
14+
)
15+
16+
from . import unix
17+
18+
19+
def parse_args(extra_args, lv_cflags, board):
20+
return _parse_args(extra_args, lv_cflags, board)
21+
22+
23+
def build_commands(not_sure, extra_args, script_dir, lv_cflags, board):
24+
return _build_commands(not_sure, extra_args, script_dir, lv_cflags, board)
25+
26+
27+
def build_manifest(not_sure, script_dir, lvgl_api, displays, indevs, frozen_manifest):
28+
_build_manifest(not_sure, script_dir, lvgl_api, displays, indevs, frozen_manifest)
29+
30+
31+
def clean():
32+
_clean()
33+
34+
35+
def force_clean(clean_mpy_cross):
36+
_force_clean(clean_mpy_cross)
37+
38+
39+
def build_sdl(addl_commands):
40+
if addl_commands.startswith('"') and addl_commands.endswith('"'):
41+
addl_commands = addl_commands[1:-1]
42+
43+
if has_neon():
44+
addl_commands += ' CFLAGS="-mfpu=neon"'
45+
46+
_build_sdl(addl_commands.strip())
47+
48+
49+
unix.build_sdl = build_sdl
50+
51+
52+
def submodules():
53+
_submodules()
54+
55+
56+
def compile(*args): # NOQA
57+
_compile(*args)
58+
59+
60+
def mpy_cross():
61+
_mpy_cross()
62+
63+
64+
def has_neon():
65+
"""
66+
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
67+
"""
68+
69+
res = False
70+
71+
with os.popen('cat /proc/cpuinfo') as file:
72+
for line in file:
73+
if not line.startswith('Features'):
74+
continue
75+
76+
features = line.split(':')[-1].strip().split(' ')
77+
res = 'neon' in features
78+
79+
if res:
80+
break
81+
82+
return res

builder/unix.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _run(c, spinner=False, cmpl=False):
154154
sys.exit(res)
155155

156156

157-
def build_sdl():
157+
def build_sdl(addl_commands):
158158
dst = f'lib/micropython/ports/unix/build-{variant}/SDL'
159159

160160
if not os.path.exists(dst):
@@ -167,7 +167,7 @@ def build_sdl():
167167
cmd_ = [
168168
[
169169
f'cmake -DSDL_STATIC=ON -DSDL_SHARED=OFF '
170-
f'-DCMAKE_BUILD_TYPE=Release {sdl_flags} {SCRIPT_PATH}/lib/SDL'
170+
f'-DCMAKE_BUILD_TYPE=Release {addl_commands} {SCRIPT_PATH}/lib/SDL'
171171
],
172172
[f'cmake --build . --config Release --parallel {os.cpu_count()}']
173173
]
@@ -407,7 +407,7 @@ def compile(*args): # NOQA
407407
update_mpconfigport_mk()
408408
copy_updated_files()
409409

410-
build_sdl()
410+
build_sdl(sdl_flags)
411411

412412
cmd_ = compile_cmd[:]
413413
cmd_.extend(list(args))

make.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
help='build target',
1919
choices=[
2020
'esp32', 'windows', 'stm32', 'unix', 'rp2',
21-
'renesas-ra', 'nrf', 'mimxrt', 'samd', 'macOS'
21+
'renesas-ra', 'nrf', 'mimxrt', 'samd', 'macOS', 'raspberry_pi'
2222
],
2323
action='store',
2424
nargs=1
@@ -45,7 +45,7 @@
4545
default=None
4646
)
4747

48-
if target in ('windows', 'unix'):
48+
if target in ('windows', 'unix', 'macOS', 'raspberry_pi'):
4949
argParser.add_argument(
5050
'VARIANT',
5151
dest='board',
@@ -188,6 +188,9 @@ def create_lvgl_header():
188188
elif target.lower() == 'macos':
189189
from builder import macOS as mod
190190
target = 'unix'
191+
elif target.lower() == 'raspberry_pi':
192+
from builder import raspberry_pi as mod
193+
target = 'unix'
191194
elif target.lower() == 'windows':
192195
from builder import windows as mod
193196
else:

0 commit comments

Comments
 (0)