Skip to content

Commit e3aebc3

Browse files
committed
trying to fix macOS port with mbedtls
1 parent 232daff commit e3aebc3

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

builder/macOS.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
from . import unix
1616
from . import spawn
1717

18-
unix.unix_cmd = [
19-
'make',
20-
'',
21-
'',
22-
'-C',
23-
]
18+
from . import read_file, write_file
19+
2420

2521
unix.REAL_PORT = 'macOS'
2622

@@ -33,8 +29,6 @@ def parse_args(extra_args, lv_cflags, board):
3329

3430

3531
def build_commands(not_sure, extra_args, script_dir, lv_cflags, board):
36-
37-
3832
return _build_commands(not_sure, extra_args, script_dir, lv_cflags, board)
3933

4034

@@ -98,6 +92,9 @@ def is_homebrew_arm(cmd):
9892
return False, cmd[0][0]
9993

10094

95+
EXTMOD_MK_PATH = 'lib/micropython/extmod/extmod.mk'
96+
97+
10198
def submodules():
10299
is_arm, brew_path = is_homebrew_arm([['brew', 'config']])
103100

@@ -150,8 +147,35 @@ def submodules():
150147
if return_code != 0:
151148
sys.exit(return_code)
152149

150+
mbedtls = os.path.abspath('lib/micropython/lib/mbedtls/README.md')
151+
152+
if not os.path.exists(mbedtls):
153+
return_code, _ = unix.spawn(unix.submodules_cmd)
154+
155+
if return_code != 0:
156+
sys.exit(return_code)
153157

154158
def compile(*args): # NOQA
159+
data = read_file('macOS', EXTMOD_MK_PATH)
160+
data = data.replace(
161+
'CFLAGS_EXTMOD += -DMICROPY_SSL_MBEDTLS=1 -I$(TOP)/$(MBEDTLS_DIR)/include',
162+
'CFLAGS_EXTMOD += -DMICROPY_SSL_MBEDTLS=1'
163+
)
164+
code = [
165+
'SRC_THIRDPARTY_C += lib/mbedtls_errors/mp_mbedtls_errors.c',
166+
'SRC_THIRDPARTY_C += $(wildcard \\',
167+
' $(MBEDTLS_DIR)/include/*/*.h \\',
168+
' $(MBEDTLS_DIR)/library/*.h \\',
169+
')'
170+
]
171+
172+
data = data.replace(
173+
'SRC_THIRDPARTY_C += lib/mbedtls_errors/mp_mbedtls_errors.c',
174+
'\n'.join(code)
175+
)
176+
177+
write_file(EXTMOD_MK_PATH, data)
178+
155179
_compile(*args)
156180

157181

0 commit comments

Comments
 (0)