]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - win32_install.py
* moved zeroradiant (1.6) into trunk
[xonotic/netradiant.git] / win32_install.py
1 # install the fucking files
2 # check the md5 to decide for a copy
3 # we have a site.conf to go through
4 # and a data list of stuff
5 # it's called at the end of each build to copy what needs to be
6 # it could be called only at GtkRadiant link time
7
8 # command line: a bunch of config switches default would be debug?, and release flag
9
10
11 import sys, traceback, os, re, filecmp, shutil, pickle, string
12 from makeversion import get_version
13
14 (line, major, minor) = get_version()
15
16 paths = {
17   'CORERADIANTDIR' : 'C:\\Program Files\\GtkRadiant-1.' + major,
18   'RTCWRADIANTDIR' : 'C:\\Program Files\\Return to Castle Wolfenstein - Game of The Year Edition\\Radiant-1.' + major,
19   'HLRADIANTDIR'   : 'C:\\Sierra\\Half-Life\\Radiant-1.' + major,
20   'SOF2RADIANTDIR' : 'C:\\Program Files\\Soldier of Fortune II - Double Helix\\Radiant-1.' + major,
21   'QUAKE2RADIANTDIR' : 'C:\\Quake2\\Radiant-1.' + major,
22   'HERETIC2RADIANTDIR' : 'C:\\Heretic2\\Radiant-1.' + major
23   }
24
25 conf_filename='site.conf.win32'
26
27 # site settings ----------------------
28
29 if (os.path.exists(conf_filename)):
30   site_file = open(conf_filename, 'r')
31   p = pickle.Unpickler(site_file)
32   paths = p.load()
33   print 'Loaded configuration from ' + conf_filename  
34
35 # end site settings ------------------
36
37 # command line overrides -------------
38
39 print '\nCommand line:'
40 regex = re.compile("(.*)=(.*)")
41 for i in sys.argv[1:]:
42   #print i
43   if ( regex.match(i) ):
44     (key, val) = string.split(i, '=')
45     #print 'key: %s val: %s' % (key, val)
46     paths[key] = val
47   else:
48     print 'Can''t parse command line - ignore: ' + i
49
50 # end command line overrides ---------
51
52 # save config ------------------------
53
54 site_file = open(conf_filename, 'w')
55 p = pickle.Pickler(site_file)
56 p.dump(paths)
57 site_file.close()
58
59 print '\nConfiguration:'
60
61 for i in paths.keys():
62   print '%s -> %s' % (i, paths[i])
63
64 # end save config --------------------
65
66 q3map2_list = [
67 #       ( ( '..\\libpng\\projects\\msvc\\win32\\zlib\\dll_dbg\\zlibd.dll', '..\\libpng\\projects\\msvc\\win32\\zlib\\dll\\zlib.dll' ), '$CORERADIANTDIR' ),
68 #       ( ( '..\\libpng\\projects\\msvc\\win32\\libpng\\dll_dbg\\libpng13d.dll', '..\\libpng\\projects\\msvc\\win32\\libpng\\dll\\libpng13.dll' ), '$CORERADIANTDIR' ),
69 #       ( ( '..\\libxml2\\win32\\binaries-debug\\libxml2.dll', '..\\libxml2\\win32\\binaries-release\\libxml2.dll' ), '$CORERADIANTDIR' ),
70         ( ( 'tools\\quake3\\q3map2\\Debug\\Q3Map2.exe', 'tools\\quake3\\q3map2\\Release\\Q3Map2.exe' ), '$CORERADIANTDIR' ),
71         ]
72
73 all = [
74         ( ( 'radiant\\Debug\\GtkRadiant.exe', 'radiant\\Release\\GtkRadiant.exe' ) ,  '$CORERADIANTDIR' ),
75         ( ( 'contrib\\bobtoolz\\Debug\\bobToolz.dll', 'contrib\\bobtoolz\\Release\\bobToolz.dll' ), '$CORERADIANTDIR\\plugins' ),
76         ( ( 'contrib\\camera\\Debug\\camera.dll', 'contrib\\camera\\Release\\camera.dll' ), '$CORERADIANTDIR\\plugins' ),
77         ( ( 'plugins\\entity\\Debug\\entity.dll', 'plugins\\entity\\Release\\entity.dll' ), '$CORERADIANTDIR\\modules' ),
78         ( ( 'plugins\\eclassfgd\\Debug\\fgd.dll', 'plugins\\eclassfgd\\Release\\fgd.dll' ), '$CORERADIANTDIR\\modules' ),
79         ( ( 'contrib\\gtkgensurf\\Debug\\gensurf.dll', 'contrib\\gtkgensurf\\Release\\gensurf.dll' ), '$CORERADIANTDIR\\plugins' ),
80         ( ( 'contrib\\hydratoolz\\Debug\\hydratoolz.dll', 'contrib\\hydratoolz\\Release\\hydratoolz.dll' ), '$HLRADIANTDIR\\plugins' ), 
81         ( ( 'plugins\\image\\Debug\\image.dll', 'plugins\\image\\Release\\image.dll' ), '$CORERADIANTDIR\\modules' ),
82         ( ( 'plugins\\imagewal\\Debug\\imagewal.dll', 'plugins\\imagewal\\Release\\imagewal.dll' ), '$QUAKE2RADIANTDIR\\modules' ),
83         ( ( 'plugins\\imagehl\\Debug\\imagehl.dll', 'plugins\\imagehl\\Release\\imagehl.dll' ), '$CORERADIANTDIR\\modules' ),
84         ( ( 'plugins\\imagepng\\Debug\\imagepng.dll', 'plugins\\imagepng\\Release\\imagepng.dll' ), '$CORERADIANTDIR\\modules' ),
85         ( ( 'plugins\\map\\Debug\\map.dll', 'plugins\\map\\Release\\map.dll' ), '$CORERADIANTDIR\\modules' ),   
86         ( ( 'plugins\\mapxml\\Debug\\mapxml.dll', 'plugins\\mapxml\\Release\\mapxml.dll' ), '$CORERADIANTDIR\\modules' ),
87         ( ( 'plugins\\model\\Debug\\model.dll', 'plugins\\model\\Release\\model.dll' ), '$CORERADIANTDIR\\modules' ),
88         ( ( 'contrib\\prtview\\Debug\\PrtView.dll', 'contrib\\prtview\\Release\\PrtView.dll' ), '$CORERADIANTDIR\\plugins' ),
89         ( ( 'tools\\quake3\\q3data\\Debug\\q3data.exe', 'tools\\quake3\\q3data\\Release\\q3data.exe' ), '$CORERADIANTDIR' ),
90         ( ( 'plugins\\shaders\\Debug\\shaders.dll', 'plugins\\shaders\\Release\\shaders.dll' ), '$CORERADIANTDIR\\modules' ),   
91         ( ( 'plugins\\spritemodel\\Debug\\spritemodel.dll', 'plugins\\spritemodel\\Release\\spritemodel.dll' ), '$CORERADIANTDIR\\modules' ),
92 #       ( ( 'Debug\\TexTool.dll', 'Release\\TexTool.dll' ), '$CORERADIANTDIR\\plugins' ),
93         ( ( 'plugins\\vfspk3\\Debug\\vfspk3.dll', 'plugins\\vfspk3\\Release\\vfspk3.dll' ), '$CORERADIANTDIR\\modules' ),
94         ( ( 'plugins\\vfspak\\Debug\\vfspak.dll', 'plugins\\vfspak\\Release\\vfspak.dll' ), '$QUAKE2RADIANTDIR\\modules' ),
95         ( ( 'plugins\\vfswad\\Debug\\vfswad.dll', 'plugins\\vfswad\\Release\\vfswad.dll' ), '$CORERADIANTDIR\\modules' ),
96   ( ( 'plugins\\surface\\Debug\\surface.dll', 'plugins\\surface\\Release\\surface.dll' ), '$CORERADIANTDIR\\modules' ),
97   ( ( 'plugins\\surface_quake2\\Debug\\surface_quake2.dll', 'plugins\\surface_quake2\\Release\\surface_quake2.dll' ), '$QUAKE2RADIANTDIR\\modules' ),
98   ( ( 'tools\\quake2\\q2map\\Debug\\q2map.exe', 'tools\\quake2\\q2map\\Release\\q2map.exe' ) ,  '$QUAKE2RADIANTDIR' ),
99   ( ( 'tools\\quake2\\qdata\\Debug\\qdata3.exe', 'tools\\quake2\\qdata\\Release\\qdata3.exe' ) ,  '$QUAKE2RADIANTDIR' ),
100   ( ( 'plugins\\vfspak\\Debug\\vfspak.dll', 'plugins\\vfspak\\Release\\vfspak.dll' ), '$HERETIC2RADIANTDIR\\modules' ),
101   ( ( 'plugins\\imagem8\\Debug\\imagem8.dll', 'plugins\\imagem8\\Release\\imagem8.dll' ), '$HERETIC2RADIANTDIR\\modules' ),
102   ( ( 'plugins\\surface_heretic2\\Debug\\surface_heretic2.dll', 'plugins\\surface_heretic2\\Release\\surface_heretic2.dll' ), '$HERETIC2RADIANTDIR\\modules' ),
103   ( ( 'tools\\quake2\\qdata_heretic2\\Debug\\qdata3.exe', 'tools\\quake2\\qdata_heretic2\\Release\\qdata3.exe' ) ,  '$HERETIC2RADIANTDIR' ),
104         ( ( 'contrib\\bkgrnd2d\\Debug\\bkgrnd2d.dll', 'contrib\\bkgrnd2d\\Release\\bkgrnd2d.dll' ), '$CORERADIANTDIR\\plugins' ),
105         ]
106
107 config = 0
108 q3map2 = 0
109
110 # config check
111 for i in sys.argv:
112         if ( i == 'release' ):
113                 config = 1
114         elif ( i == 'q3map2' ):
115                 q3map2 = 1
116
117 if ( config == 1 ):
118         print 'installing release binaries'
119 else:
120         print 'installing debug binaries'
121
122 def expand(path_in):
123         for matches in paths.keys():
124                 exp = re.compile('\\$%s' % matches)
125                 if ( not re.match(exp, path_in) is None ):
126                         #print "Got a match for %s on %s" % ( matches, path_in )
127                         path_in = re.sub(exp, paths[matches], path_in)  
128                         #print "Processed to: %s" % path_in
129         return path_in
130
131 # don't bother about stderr
132 sys.stderr = sys.stdout
133
134 if ( q3map2 == 0 ):
135         stuff = q3map2_list
136         stuff += all
137 else:
138         stuff = q3map2_list
139
140 for entries in stuff:
141         try:
142                 src = expand(entries[0][config])
143                 #print "src basename: %s -> %s" % (src, os.path.basename(src))
144                 dst = entries[1]
145                 dst = os.path.join( entries[1], os.path.basename(src) )
146                 dst = expand(dst)
147                 #print "src: %s dst: %s" % (src, dst)
148                 if (os.path.isfile(src)):
149                         if (os.path.isfile(dst)):
150                                 if (not filecmp.cmp(src, dst)):
151                                         shutil.copy(src, dst)
152                                         print "%s: OK - updated" % dst
153                                 else:
154                                         print "%s: OK - already up to date" % dst
155                         else:
156                                 shutil.copy(src, dst)
157                                 print "%s: OK - installed" % dst
158                 else:   
159                         print "%s: FAILED - not found" % src
160                         if (os.path.isfile(dst)):
161                                 print "delete %s" % dst
162                                 os.remove(dst)
163         except:
164                 print "%s: FAILED" % src
165                 traceback.print_exc()
166