aboutsummaryrefslogtreecommitdiff
path: root/desktop/scripts/macos-check-arch.py
blob: b0febef64ab4f32a2805c1cd463d7efeeda5ae47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3

import os, subprocess, sys

def main(argv):
    if len(argv) != 2:
        print("Usage: check-arch.py PATH_TO_APP", file = sys.stderr)
        sys.exit(-1)
    universal = []
    silicon = []
    intel = []
    for d in os.walk(argv[1]):
        ap = os.path.join(os.path.abspath('.'),d[0])
        for f in os.listdir(ap):
            fl = os.path.join(ap,f)
            if os.path.isfile(fl):
                a = subprocess.run(['file',fl], stdout = subprocess.PIPE)
                b = a.stdout.decode('utf-8')
                if 'binary' in b or 'executable' in b or 'library' in b:
                    arm64, x86 = False, False
                    if 'arm64' in b:
                        arm64 = True
                    if 'x86_64' in b:
                        x86 = True
                    if arm64 and x86:
                        universal += [fl]
                    elif arm64:
                        silicon += [fl]
                    elif x86:
                        intel += [fl]
    with open('macos-check-arch.log', 'w') as fout:
        fout.write('-*- Universal -*-\n')
        for p in universal:
            fout.write(p+'\n')
        fout.write('\n-*- Silicon -*-\n')
        for p in silicon:
            fout.write(p+'\n')
        fout.write('\n-*- Intel -*-\n')
        for p in intel:
            fout.write(p+'\n')

if __name__ == '__main__':
    main(sys.argv)