-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-redist.py
56 lines (47 loc) · 1.5 KB
/
build-redist.py
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
#!/usr/bin/env python3
import os, platform, shutil, subprocess
def safe_replace( txin, txfrom, txto ):
txout = txin.replace( txfrom, txto )
if txout == txin:
raise Exception( "failed to replace '%s' to '%s'" % ( txfrom, txto ) )
return txout
PLATFORM = platform.system()
FOLDER = "sgs-ouzel"
print( "creating output directory" )
if os.path.exists( FOLDER ):
for i in range(10):
try:
shutil.rmtree( FOLDER )
except:
pass
if os.path.exists( FOLDER ):
shutil.rmtree( FOLDER )
os.mkdir( FOLDER )
print( "copying sample resources (if this fails, submodules haven't been checked out)" )
shutil.copytree( "ext/ouzel/samples/Resources", FOLDER + "/Resources" )
print( "copying sample code & helpers" )
files = [
"build.py",
"settings.ini",
"main-menu.sgs",
"main-sample-animations.sgs",
"main-sample-gui.sgs",
"main-sample-input.sgs",
"main-sample-rt.sgs",
"main-sample-sound.sgs",
"main-sample-sprites.sgs",
"main.sgs",
]
for f in files:
shutil.copy( "bin/" + f, FOLDER )
print( "copying local platform files (if this fails, make hasn't been run)" )
if PLATFORM == "Windows":
shutil.copy( "bin/sgsouzel-win32.exe", FOLDER )
def android_ignore_prebuilt( directory, contents ):
if directory == "bin/android":
return [ "bin", "gen", "jni", "obj" ]
return []
shutil.copytree( "bin/android", FOLDER + "/android", ignore = android_ignore_prebuilt )
print( "building an archive" )
name = "sgsouzel_dist_" + PLATFORM
shutil.make_archive( name, "zip" if PLATFORM == "Windows" else "gztar", ".", FOLDER )