File: genapis.py

package info (click to toggle)
python-numarray 1.5.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,668 kB
  • ctags: 11,384
  • sloc: ansic: 113,864; python: 22,422; makefile: 197; sh: 11
file content (69 lines) | stat: -rw-r--r-- 2,280 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os, genapi, sys

def move(s, d):
    try:
        os.remove(d);
    except:
        pass;
    os.rename(s, d);

def check_rebuild(source, target):
    if not os.path.exists(target):
        return 1
    targettime = os.path.getmtime(target)
    sourcetime = os.path.getmtime(source)
    return targettime <= sourcetime

def need_rebuild(sources, targets):
    for t in targets:
        for s in sources:
            if check_rebuild(s, t):
                return 1
    return 0
        
def main():
    functions="Include/numarray/libnumarray.fnc"
    
    body_files=["Src/libnumarray.ch"]
    
    extra_dependencies=["Include/numarray/genapis.py",
                        "Include/numarray/genapi.py"]

    outputs=["Include/numarray/libnumarray.h",
             "Src/libnumarraymodule.c"]
    
    header_includes=["arraybase.h",
                     "nummacro.h",
                     "numcomplex.h",
                     "ieeespecial.h",
                     "cfunc.h"]
    
    if (need_rebuild( [functions] + body_files + extra_dependencies, outputs)
        or "--check-dates" not in sys.argv):
        
        genapi.main(module="libnumarray",
                    qualified_module="numarray.libnumarray",
                    functions=functions,
                    header_includes=header_includes,
                    body_files=body_files)
        move("libnumarray.h", "Include/numarray/libnumarray.h")
        move("libnumarray.c", "Src/libnumarraymodule.c")

        genapi.main(module="libteacup",
                    qualified_module="numarray.libteacup",
                    functions = "Include/numarray/libteacup.fnc",
                    header_includes = [],
                    body_files=["Src/teacup.ch"]);
        move("libteacup.h","Include/numarray/libteacup.h");
        move("libteacup.c", "Src/libteacupmodule.c");

        genapi.main(module="libnumeric",
                    qualified_module="numarray.libnumeric",
                    functions = "Include/numarray/libnumeric.fnc",
                    header_includes = [],
                    body_files=["Src/libnumeric.ch"])
        move("libnumeric.h", "Include/numarray/libnumeric.h");
        move("libnumeric.c", "Src/libnumericmodule.c")
    
if __name__ == "__main__":
    main()