Updating build systems: folder release/bpydata/ moved to release/scripts/bpydata/
[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/python23.dll", "dist/python23.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         elif sys.platform in ['linux2', 'linux-i386', 'freebsd4', 'freebsd5']:
66                 shutil.copy("blender", "dist/blender")
67                 if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1:
68                         shutil.copy("blenderplayer", "dist/blenderplayer")
69         else:
70                 print "update preparedist() for your platform!"
71                 return 0
72         
73         # now copy .blender and necessary extras for it
74         if os.path.isdir("dist/.blender"):
75                 shutil.rmtree("dist/.blender")
76         os.chdir("bin")
77         shutil.copytree(".blender/", "../dist/.blender")
78         os.chdir(startdir)
79         if os.path.isdir("dist/.blender/scripts"):
80                 shutil.rmtree("dist/.blender/scripts")
81
82         os.chdir("release")
83         shutil.copytree("scripts/", "../dist/.blender/scripts")
84
85         # finally copy auxiliaries (readme, license, etc.)
86         if sys.platform == 'win32':
87                 shutil.copy("windows/extra/Help.url", "../dist/Help.url")
88                 shutil.copy("windows/extra/Python23.zip", "../dist/Python23.zip")
89                 shutil.copy("windows/extra/zlib.pyd", "../dist/zlib.pyd")
90         shutil.copy("text/copyright.txt", "../dist/copyright.txt")
91         shutil.copy("text/blender.html", "../dist/blender.html")
92         shutil.copy("text/GPL-license.txt", "../dist/GPL-license.txt")
93         shutil.copy("text/Python-license.txt", "../dist/Python-license.txt")
94         
95         reltext = "release_" + string.join(bs_globals.version.split("."), '') + ".txt"
96         shutil.copy("text/" + reltext, "../dist/" + reltext)
97         
98         os.chdir(startdir)
99         
100         if cleanCVS()==0:
101                 return 0
102         return 1
103
104 def finalisedist(zipname):
105         """
106         Fetch the package created and remove temp dir
107         """
108         
109         try:
110                 import shutil
111         except:
112                 print "no shutil available"
113                 print "make sure you use python 2.3"
114                 print
115                 return 0
116         
117         #shutil.copy("dist/" + zipname, zipname)
118         #shutil.rmtree("dist")
119         
120         return 1