2012-12-17 08:01:43 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# The Original Code is Copyright (C) 2011, Blender Foundation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# The Original Code is: all of this file.
|
|
|
|
#
|
|
|
|
# Contributor(s): Nathan Letwory.
|
|
|
|
#
|
|
|
|
# ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
2011-11-08 20:40:02 +00:00
|
|
|
from os import path
|
|
|
|
Import('env')
|
|
|
|
|
|
|
|
cycles = env.Clone()
|
|
|
|
|
|
|
|
cycles.Depends('../../source/blender/makesrna/intern/RNA_blender_cpp.h', 'makesrna')
|
|
|
|
|
2011-11-15 19:23:35 +00:00
|
|
|
sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob('kernel/*.cpp') + cycles.Glob('render/*.cpp') + cycles.Glob('subd/*.cpp') + cycles.Glob('util/*.cpp') + cycles.Glob('blender/*.cpp')
|
2011-11-08 20:40:02 +00:00
|
|
|
|
|
|
|
sources.remove(path.join('util', 'util_view.cpp'))
|
2013-02-04 16:12:37 +00:00
|
|
|
sources.remove(path.join('kernel', 'kernel_sse2.cpp'))
|
|
|
|
sources.remove(path.join('kernel', 'kernel_sse3.cpp'))
|
2013-11-22 13:16:47 +00:00
|
|
|
sources.remove(path.join('kernel', 'kernel_sse41.cpp'))
|
2014-01-16 16:04:11 +00:00
|
|
|
sources.remove(path.join('kernel', 'kernel_avx.cpp'))
|
2014-06-13 20:23:58 +00:00
|
|
|
sources.remove(path.join('kernel', 'kernel_avx2.cpp'))
|
2011-11-08 20:40:02 +00:00
|
|
|
|
|
|
|
incs = []
|
|
|
|
defs = []
|
2012-06-25 11:42:58 +00:00
|
|
|
cxxflags = Split(env['CXXFLAGS'])
|
2011-11-08 20:40:02 +00:00
|
|
|
|
2013-02-10 20:47:44 +00:00
|
|
|
defs.append('GLEW_STATIC')
|
|
|
|
|
2011-11-08 20:40:02 +00:00
|
|
|
defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {')
|
|
|
|
defs.append('CCL_NAMESPACE_END=}')
|
|
|
|
|
|
|
|
defs.append('WITH_OPENCL')
|
|
|
|
defs.append('WITH_MULTI')
|
|
|
|
defs.append('WITH_CUDA')
|
|
|
|
|
2012-11-15 13:11:12 +00:00
|
|
|
if env['WITH_BF_CYCLES_OSL']:
|
|
|
|
defs.append('WITH_OSL')
|
2013-01-30 21:58:47 +00:00
|
|
|
defs.append('OSL_STATIC_LIBRARY')
|
2012-11-15 13:11:12 +00:00
|
|
|
incs.append(cycles['BF_OSL_INC'])
|
|
|
|
|
2011-11-08 20:40:02 +00:00
|
|
|
incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
|
2013-09-01 15:01:15 +00:00
|
|
|
incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna #source/blender/blenlib'.split())
|
2011-11-08 20:40:02 +00:00
|
|
|
incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split())
|
2012-11-03 15:36:02 +00:00
|
|
|
incs.extend('#extern/glew/include #intern/mikktspace'.split())
|
2011-11-08 20:40:02 +00:00
|
|
|
incs.append(cycles['BF_OIIO_INC'])
|
|
|
|
incs.append(cycles['BF_BOOST_INC'])
|
2012-11-15 21:35:25 +00:00
|
|
|
incs.append(cycles['BF_OPENEXR_INC'].split())
|
2012-11-12 18:31:15 +00:00
|
|
|
incs.extend(cycles['BF_PYTHON_INC'].split())
|
2011-11-08 20:40:02 +00:00
|
|
|
|
2011-12-01 16:33:21 +00:00
|
|
|
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
|
|
|
|
cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /EHsc'.split())
|
|
|
|
else:
|
|
|
|
cxxflags.append('-ffast-math'.split())
|
|
|
|
|
2014-05-02 21:22:14 +00:00
|
|
|
# Warnings
|
2014-05-03 09:08:27 +00:00
|
|
|
# XXX Not supported by gcc < 4.9, since we do not have any 'supported flags' test as in cmake,
|
|
|
|
# simpler to comment for now.
|
|
|
|
#if env['C_COMPILER_ID'] == 'gcc':
|
|
|
|
# cxxflags.append(['-Werror=float-conversion'])
|
2014-05-02 21:22:14 +00:00
|
|
|
|
2012-04-24 12:57:58 +00:00
|
|
|
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
|
2012-02-04 19:58:09 +00:00
|
|
|
incs.append(env['BF_PTHREADS_INC'])
|
|
|
|
|
2014-01-28 21:56:12 +00:00
|
|
|
# optimized kernel. we compile the kernel multiple times with different
|
|
|
|
# optimization flags, at runtime it will choose the optimal kernel
|
|
|
|
kernel_flags = {}
|
2014-01-14 19:39:21 +00:00
|
|
|
|
|
|
|
if env['OURPLATFORM'] == 'win32-vc':
|
|
|
|
# there is no /arch:SSE3, but intrinsics are available anyway
|
2014-03-31 17:44:02 +00:00
|
|
|
kernel_flags['sse2'] = '/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /GS-'
|
2014-01-28 21:56:12 +00:00
|
|
|
kernel_flags['sse3'] = kernel_flags['sse2']
|
2014-01-14 19:39:21 +00:00
|
|
|
|
2014-01-28 21:56:12 +00:00
|
|
|
elif env['OURPLATFORM'] == 'win64-vc':
|
|
|
|
# /arch:AVX only available from visual studio 2012
|
2014-03-31 17:44:02 +00:00
|
|
|
kernel_flags['sse2'] = '-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /GS-'
|
2014-01-28 21:56:12 +00:00
|
|
|
kernel_flags['sse3'] = kernel_flags['sse2']
|
2014-01-14 19:39:21 +00:00
|
|
|
|
2014-05-15 06:12:15 +00:00
|
|
|
if env['MSVC_VERSION'] >= '12.0':
|
2014-01-29 12:29:06 +00:00
|
|
|
kernel_flags['sse41'] = kernel_flags['sse3']
|
2014-01-28 21:56:12 +00:00
|
|
|
kernel_flags['avx'] = kernel_flags['sse41'] + ' /arch:AVX'
|
2014-06-13 20:23:58 +00:00
|
|
|
kernel_flags['avx2'] = kernel_flags['sse41'] + ' /arch:AVX /arch:AVX2'
|
2014-01-16 18:44:25 +00:00
|
|
|
else:
|
2014-01-28 21:56:12 +00:00
|
|
|
# -mavx only available with relatively new gcc/clang
|
|
|
|
kernel_flags['sse2'] = '-ffast-math -msse -msse2 -mfpmath=sse'
|
|
|
|
kernel_flags['sse3'] = kernel_flags['sse2'] + ' -msse3 -mssse3'
|
|
|
|
kernel_flags['sse41'] = kernel_flags['sse3'] + ' -msse4.1'
|
|
|
|
|
|
|
|
if (env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6') or (env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.1'):
|
|
|
|
kernel_flags['avx'] = kernel_flags['sse41'] + ' -mavx'
|
2014-06-13 21:09:31 +00:00
|
|
|
kernel_flags['avx2'] = kernel_flags['avx'] + ' -mavx2 -mfma -mlzcnt -mbmi -mbmi2'
|
2014-01-28 21:56:12 +00:00
|
|
|
|
|
|
|
for kernel_type in kernel_flags.keys():
|
|
|
|
defs.append('WITH_KERNEL_' + kernel_type.upper())
|
|
|
|
|
|
|
|
for kernel_type in kernel_flags.keys():
|
|
|
|
kernel_source = path.join('kernel', 'kernel_' + kernel_type + '.cpp')
|
|
|
|
kernel_cxxflags = Split(env['CXXFLAGS'])
|
|
|
|
kernel_cxxflags.append(kernel_flags[kernel_type].split())
|
|
|
|
kernel_defs = defs[:]
|
|
|
|
kernel_env = cycles.Clone()
|
|
|
|
|
|
|
|
if env['OURPLATFORM'] == 'darwin' and env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6':
|
|
|
|
# use Apple assembler for avx , gnu-compilers do not support it ( gnu gcc-4.6 or higher case )
|
|
|
|
kernel_env.BlenderLib('bf_intern_cycles_' + kernel_type, [kernel_source], incs, kernel_defs,
|
|
|
|
libtype=['intern'], priority=[10], cxx_compileflags=kernel_cxxflags,
|
|
|
|
cc_compilerchange='/usr/bin/clang', cxx_compilerchange='/usr/bin/clang++')
|
|
|
|
else:
|
|
|
|
kernel_env.BlenderLib('bf_intern_cycles_' + kernel_type, [kernel_source], incs, kernel_defs,
|
|
|
|
libtype=['intern'], priority=[10], cxx_compileflags=kernel_cxxflags)
|
2011-11-15 15:13:38 +00:00
|
|
|
|
2012-06-25 11:42:58 +00:00
|
|
|
cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], cxx_compileflags=cxxflags)
|
2011-12-01 16:33:21 +00:00
|
|
|
|
2014-01-28 21:56:12 +00:00
|
|
|
# OSL shaders
|
2012-11-15 13:11:12 +00:00
|
|
|
if env['WITH_BF_CYCLES_OSL']:
|
|
|
|
oso_files = SConscript(['kernel/shaders/SConscript'])
|
|
|
|
cycles.Depends("kernel/osl/osl_shader.o", oso_files)
|
|
|
|
|
|
|
|
SConscript(['kernel/osl/SConscript'])
|
|
|
|
|
2011-12-01 16:33:21 +00:00
|
|
|
# cuda kernel binaries
|
|
|
|
if env['WITH_BF_CYCLES_CUDA_BINARIES']:
|
|
|
|
kernel_binaries = SConscript(['kernel/SConscript'])
|
|
|
|
cycles.Depends("device/device_cuda.o", kernel_binaries)
|
2011-11-08 20:40:02 +00:00
|
|
|
|