File: wrap_yasm.py

package info (click to toggle)
yasm 1.3.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,880 kB
  • sloc: asm: 74,423; ansic: 53,055; python: 9,927; sh: 5,276; xml: 1,617; makefile: 214; pascal: 95; sed: 16
file content (57 lines) | stat: -rwxr-xr-x 1,294 bytes parent folder | download | duplicates (16)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python

""" 

(c) 2002, 2003, 2004, 2005 Simon Burton <simon@arrowtheory.com>
Released under GNU LGPL license.

version 0.xx

"""


import sys
import os

from work_unit import WorkUnit, get_syms
import ir


def mk_tao(CPPFLAGS = "", CPP = "gcc -E", modname = '_yasm', oname = None, YASM_DIR = ".", **options):
    if oname is None:
        oname = modname+'.pyx'
    CPPFLAGS += " -I"+YASM_DIR
    CPPFLAGS += " -DYASM_PYXELATOR"
    CPPFLAGS += " -DYASM_LIB_INTERNAL"
    CPPFLAGS += " -DYASM_BC_INTERNAL"
    CPPFLAGS += " -DYASM_EXPR_INTERNAL"
    files = [ 'libyasm.h', 'libyasm/assocdat.h', 'libyasm/bitvect.h' ]

    syms = get_syms( ['yasm'], [YASM_DIR] )
    def cb(trans_unit, node, *args):
        name, file = node.name, node.file
        return True
        return name in syms
    extradefs = ""
    unit = WorkUnit(files,modname,oname,False,mark_cb=cb,extradefs=extradefs,
        CPPFLAGS=CPPFLAGS, CPP=CPP, **options)


    unit.parse( False )
    unit.transform(verbose=False, test_parse=False, test_types=False)
    unit.output()

def main():
    options = {}
    for i,arg in enumerate(sys.argv[1:]):
        if arg.count('='):
            key,val = arg.split('=', 1)
            options[key]=val
    mk_tao(**options)

if __name__=="__main__":
    main()