File: update.py

package info (click to toggle)
pymol 1.7.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 42,668 kB
  • ctags: 25,775
  • sloc: ansic: 494,779; python: 75,446; cpp: 20,088; makefile: 351; sh: 172; csh: 21
file content (168 lines) | stat: -rw-r--r-- 4,737 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
if 0:
    print "DANGER DO NOT RUN UNTIL changes to the following files have been backported..."
    print "dcdplugin.c, gridplugin.c, endianswap.h, fastio.h, vmddir.h "
    print "dtrplugin.cpp, fs4plugin.cpp, maeffplugin.cpp"
else:

    import re
    import string
    import os
    from glob import glob

    molfile_src_path = "/tmp/plugins/molfile_plugin/src"

    src_list=[
        'avsplugin',
#        'babelplugin', # requires openbabel
        'basissetplugin', #
        'basissetplugin', #
        'bgfplugin',
        'binposplugin',
        'biomoccaplugin',
        'brixplugin',
        'carplugin',
        'ccp4plugin',
#        'cdfplugin', # requires netcdf
        'corplugin',
#        'cpmdlogplugin', #
#        'cpmdplugin',
        'crdplugin',
        'cubeplugin',
        'dcdplugin',
        'dlpolyplugin',
        'dsn6plugin',
        'dtrplugin', #
        'dxplugin',
        'edmplugin',
        'fs4plugin',
        'gamessplugin',
#        'gaussianplugin', #
        'graspplugin',
        'grdplugin',
        'gridplugin',
        'gromacsplugin',
#        'hoomdplugin', # requires expat
        'jsplugin', #
#        'lammpsplugin', # requires gz
        'maeffplugin', #
        'mapplugin',
        'mdfplugin',
        'mmcif', #
        'mol2plugin',
        'moldenplugin',
#        'mrcplugin', # gone?
        'msmsplugin',
        'namdbinplugin',
#        'netcdfplugin', # requires netcdf
        'parm7plugin',
        'parmplugin',
        'pbeqplugin', #
        'pdbplugin',
        'phiplugin',
        'pltplugin',
        'pqrplugin',
        'psfplugin',
        'raster3dplugin',
        'rst7plugin',
        'situsplugin',
        'spiderplugin',
        'stlplugin',
        'tinkerplugin',
        'uhbdplugin',
        'vaspchgcarplugin', #
        'vaspoutcarplugin', #
        'vaspparchgplugin', #
        'vaspposcarplugin', #
        'vaspxdatcarplugin', #
        'vaspxmlplugin', #
        'vtfplugin', #
#        'webpdbplugin', # tcl dependent
        'xbgfplugin',
        'xsfplugin',
        'xyzplugin']

    plugins = [ ]

    clean_re = re.compile("\/\/.*$")
    api_re = re.compile("VMDPLUGIN_API")

    for pref in src_list:
        print pref
        in_file = glob(molfile_src_path+"/"+pref+".[cC]*")[0]
        input = open(in_file).readlines()

        out_file = "src/"+pref+".c"
        plugins.append(pref+".o")
        if (in_file[-1:]=='C') or (in_file[-3:]=='cxx'):
            out_file = out_file + "pp"
            # fix the extern
            input = map(lambda x,c=api_re:c.sub("VMDPLUGIN_EXTERN",x),input)
        else:
            # get rid of non-ansi C comments
            input = map(lambda x,c=clean_re:c.sub("\n",x),input)
            
        g=open(out_file,'w')
        g.write("/* MACHINE GENERATED FILE, DO NOT EDIT! */\n\n")
        g.write("#define VMDPLUGIN molfile_%s\n"%pref)
        g.write("#define STATIC_PLUGIN 1\n\n")    
        output = string.join(input,'')
        output.replace('(vmdplugin_t *)','(vmdplugin_t *)(void*)')
        g.write(output)
        g.close()
        g = open("src/objects.make",'w')
        g.write("OBJS="+string.join(plugins,' ')+"\n")
        g.close()


    g=open("src/PlugIOManagerInit.c",'w');
    g.write("/* MACHINE GENERATED FILE, DO NOT EDIT! */\n\n")
    g.write('#include "vmdplugin.h"\n\n')
    g.write('typedef struct _PyMOLGlobals PyMOLGlobals;\n');
    g.write('/* prototypes */')
    for pref in src_list:
        g.write("int molfile_%s_init(void);\n"%pref)
        g.write("int molfile_%s_register(void *,vmdplugin_register_cb);\n"%pref)
        g.write("int molfile_%s_fini(void);\n"%pref)
    g.write('''

    int PlugIOManagerRegister(PyMOLGlobals *G, vmdplugin_t *);

    int PlugIOManagerInitAll(PyMOLGlobals *G);

    int PlugIOManagerInitAll(PyMOLGlobals *G)
    {
       int ok=1;
    ''')
    for pref in src_list:
        g.write("if(ok) ok = ok && (molfile_%s_init() == VMDPLUGIN_SUCCESS);\n"%pref)
    g.write('''
       if(ok) {
    ''')
    for pref in src_list:
        g.write("if(ok) ok = ok && (molfile_%s_register(G,(vmdplugin_register_cb)PlugIOManagerRegister) == VMDPLUGIN_SUCCESS);\n"%pref)
    g.write('''
       }
       return ok;
    }
    ''')
    g.write('''

    int PlugIOManagerRegister(PyMOLGlobals *G, vmdplugin_t *);

    int PlugIOManagerFreeAll(void);
    int PlugIOManagerFreeAll(void)
    {
       int ok=1;
    ''')
    for pref in src_list:
        g.write("if(ok) ok = ok && (molfile_%s_fini() == VMDPLUGIN_SUCCESS);\n"%pref)

    g.write('''
       return ok;
    }\n''')


    os.system("/bin/cp %s/*.h* src/"%molfile_src_path)
    os.system("/bin/cp %s/hash.c src/"%molfile_src_path)

    os.system("/bin/chmod -x src/*")