9dd39ccd3088b27d8e10fe18477072d5d55cf493
[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
25 # get builder name
26 if len(sys.argv) < 2:
27     sys.stderr.write("Not enough arguments, expecting builder name\n")
28     sys.exit(1)
29
30 builder = sys.argv[1]
31
32 # we run from build/ directory
33 blender_dir = '../blender'
34
35 if builder.find('cmake') != -1:
36     # cmake
37
38     # set build options
39     cmake_options = ['-DCMAKE_BUILD_TYPE:STRING=Release']
40
41     if builder.endswith('mac_x86_64_cmake'):
42         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
43     elif builder.endswith('mac_i386_cmake'):
44         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=i386')
45     elif builder.endswith('mac_ppc_cmake'):
46         cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=ppc')
47
48     # configure and make
49     retcode = subprocess.call(['cmake', blender_dir] + cmake_options)
50     if retcode != 0:
51         sys.exit(retcode)
52     retcode = subprocess.call(['make', '-s', '-j4', 'install'])
53     sys.exit(retcode)
54 else:
55     # scons
56     os.chdir(blender_dir)
57     scons_cmd = ['python', 'scons/scons.py']
58     scons_options = []
59
60     if builder.find('linux') != -1:
61         import shutil
62
63         # We're using the same rules as release builder, so tweak
64         # build and install dirs
65         build_dir = os.path.join('..', 'build', builder)
66         install_dir = os.path.join('..', 'install', builder)
67
68         common_options = ['BF_INSTALLDIR=' + install_dir]
69
70         # Clean install directory so we'll be sure there's no
71         if os.path.isdir(install_dir):
72             shutil.rmtree(install_dir)
73
74         buildbot_dir = os.path.dirname(os.path.realpath(__file__))
75         config_dir = os.path.join(buildbot_dir, 'config')
76
77         configs = []
78         if builder.endswith('linux_x86_64_scons'):
79             configs = ['user-config-player-x86_64.py',
80                        'user-config-x86_64.py']
81         elif builder.endswith('linux_i386_scons'):
82             configs = ['user-config-player-i686.py',
83                        'user-config-i686.py']
84
85         for config in configs:
86             config_fpath = os.path.join(config_dir, config)
87
88             scons_options = []
89
90             if config.find('player') != -1:
91                 scons_options.append('BF_BUILDDIR=%s_player' % (build_dir))
92             else:
93                 scons_options.append('BF_BUILDDIR=%s' % (build_dir))
94
95             scons_options += common_options
96
97             if config.find('player') == -1:
98                 scons_options.append('blender')
99             else:
100                 scons_options.append('blenderplayer')
101
102             scons_options.append('BF_CONFIG=' + config_fpath)
103
104             retcode = subprocess.call(scons_cmd + scons_options)
105             if retcode != 0:
106                 print('Error building rules wuth config ' + config)
107                 sys.exit(retcode)
108
109         sys.exit(0)
110     else:
111         bitness = '32'
112         # Switch to new FFmpeg library
113         if builder.find('win') != -1:
114             if builder.find('win32') != -1:
115                 LCGDIR = '#../lib/windows'
116             elif builder.find('win64') != -1:
117                 LCGDIR = '#../lib/win64'
118                 bitness = '64'
119
120             all_ffmpeg_libs = ['avcodec-53',
121                                'avdevice-53',
122                                'avformat-53',
123                                'avutil-51',
124                                'swscale-2']
125
126             ffmpeg_lib = []
127             ffmpeg_dll = []
128
129             for lib in all_ffmpeg_libs:
130                 ffmpeg_lib.append(lib + '.lib')
131                 ffmpeg_dll.append('${BF_FFMPEG_LIBPATH}/' + lib + '.dll')
132
133             scons_options.append('BF_FFMPEG=' + LCGDIR + '/ffmpeg-0.8')
134             scons_options.append('BF_FFMPEG_LIB=' + (' '.join(ffmpeg_lib)))
135             scons_options.append('BF_FFMPEG_DLL=' + (' '.join(ffmpeg_dll)))
136
137             scons_options.append('BF_BITNESS='+bitness)
138
139         retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options)
140         sys.exit(retcode)