Mixed paths to redist libraries in recent commit
[blender.git] / build_files / buildbot / slave_compile.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20
21 import os
22 import subprocess
23 import sys
24 import shutil
25
26 # get builder name
27 if len(sys.argv) < 2:
28     sys.stderr.write("Not enough arguments, expecting builder name\n")
29     sys.exit(1)
30
31 builder = sys.argv[1]
32
33 # we run from build/ directory
34 blender_dir = '../blender'
35
36 if builder.find('cmake') != -1:
37     # cmake
38
39     # set build options
40     cmake_options = ['-DCMAKE_BUILD_TYPE:STRING=Release']
41
42     if builder.endswith('mac_x86_64_cmake'):
43         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
44     elif builder.endswith('mac_i386_cmake'):
45         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=i386')
46     elif builder.endswith('mac_ppc_cmake'):
47         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=ppc')
48
49     # configure and make
50     retcode = subprocess.call(['cmake', blender_dir] + cmake_options)
51     if retcode != 0:
52         sys.exit(retcode)
53     retcode = subprocess.call(['make', '-s', '-j4', 'install'])
54     sys.exit(retcode)
55 else:
56     # scons
57     os.chdir(blender_dir)
58     scons_cmd = ['python', 'scons/scons.py']
59     scons_options = ['BF_FANCY=False']
60
61     # We're using the same rules as release builder, so tweak
62     # build and install dirs
63     build_dir = os.path.join('..', 'build', builder)
64     install_dir = os.path.join('..', 'install', builder)
65
66     # Clean install directory so we'll be sure there's no
67     if os.path.isdir(install_dir):
68         shutil.rmtree(install_dir)
69
70     buildbot_dir = os.path.dirname(os.path.realpath(__file__))
71     config_dir = os.path.join(buildbot_dir, 'config')
72
73     if builder.find('linux') != -1:
74         configs = []
75         if builder.endswith('linux_glibc211_x86_64_scons'):
76             configs = ['user-config-player-glibc211-x86_64.py',
77                        'user-config-cuda-glibc211-x86_64.py',
78                        'user-config-glibc211-x86_64.py'
79                        ]
80             chroot_name = 'buildbot_squeeze_x86_64'
81             cuda_chroot = 'buildbot_squeeze_x86_64'
82         elif builder.endswith('linux_glibc211_i386_scons'):
83             configs = ['user-config-player-glibc211-i686.py',
84                        'user-config-cuda-glibc211-i686.py',
85                        'user-config-glibc211-i686.py']
86             chroot_name = 'buildbot_squeeze_i686'
87
88             # use 64bit cuda toolkit, so there'll be no memory limit issues
89             cuda_chroot = 'buildbot_squeeze_x86_64'
90
91         # Compilation will happen inside of chroot environment
92         prog_scons_cmd = ['schroot', '-c', chroot_name, '--'] + scons_cmd
93         cuda_scons_cmd = ['schroot', '-c', cuda_chroot, '--'] + scons_cmd
94
95         common_options = ['BF_INSTALLDIR=' + install_dir] + scons_options
96
97         for config in configs:
98             config_fpath = os.path.join(config_dir, config)
99
100             scons_options = []
101
102             if config.find('player') != -1:
103                 scons_options.append('BF_BUILDDIR=%s_player' % (build_dir))
104             else:
105                 scons_options.append('BF_BUILDDIR=%s' % (build_dir))
106
107             scons_options += common_options
108
109             if config.find('player') != -1:
110                 scons_options.append('blenderplayer')
111                 cur_scons_cmd = prog_scons_cmd
112             elif config.find('cuda') != -1:
113                 scons_options.append('cudakernels')
114                 cur_scons_cmd = cuda_scons_cmd
115
116                 if config.find('i686') != -1:
117                     scons_options.append('BF_BITNESS=32')
118                 elif config.find('x86_64') != -1:
119                     scons_options.append('BF_BITNESS=64')
120             else:
121                 scons_options.append('blender')
122                 cur_scons_cmd = prog_scons_cmd
123
124             scons_options.append('BF_CONFIG=' + config_fpath)
125
126             retcode = subprocess.call(cur_scons_cmd + scons_options)
127             if retcode != 0:
128                 print('Error building rules wuth config ' + config)
129                 sys.exit(retcode)
130
131         sys.exit(0)
132     else:
133         if builder.find('win') != -1:
134             bitness = '32'
135
136             if builder.find('win64') != -1:
137                 bitness = '64'
138
139             scons_options.append('BF_INSTALLDIR=' + install_dir)
140             scons_options.append('BF_BUILDDIR=' + build_dir)
141             scons_options.append('BF_BITNESS=' + bitness)
142             scons_options.append('WITH_BF_CYCLES_CUDA_BINARIES=True')
143             scons_options.append('BF_CYCLES_CUDA_NVCC=nvcc.exe')
144             if builder.find('mingw') != -1:
145                 scons_options.append('BF_TOOLSET=mingw')
146
147         elif builder.find('mac') != -1:
148             if builder.find('x86_64') != -1:
149                 config = 'user-config-mac-x86_64.py'
150             else:
151                 config = 'user-config-mac-i386.py'
152
153             scons_options.append('BF_CONFIG=' + os.path.join(config_dir, config))
154
155         retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options)
156         if retcode == 0:
157             dlls = ('msvcm90.dll', 'msvcp90.dll', 'msvcr90.dll', 'vcomp90.dll', 'Microsoft.VC90.CRT.manifest', 'Microsoft.VC90.OpenMP.manifest')
158             if bitness == '32':
159                dlls_path = 'C:\\b\\redist\\x86'
160             else:
161                dlls_path = 'C:\\b\\redist\\amd64'
162             for dll in dlls:
163                 shutil.copyfile(os.path.join(dlls_path, dll), os.path.join(install_dir, dll))
164         sys.exit(retcode)