diff options
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/cycles/SConscript | 173 | ||||
-rw-r--r-- | intern/cycles/kernel/SConscript | 121 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_avx.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_avx2.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_sse2.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_sse3.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_sse41.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/SConscript | 80 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/SConscript | 68 |
10 files changed, 1 insertions, 468 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index c252a613cef..3df9a670f7d 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -11,7 +11,7 @@ endif() include(cmake/external_libs.cmake) # Build Flags -# todo: refactor this code to match scons +# todo: this code could be refactored a bit to avoid duplication # note: CXX_HAS_SSE is needed in case passing SSE flags fails altogether (gcc-arm) if(WITH_CYCLES_WERROR) diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript deleted file mode 100644 index 99df8c299fc..00000000000 --- a/intern/cycles/SConscript +++ /dev/null @@ -1,173 +0,0 @@ -#!/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 ***** - -from os import path -Import('env') - -cycles = env.Clone() - -cycles.Depends('../../source/blender/makesrna/intern/RNA_blender_cpp.h', 'makesrna') - -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') - -sources.append(path.join('kernel', 'kernels', 'cpu', 'kernel.cpp')) -sources.remove(path.join('util', 'util_view.cpp')) - -incs = [] -defs = [] -cxxflags = Split(env['CXXFLAGS']) - -defs += env['BF_GL_DEFINITIONS'] - -if env['WITH_UNORDERED_MAP_SUPPORT']: - if env['UNORDERED_MAP_HEADER'] == 'unordered_map': - if env['UNORDERED_MAP_NAMESPACE'] == 'std': - defs.append('CYCLES_STD_UNORDERED_MAP') - elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': - defs.append('CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE') - elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': - defs.append('CYCLES_TR1_UNORDERED_MAP') -else: - print("-- Replacing unordered_map/set with map/set (warning: slower!)") - defs.append('CYCLES_NO_UNORDERED_MAP') - -defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') -defs.append('CCL_NAMESPACE_END=}') - -defs.append('WITH_OPENCL') -defs.append('WITH_MULTI') -defs.append('WITH_CUDA') - -if env['WITH_BF_CYCLES_OSL']: - defs.append('WITH_OSL') - defs.append('OSL_STATIC_LIBRARY') - incs.append(cycles['BF_OSL_INC']) - -if env['WITH_BF_CYCLES_DEBUG']: - defs.append('WITH_CYCLES_DEBUG') - -if env['WITH_BF_CYCLES_LOGGING']: - defs.append('WITH_CYCLES_LOGGING') - defs.append('GOOGLE_GLOG_DLL_DECL=') - defs.append('CYCLES_GFLAGS_NAMESPACE=gflags') - if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs.append('#extern/libmv/third_party/glog/src/windows') - incs.append('#extern/libmv/third_party/gflags') - else: - incs.append('#extern/libmv/third_party/glog/src') - incs.append('#extern/libmv/third_party/gflags') - -incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split()) -incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna #source/blender/blenlib'.split()) -incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split()) - -incs.append(env['BF_GLEW_INC']) -incs.append('#/intern/glew-mx') -incs.append('#/intern/atomic') -incs.append('#intern/mikktspace') -incs.extend('#extern/glew/include #extern/clew/include #extern/cuew/include #intern/mikktspace'.split()) - -incs.append(cycles['BF_OIIO_INC']) -incs.append(cycles['BF_BOOST_INC']) -incs.append(cycles['BF_OPENEXR_INC'].split()) -incs.extend(cycles['BF_PYTHON_INC'].split()) - -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()) - -# Warnings -# 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']) - -if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs.append(env['BF_PTHREADS_INC']) - -# optimized kernel. we compile the kernel multiple times with different -# optimization flags, at runtime it will choose the optimal kernel -kernel_flags = {} - -if env['OURPLATFORM'] == 'win32-vc': - # there is no /arch:SSE3, but intrinsics are available anyway - kernel_flags['sse2'] = '/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /GS-' - kernel_flags['sse3'] = kernel_flags['sse2'] - -elif env['OURPLATFORM'] == 'win64-vc': - # /arch:AVX only available from visual studio 2012 - kernel_flags['sse2'] = '-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /GS-' - kernel_flags['sse3'] = kernel_flags['sse2'] - - if env['MSVC_VERSION'] >= '12.0': - kernel_flags['sse41'] = kernel_flags['sse3'] - kernel_flags['avx'] = kernel_flags['sse41'] + ' /arch:AVX' - kernel_flags['avx2'] = kernel_flags['sse41'] + ' /arch:AVX /arch:AVX2' -else: - # -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' - kernel_flags['avx2'] = kernel_flags['avx'] + ' -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c' - -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', 'kernels', 'cpu', '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) - -cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], cxx_compileflags=cxxflags) - -# OSL shaders -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']) - -# cuda kernel binaries -if env['WITH_BF_CYCLES_CUDA_BINARIES']: - kernel_binaries = SConscript(['kernel/SConscript']) - cycles.Depends("device/device_cuda.o", kernel_binaries) - diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript deleted file mode 100644 index e8d51013924..00000000000 --- a/intern/cycles/kernel/SConscript +++ /dev/null @@ -1,121 +0,0 @@ -#!/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 ***** - -import re -import subprocess -import sys -import os -import Blender as B -import btools - -def normpath(path): - return os.path.abspath(os.path.normpath(path)) - -Import ('env') - -kernel_binaries = [] - -#Bitness -if B.bitness == 32: - bits = 32 -else: - bits = 64 - -if env['WITH_BF_CYCLES_CUDA_BINARIES']: - kernel = env.Clone() - - # cuda info - nvcc = env['BF_CYCLES_CUDA_NVCC'] - cuda_archs = env['BF_CYCLES_CUDA_BINARIES_ARCH'] - - # build directory - root_build_dir = normpath(env['BF_BUILDDIR']) - build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel') - - # source directories and files - kernel_file_rel = os.path.join("kernels", "cuda", "kernel.cu") - source_dir = Dir('.').srcnode().path - kernel_file = os.path.join(source_dir, kernel_file_rel) - util_dir = os.path.join(source_dir, "../util") - svm_dir = os.path.join(source_dir, "../svm") - geom_dir = os.path.join(source_dir, "../geom") - closure_dir = os.path.join(source_dir, "../closure") - - # get CUDA version - output = btools.get_command_output([nvcc, "--version"]) - cuda_major_minor = re.findall(r'release (\d+).(\d+)', output)[0] - cuda_version = int(cuda_major_minor[0])*10 + int(cuda_major_minor[1]) - - if cuda_version != 65: - print("CUDA version %d.%d detected, build may succeed but only CUDA 6.5 is officially supported." % (cuda_version/10, cuda_version%10)) - - # nvcc flags - nvcc_flags = "-m%s" % (bits) - nvcc_flags += " --cubin --ptxas-options=\"-v\" --use_fast_math" - nvcc_flags += " -D__KERNEL_CUDA_VERSION__=%d" % (cuda_version) - nvcc_flags += " -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC" - nvcc_flags += " -I \"%s\" -I \"%s\" -I \"%s\" -I \"%s\"" % (util_dir, svm_dir, geom_dir, closure_dir) - - if env['WITH_BF_CYCLES_DEBUG']: - nvcc_flags += " -D__KERNEL_DEBUG__" - - # dependencies - dependencies = [kernel_file_rel] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + kernel.Glob('geom/*.h') + kernel.Glob('closure/*.h') - last_cubin_file = None - - configs = (("kernel_%s.cubin", ''), - ("kernel_experimental_%s.cubin", ' -D__KERNEL_EXPERIMENTAL__')) - - # add command for each cuda architecture - for arch in cuda_archs: - for config in configs: - # TODO(sergey): Use dict instead ocouple in order to increase readability? - name = config[0] - extra_flags = config[1] - - cubin_file = os.path.join(build_dir, name % arch) - current_flags = nvcc_flags + extra_flags - - if env['BF_CYCLES_CUDA_ENV']: - MS_SDK = "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\SetEnv.cmd" - command = "\"%s\" & \"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (MS_SDK, nvcc, arch, current_flags, kernel_file, cubin_file) - else: - command = "\"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (nvcc, arch, current_flags, kernel_file, cubin_file) - - kernel.Command(cubin_file, kernel_file_rel, command) - kernel.Depends(cubin_file, dependencies) - - kernel_binaries.append(cubin_file) - - if not env['WITH_BF_CYCLES_CUDA_THREADED_COMPILE']: - # trick to compile one kernel at a time to reduce memory usage - if last_cubin_file: - kernel.Depends(cubin_file, last_cubin_file) - last_cubin_file = cubin_file - -Return('kernel_binaries') - diff --git a/intern/cycles/kernel/kernels/cpu/kernel_avx.cpp b/intern/cycles/kernel/kernels/cpu/kernel_avx.cpp index bc754f6832c..a4e43b180fb 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_avx.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_avx.cpp @@ -33,10 +33,5 @@ # include "kernel.h" # define KERNEL_ARCH cpu_avx # include "kernel_cpu_impl.h" -#else /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX */ - -/* needed for some linkers in combination with scons making empty compilation unit in a library */ -void __dummy_function_cycles_avx(void); -void __dummy_function_cycles_avx(void) {} #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX */ diff --git a/intern/cycles/kernel/kernels/cpu/kernel_avx2.cpp b/intern/cycles/kernel/kernels/cpu/kernel_avx2.cpp index ce4a0441f6e..fd6c753b34c 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_avx2.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_avx2.cpp @@ -34,10 +34,5 @@ # include "kernel.h" # define KERNEL_ARCH cpu_avx2 # include "kernel_cpu_impl.h" -#else /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 */ - -/* needed for some linkers in combination with scons making empty compilation unit in a library */ -void __dummy_function_cycles_avx2(void); -void __dummy_function_cycles_avx2(void) {} #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 */ diff --git a/intern/cycles/kernel/kernels/cpu/kernel_sse2.cpp b/intern/cycles/kernel/kernels/cpu/kernel_sse2.cpp index 3142f1d7e8b..7e843dc1c7c 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_sse2.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_sse2.cpp @@ -29,10 +29,5 @@ # include "kernel.h" # define KERNEL_ARCH cpu_sse2 # include "kernel_cpu_impl.h" -#else /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE2 */ - -/* needed for some linkers in combination with scons making empty compilation unit in a library */ -void __dummy_function_cycles_sse2(void); -void __dummy_function_cycles_sse2(void) {} #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE2 */ diff --git a/intern/cycles/kernel/kernels/cpu/kernel_sse3.cpp b/intern/cycles/kernel/kernels/cpu/kernel_sse3.cpp index 93ee7d1a8ef..cc5656ed5be 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_sse3.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_sse3.cpp @@ -31,10 +31,5 @@ # include "kernel.h" # define KERNEL_ARCH cpu_sse3 # include "kernel_cpu_impl.h" -#else /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE3 */ - -/* needed for some linkers in combination with scons making empty compilation unit in a library */ -void __dummy_function_cycles_sse3(void); -void __dummy_function_cycles_sse3(void) {} #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE3 */ diff --git a/intern/cycles/kernel/kernels/cpu/kernel_sse41.cpp b/intern/cycles/kernel/kernels/cpu/kernel_sse41.cpp index c3ace9e8c07..252e16873aa 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_sse41.cpp +++ b/intern/cycles/kernel/kernels/cpu/kernel_sse41.cpp @@ -32,10 +32,5 @@ # include "kernel.h" # define KERNEL_ARCH cpu_sse41 # include "kernel_cpu_impl.h" -#else /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 */ - -/* needed for some linkers in combination with scons making empty compilation unit in a library */ -void __dummy_function_cycles_sse41(void); -void __dummy_function_cycles_sse41(void) {} #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 */ diff --git a/intern/cycles/kernel/osl/SConscript b/intern/cycles/kernel/osl/SConscript deleted file mode 100644 index 74ba5e1020c..00000000000 --- a/intern/cycles/kernel/osl/SConscript +++ /dev/null @@ -1,80 +0,0 @@ -#!/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 ***** - -Import('env') - -defs = [] -incs = [] -cxxflags = Split(env['CXXFLAGS']) - -sources = env.Glob('*.cpp') - -incs.extend('. .. ../svm ../../render ../../util ../../device'.split()) -incs.append(env['BF_OIIO_INC']) -incs.append(env['BF_BOOST_INC']) -incs.append(env['BF_OSL_INC']) -incs.append(env['BF_OPENEXR_INC'].split()) -incs.append('#/intern/atomic') - -defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') -defs.append('CCL_NAMESPACE_END=}') -defs.append('WITH_OSL') - -if env['WITH_UNORDERED_MAP_SUPPORT']: - if env['UNORDERED_MAP_HEADER'] == 'unordered_map': - if env['UNORDERED_MAP_NAMESPACE'] == 'std': - defs.append('CYCLES_STD_UNORDERED_MAP') - elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': - defs.append('CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE') - elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': - defs.append('CYCLES_TR1_UNORDERED_MAP') -else: - print("-- Replacing unordered_map/set with map/set (warning: slower!)") - defs.append('CYCLES_NO_UNORDERED_MAP') - -if env['WITH_BF_CYCLES_DEBUG']: - defs.append('WITH_CYCLES_DEBUG') - -if env['WITH_BF_CYCLES_LOGGING']: - defs.append('WITH_CYCLES_LOGGING') - defs.append('GOOGLE_GLOG_DLL_DECL=') - defs.append('CYCLES_GFLAGS_NAMESPACE=gflags') - if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs.append('#extern/libmv/third_party/glog/src/windows') - incs.append('#extern/libmv/third_party/gflags') - else: - incs.append('#extern/libmv/third_party/glog/src') - incs.append('#extern/libmv/third_party/gflags') - -if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): - cxxflags.append('-DBOOST_NO_RTTI -DBOOST_NO_TYPEID /fp:fast'.split()) - incs.append(env['BF_PTHREADS_INC']) - defs.append('OSL_STATIC_LIBRARY') -else: - cxxflags.append('-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID -ffast-math'.split()) - -env.BlenderLib ('cycles_kernel_osl', sources, incs, defs, libtype=['intern'], priority=[10], cxx_compileflags=cxxflags) diff --git a/intern/cycles/kernel/shaders/SConscript b/intern/cycles/kernel/shaders/SConscript deleted file mode 100644 index 8bc1c2206e0..00000000000 --- a/intern/cycles/kernel/shaders/SConscript +++ /dev/null @@ -1,68 +0,0 @@ -#!/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 ***** - -import sys -import os -import Blender as B - -def normpath(path): - return os.path.abspath(os.path.normpath(path)) - -Import ('env') - -oso_files = [] - -if env['WITH_BF_CYCLES_OSL']: - shaders = env.Clone() - - # osl compiler - osl_compiler = File(env.subst(env['BF_OSL_COMPILER'])).abspath - - # build directory - root_build_dir = normpath(env['BF_BUILDDIR']) - build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel/shaders') - - # source directories and files - source_dir = Dir('.').srcnode().path - - # dependencies - dependencies = shaders.Glob('*.h') - - for f in os.listdir(source_dir): - if f.endswith('.osl'): - osl_file = os.path.join(source_dir, f) - oso_file = os.path.join(build_dir, f.replace('.osl', '.oso')) - - command = "\"%s\" -q -O2 -I\"%s\" -o \"%s\" \"%s\"" % (osl_compiler, source_dir, oso_file, osl_file) - - shaders.Command(oso_file, f, command) - shaders.Depends(oso_file, [f] + dependencies) - - oso_files.append(oso_file) - - -Return('oso_files') |