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