|
12 | 12 | mpy_crossas_mpy_cross |
13 | 13 | ) |
14 | 14 |
|
15 | | - |
16 | 15 | from .importunix |
| 16 | +from .importspawn |
17 | 17 |
|
18 | 18 |
|
19 | 19 | unix.REAL_PORT='macOS' |
@@ -58,7 +58,81 @@ def build_sdl(_): |
58 | 58 | unix.build_sdl=build_sdl |
59 | 59 |
|
60 | 60 |
|
| 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 | + |
61 | 94 | 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 | + |
62 | 136 | berkeley_db=os.path.abspath('lib/micropython/lib/berkeley-db-1.xx/README') |
63 | 137 |
|
64 | 138 | ifnotos.path.exists(berkeley_db): |
|