File: munge_make_log.py

package info (click to toggle)
python-cython-blis 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 43,676 kB
  • sloc: ansic: 645,510; sh: 2,354; asm: 1,466; python: 821; cpp: 585; makefile: 14
file content (37 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
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
import os
import sys
import json

os_name = sys.argv[1]
arch_name = sys.argv[2]

print(json.dumps({"environment": dict(os.environ)}))
for line in sys.stdin:
    if 'flatten-headers.py' in line:
        continue
    line = line.replace('include/' + arch_name, 'include/' + os_name + '-' + arch_name)
    pieces = line.split()
    args = {}
    flags = []
    macros = []
    includes = []
    for i, piece in enumerate(pieces):
        if i == 0:
            args['compiler'] = piece
        elif piece == '-c':
            args['source'] = pieces[i+1]
        elif piece == '-o':
            args['target'] = pieces[i+1]
        elif piece.startswith('-f') or piece.startswith('-m') or piece.startswith('-O'):
            flags.append(piece)
        elif piece.startswith('-std'):
            flags.append(piece)
        elif piece.startswith('-D'):
            macros.append(piece.replace('\\', ''))
        elif piece.startswith('-I'):
            includes.append(piece)
    if 'source' in args:
        args['flags'] = flags
        args['macros'] = macros
        args['include'] = includes
        print(json.dumps(args))