Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit07597c6

Browse files
committed
Adds detection of libffi and sdl2 on macos using arm processor
1 parentcade7b4 commit07597c6

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

‎builder/macOS.py‎

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
mpy_crossas_mpy_cross
1313
)
1414

15-
1615
from .importunix
16+
from .importspawn
1717

1818

1919
unix.REAL_PORT='macOS'
@@ -58,7 +58,81 @@ def build_sdl(_):
5858
unix.build_sdl=build_sdl
5959

6060

61+
defis_homebrew_arm(cmd):
62+
ret_val,output=spawn(cmd,out_to_screen=False)
63+
ifret_val:
64+
ifcmd[0][0]=='/opt/homebrew/bin/brew':
65+
raiseRuntimeError('Unable to locate homebrew installation')
66+
67+
returnis_homebrew_arm([['/opt/homebrew/bin/brew','config']])
68+
69+
data= {line.split(':',1)[0].strip():line.split(':',1)[1].strip()for
70+
lineinoutput.split('\n')}
71+
72+
if'macOS'notindata:
73+
raiseRuntimeError('Unable to determine Homebrew CPU type')
74+
75+
if'arm64'indata['macOS']:
76+
if'Rosetta 2'notindata:
77+
ifcmd[0][0]!='/opt/homebrew/bin/brew':
78+
returnis_homebrew_arm([['/opt/homebrew/bin/brew','config']])
79+
80+
raiseRuntimeError('Unable to determine Homebrew platform')
81+
82+
ifdata['Rosetta 2']=='true':
83+
ifcmd[0][0]!='/opt/homebrew/bin/brew':
84+
returnis_homebrew_arm([['/opt/homebrew/bin/brew','config']])
85+
86+
raiseRuntimeError('Unable to locate Homebrew for Arm processors.')
87+
88+
returnTrue,cmd[0][0]
89+
90+
returnFalse,cmd[0][0]
91+
92+
93+
6194
defsubmodules():
95+
is_arm,brew_path=is_homebrew_arm([['brew','config']])
96+
97+
ifis_arm:
98+
ret,out=spawn([[brew_path,'info','libffi']],out_to_screen=False)
99+
ifret:
100+
print(out)
101+
sys.exit(ret)
102+
103+
if'Installed\n'notinout:
104+
raiseRuntimeError('libffi is not installed')
105+
106+
out=out.split('Installed\n',1)[-1]
107+
alt_path=out.split('(',1)[0].strip().split('Cellar',1)[0]
108+
109+
if'export LDFLAGS='inout:
110+
out=out.split('export LDFLAGS="',1)[-1]
111+
ldflags=out.split('"',1)[0]
112+
else:
113+
ldflags=f'-L{alt_path}opt/libffi/lib'
114+
115+
if'export CPPFLAGS='inout:
116+
out=out.split('export CPPFLAGS="',1)[-1]
117+
cflags=out.split('"',1)[0]
118+
else:
119+
cflags=f'-I{alt_path}opt/libffi/include'
120+
121+
ret,out=spawn([[brew_path,'info','sdl2']],out_to_screen=False)
122+
123+
ifret:
124+
print(out)
125+
sys.exit(ret)
126+
127+
if'Installed\n'notinout:
128+
raiseRuntimeError('sdl2 is not installed')
129+
130+
ldflags+=f' -L{alt_path}lib'
131+
cflags+=f' -I{alt_path}include'
132+
133+
os.environ['LDFLAGS']=f'"{ldflags}"'
134+
os.environ['CFLAGS']=f'"{cflags}"'
135+
62136
berkeley_db=os.path.abspath('lib/micropython/lib/berkeley-db-1.xx/README')
63137

64138
ifnotos.path.exists(berkeley_db):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp