updated make_release script so it copies over the freetype.dll. Closes #563
[twcon.git] / scripts / make_release.py
blobf9ff9e9438c088aa17b46e28f1e292b57ea7087b
1 import shutil, os, sys, zipfile
3 #valid_platforms = ["win32", "linux86", "linux86_64", "src"]
5 if len(sys.argv) != 3:
6 print "wrong number of arguments"
7 print sys.argv[0], "VERSION PLATFORM"
8 sys.exit(-1)
10 name = "teeworlds"
11 version = sys.argv[1]
12 platform = sys.argv[2]
13 exe_ext = ""
14 use_zip = 0
15 use_gz = 1
16 use_dmg = 0
17 use_bundle = 0
18 include_data = True
19 include_exe = True
20 include_src = False
22 if platform == "src":
23 include_data = True
24 include_exe = False
25 include_src = True
26 use_zip = 1
27 use_gz = 1
29 #if not platform in valid_platforms:
30 # print "not a valid platform"
31 # print valid_platforms
32 # sys.exit(-1)
34 if platform == 'win32':
35 exe_ext = ".exe"
36 use_zip = 1
37 use_gz = 0
38 if platform == 'osx':
39 use_dmg = 1
40 use_gz = 0
41 use_bundle = 1
43 def copydir(src, dst, excl=[]):
44 for root, dirs, files in os.walk(src, topdown=True):
45 if "/." in root or "\\." in root:
46 continue
47 for name in dirs:
48 if name[0] != '.':
49 os.mkdir(os.path.join(dst, root, name))
50 for name in files:
51 if name[0] != '.':
52 shutil.copy(os.path.join(root, name), os.path.join(dst, root, name))
54 package = "%s-%s-%s" %(name, version, platform)
55 package_dir = package
57 print "cleaning target"
58 shutil.rmtree(package_dir, True)
59 os.mkdir(package_dir)
61 print "adding files"
62 shutil.copy("readme.txt", package_dir)
63 shutil.copy("license.txt", package_dir)
64 shutil.copy("storage.cfg", package_dir)
66 if include_data and not use_bundle:
67 os.mkdir(os.path.join(package_dir, "data"))
68 copydir("data", package_dir)
69 if platform[:3] == "win":
70 shutil.copy("other/config_directory.bat", package_dir)
71 shutil.copy("SDL.dll", package_dir)
72 shutil.copy("freetype.dll", package_dir)
74 if include_exe and not use_bundle:
75 shutil.copy(name+exe_ext, package_dir)
76 shutil.copy(name+"_srv"+exe_ext, package_dir)
78 if include_src:
79 for p in ["src", "scripts", "datasrc", "other", "objs"]:
80 os.mkdir(os.path.join(package_dir, p))
81 copydir(p, package_dir)
82 shutil.copy("bam.lua", package_dir)
83 shutil.copy("configure.lua", package_dir)
85 if use_bundle:
86 os.system("lipo -create -output "+name+"_srv "+name+"_srv"+"_ppc "+name+"_srv"+"_x86")
87 os.system("lipo -create -output "+name+" "+name+"_ppc "+name+"_x86")
88 os.system("lipo -create -output serverlaunch serverlaunch_ppc serverlaunch_x86")
90 # create Teeworlds appfolder
91 clientbundle_content_dir = os.path.join(package_dir, "Teeworlds.app/Contents")
92 clientbundle_bin_dir = os.path.join(clientbundle_content_dir, "MacOS")
93 clientbundle_resource_dir = os.path.join(clientbundle_content_dir, "Resources")
94 clientbundle_framework_dir = os.path.join(clientbundle_content_dir, "Frameworks")
95 os.mkdir(os.path.join(package_dir, "Teeworlds.app"))
96 os.mkdir(clientbundle_content_dir)
97 os.mkdir(clientbundle_bin_dir)
98 os.mkdir(clientbundle_resource_dir)
99 os.mkdir(clientbundle_framework_dir)
100 os.mkdir(os.path.join(clientbundle_resource_dir, "data"))
101 copydir("data", clientbundle_resource_dir)
102 shutil.copy("other/icons/Teeworlds.icns", clientbundle_resource_dir)
103 shutil.copy(name+exe_ext, clientbundle_bin_dir)
104 os.system("cp -R /Library/Frameworks/SDL.framework " + clientbundle_framework_dir)
105 file(os.path.join(clientbundle_content_dir, "Info.plist"), "w").write("""
106 <?xml version="1.0" encoding="UTF-8"?>
107 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
108 <plist version="1.0">
109 <dict>
110 <key>CFBundleDevelopmentRegion</key>
111 <string>English</string>
112 <key>CFBundleExecutable</key>
113 <string>teeworlds</string>
114 <key>CFBundleIconFile</key>
115 <string>Teeworlds</string>
116 <key>CFBundleInfoDictionaryVersion</key>
117 <string>6.0</string>
118 <key>CFBundlePackageType</key>
119 <string>APPL</string>
120 <key>CFBundleSignature</key>
121 <string>????</string>
122 <key>CFBundleVersion</key>
123 <string>%s</string>
124 </dict>
125 </plist>
126 """ % (version))
127 file(os.path.join(clientbundle_content_dir, "PkgInfo"), "w").write("APPL????")
129 # create Teeworlds Server appfolder
130 serverbundle_content_dir = os.path.join(package_dir, "Teeworlds Server.app/Contents")
131 serverbundle_bin_dir = os.path.join(serverbundle_content_dir, "MacOS")
132 serverbundle_resource_dir = os.path.join(serverbundle_content_dir, "Resources")
133 os.mkdir(os.path.join(package_dir, "Teeworlds Server.app"))
134 os.mkdir(serverbundle_content_dir)
135 os.mkdir(serverbundle_bin_dir)
136 os.mkdir(serverbundle_resource_dir)
137 os.mkdir(os.path.join(serverbundle_resource_dir, "data"))
138 os.mkdir(os.path.join(serverbundle_resource_dir, "data/maps"))
139 os.mkdir(os.path.join(serverbundle_resource_dir, "data/mapres"))
140 copydir("data/maps", serverbundle_resource_dir)
141 shutil.copy("other/icons/Teeworlds_srv.icns", serverbundle_resource_dir)
142 shutil.copy(name+"_srv"+exe_ext, serverbundle_bin_dir)
143 shutil.copy("serverlaunch"+exe_ext, serverbundle_bin_dir + "/"+name+"_server")
144 file(os.path.join(serverbundle_content_dir, "Info.plist"), "w").write("""
145 <?xml version="1.0" encoding="UTF-8"?>
146 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
147 <plist version="1.0">
148 <dict>
149 <key>CFBundleDevelopmentRegion</key>
150 <string>English</string>
151 <key>CFBundleExecutable</key>
152 <string>teeworlds_server</string>
153 <key>CFBundleIconFile</key>
154 <string>Teeworlds_srv</string>
155 <key>CFBundleInfoDictionaryVersion</key>
156 <string>6.0</string>
157 <key>CFBundlePackageType</key>
158 <string>APPL</string>
159 <key>CFBundleSignature</key>
160 <string>????</string>
161 <key>CFBundleVersion</key>
162 <string>%s</string>
163 </dict>
164 </plist>
165 """ % (version))
166 file(os.path.join(serverbundle_content_dir, "PkgInfo"), "w").write("APPL????")
168 if use_zip:
169 print "making zip archive"
170 zf = zipfile.ZipFile("%s.zip" % package, 'w', zipfile.ZIP_DEFLATED)
172 for root, dirs, files in os.walk(package_dir, topdown=True):
173 for name in files:
174 n = os.path.join(root, name)
175 zf.write(n, n)
176 #zf.printdir()
177 zf.close()
179 if use_gz:
180 print "making tar.gz archive"
181 os.system("tar czf %s.tar.gz %s" % (package, package_dir))
183 if use_dmg:
184 print "making disk image"
185 os.system("rm -f %s.dmg %s_temp.dmg" % (package, package))
186 os.system("hdiutil create -srcfolder %s -volname Teeworlds -quiet %s_temp" % (package_dir, package))
187 os.system("hdiutil convert %s_temp.dmg -format UDBZ -o %s.dmg -quiet" % (package, package))
188 os.system("rm -f %s_temp.dmg" % package)
190 print "done"