added libtiff dll to 'release' target for scons (win32)
[blender.git] / tools / scons / bs / bs_dirs.py
1 # functions used for dir handling / preperation / cleaning
2
3 import os
4 import string
5 import sys
6 import bs_globals
7
8 def cleanCVS():
9         """
10         walks the dist dir and removes all CVS dirs
11         """
12         
13         try:
14                 import shutil
15         except:
16                 print "no shutil available"
17                 print "make sure you use python 2.3"
18                 print
19                 return 0
20         
21         startdir = os.getcwd()
22         
23         for root, dirs, files in os.walk("dist", topdown=False):
24                 for name in dirs:
25                         if name in ['CVS']:
26                                 if os.path.isdir(root + "/" + name):
27                                         shutil.rmtree(root + "/" + name)
28         
29         os.chdir(startdir)
30         
31         return 1
32
33 def preparedist():
34         """
35         Prepare a directory for creating either archives or the installer
36         """
37         
38         try:
39                 import shutil
40                 import time
41                 import stat
42         except:
43                 print "no shutil available"
44                 print "make sure you use python 2.3"
45                 print
46                 return 0
47         
48         startdir = os.getcwd()
49         
50         if os.path.isdir("dist") == 0:
51                 os.makedirs("dist")
52         else:
53                 shutil.rmtree("dist") # make sure we don't get old cruft
54                 os.makedirs("dist")
55         
56         # first copy binaries
57         
58         if sys.platform == 'win32' or sys.platform == 'cygwin':
59                 shutil.copy("blender.exe", "dist/blender.exe")
60                 if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
61                         shutil.copy("blenderplayer.exe", "dist/blenderplayer.exe")
62                 shutil.copy("../lib/windows/python/lib/python24.dll", "dist/python24.dll")
63                 shutil.copy("../lib/windows/sdl/lib/SDL.dll", "dist/SDL.dll")
64                 shutil.copy("../lib/windows/gettext/lib/gnu_gettext.dll", "dist/gnu_gettext.dll")
65                 shutil.copy("../lib/windows/tiff/lib/libtiff.dll", "dist/libtiff.dll")
66         elif sys.platform in ['linux2', 'linux-i386', 'freebsd4', 'freebsd5']:
67                 shutil.copy("blender", "dist/blender")
68                 if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
69                         shutil.copy("blenderplayer", "dist/blenderplayer")
70         else:
71                 print "update preparedist() for your platform!"
72                 return 0
73         
74         # now copy .blender and necessary extras for it
75         if os.path.isdir("dist/.blender"):
76                 shutil.rmtree("dist/.blender")
77         os.chdir("bin")
78         shutil.copytree(".blender/", "../dist/.blender")
79         os.chdir(startdir)
80         if os.path.isdir("dist/.blender/scripts"):
81                 shutil.rmtree("dist/.blender/scripts")
82         if os.path.isdir("dist/plugins"):
83             shutil.rmtree("dist/plugins")
84         os.makedirs("dist/plugins/include")
85         shutil.copy("source/blender/blenpluginapi/documentation.h", "dist/plugins/include/documentation.h")
86         shutil.copy("source/blender/blenpluginapi/floatpatch.h", "dist/plugins/include/floatpatch.h")
87         shutil.copy("source/blender/blenpluginapi/iff.h", "dist/plugins/include/iff.h")
88         shutil.copy("source/blender/blenpluginapi/plugin.h", "dist/plugins/include/plugin.h")
89         shutil.copy("source/blender/blenpluginapi/util.h", "dist/plugins/include/util.h")
90
91         os.chdir("release")
92         shutil.copytree("scripts/", "../dist/.blender/scripts")
93         # finally copy auxiliaries (readme, license, etc.)
94         if sys.platform == 'win32':
95                 shutil.copy("windows/extra/Help.url", "../dist/Help.url")
96                 shutil.copy("windows/extra/Python24.zip", "../dist/Python24.zip")
97                 shutil.copy("windows/extra/zlib.pyd", "../dist/zlib.pyd")
98         shutil.copy("text/copyright.txt", "../dist/copyright.txt")
99         shutil.copy("text/blender.html", "../dist/blender.html")
100         shutil.copy("text/GPL-license.txt", "../dist/GPL-license.txt")
101         shutil.copy("text/Python-license.txt", "../dist/Python-license.txt")
102         
103         reltext = "release_" + string.join(bs_globals.version.split("."), '') + ".txt"
104         shutil.copy("text/" + reltext, "../dist/" + reltext)
105         
106         os.chdir(startdir)
107         
108         if cleanCVS()==0:
109                 return 0
110         return 1
111
112 def finalisedist(zipname):
113         """
114         Fetch the package created and remove temp dir
115         """
116         
117         try:
118                 import shutil
119         except:
120                 print "no shutil available"
121                 print "make sure you use python 2.3"
122                 print
123                 return 0
124         
125         #shutil.copy("dist/" + zipname, zipname)
126         #shutil.rmtree("dist")
127         
128         return 1