3 # ***** BEGIN GPL LICENSE BLOCK *****
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
22 # The Original Code is: all of this file.
24 # Contributor(s): Nathan Letwory.
26 # ***** END GPL LICENSE BLOCK *****
28 # Main entry-point for the SCons building system
29 # Set up some custom actions and target/argument handling
30 # Then read all SConscripts and build
32 # TODO: fix /FORCE:MULTIPLE on windows to get proper debug builds.
33 # TODO: directory copy functions are far too complicated, see:
34 # http://wiki.blender.org/index.php/User:Ideasman42/SConsNotSimpleInstallingFiles
43 # store path to tools and modules
44 toolpath=os.path.join(".", "build_files", "scons", "tools")
45 modulespath=os.path.join(".", "build_files", "scons", "Modules")
47 # needed for importing tools and modules
48 sys.path.append(toolpath)
49 sys.path.append(modulespath)
54 EnsureSConsVersion(1,0,0)
56 # Before we do anything, let's check if we have a sane os.environ
57 if not btools.check_environ():
60 BlenderEnvironment = Blender.BlenderEnvironment
63 VERSION = btools.VERSION # This is used in creating the local config directories
64 VERSION_RELEASE_CYCLE = btools.VERSION_RELEASE_CYCLE
67 platform = sys.platform
71 ##### BEGIN SETUP #####
73 B.possible_types = ['core', 'player', 'player2', 'intern', 'extern', 'system']
75 B.binarykind = ['blender' , 'blenderplayer']
76 ##################################
77 # target and argument validation #
78 ##################################
79 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
80 use_color = ARGUMENTS.get('BF_FANCY', '1')
84 if not use_color=='1':
87 #on defaut white Os X terminal, some colors are totally unlegible
88 if platform=='darwin':
89 B.bc.OKGREEN = '\033[34m'
90 B.bc.WARNING = '\033[36m'
93 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
94 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
95 btools.print_arguments(B.arguments, B.bc)
98 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
99 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
100 btools.print_targets(B.targets, B.bc)
102 ##########################
103 # setting up environment #
104 ##########################
106 # handling cmd line arguments & config file
109 tempbitness = int(B.arguments.get('BF_BITNESS', B.bitness)) # default to bitness found as per starting python
110 if tempbitness in B.allowed_bitnesses.values() :
111 B.bitness = tempbitness
113 # first check cmdline for toolset and we create env to work on
114 quickie = B.arguments.get('BF_QUICK', None)
115 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
118 B.quickdebug=string.split(quickdebug, ',')
123 B.quickie=string.split(quickie,',')
127 toolset = B.arguments.get('BF_TOOLSET', None)
128 vcver = B.arguments.get('MSVS_VERSION', '12.0')
131 print "Using " + toolset
132 if toolset=='mstoolkit':
133 env = BlenderEnvironment(ENV = os.environ)
134 env.Tool('mstoolkit', [toolpath])
136 env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
138 btools.SetupSpawn(env)
140 if B.bitness==64 and platform=='win32':
141 env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64', TARGET_ARCH='x86_64', MSVC_VERSION=vcver)
143 env = BlenderEnvironment(ENV = os.environ, TARGET_ARCH='x86', MSVC_VERSION=vcver)
146 print "Could not create a build environment"
149 cc = B.arguments.get('CC', None)
150 cxx = B.arguments.get('CXX', None)
156 if sys.platform=='win32':
157 if env['CC'] in ['cl', 'cl.exe']:
158 platform = 'win64-vc' if B.bitness == 64 else 'win32-vc'
159 elif env['CC'] in ['gcc']:
160 platform = 'win64-mingw' if B.bitness == 64 else 'win32-mingw'
162 if 'mingw' in platform:
163 print "Setting custom spawn function"
164 btools.SetupSpawn(env)
166 env.SConscriptChdir(0)
168 # Remove major kernel version from linux platform.
169 # After Linus switched kernel to new version model this major version
170 # shouldn't take much sense for building rules.
172 if re.match('linux[0-9]+', platform):
175 crossbuild = B.arguments.get('BF_CROSS', None)
176 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
177 platform = 'linuxcross'
179 env['OURPLATFORM'] = platform
181 configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
183 if os.path.exists(configfile):
184 print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
186 print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
188 if crossbuild and env['PLATFORM'] != 'win32':
189 print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
190 env.Tool('crossmingw', [toolpath])
191 # todo: determine proper libs/includes etc.
192 # Needed for gui programs, console programs should do without it
194 # Now we don't need this option to have console window
195 # env.Append(LINKFLAGS=['-mwindows'])
197 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
198 # first read platform config. B.arguments will override
199 optfiles = [configfile]
200 if os.path.exists(userconfig):
201 print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
202 optfiles += [userconfig]
204 print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
206 opts = btools.read_opts(env, optfiles, B.arguments)
209 if sys.platform=='win32':
211 env.Append(CPPFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally
214 env.Append(CPPDEFINES=['_DEBUG', 'DEBUG'])
216 env.Append(CPPDEFINES=['NDEBUG'])
218 if not env['BF_FANCY']:
221 if env['WITH_BF_SDL_DYNLOAD']:
222 env['BF_SDL_INC'] = '#extern/sdlew/include/SDL2'
224 # remove install dir so old and new files are not mixed.
225 # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
226 # TODO: perhaps we need an option (off by default) to not do this altogether...
227 if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
228 scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
229 if os.path.isdir(scriptsDir):
230 print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
231 shutil.rmtree(scriptsDir)
234 SetOption('num_jobs', int(env['BF_NUMJOBS']))
235 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
236 print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
238 if 'blenderlite' in B.targets:
240 target_env_defs['WITH_BF_GAMEENGINE'] = False
241 target_env_defs['WITH_BF_CYCLES'] = False
242 target_env_defs['WITH_BF_OPENAL'] = False
243 target_env_defs['WITH_BF_OPENEXR'] = False
244 target_env_defs['WITH_BF_PSD'] = False
245 target_env_defs['WITH_BF_OPENMP'] = False
246 target_env_defs['WITH_BF_ICONV'] = False
247 target_env_defs['WITH_BF_INTERNATIONAL'] = False
248 target_env_defs['WITH_BF_OPENJPEG'] = False
249 target_env_defs['WITH_BF_FFMPEG'] = False
250 target_env_defs['WITH_BF_QUICKTIME'] = False
251 target_env_defs['WITH_BF_REDCODE'] = False
252 target_env_defs['WITH_BF_DDS'] = False
253 target_env_defs['WITH_BF_CINEON'] = False
254 target_env_defs['WITH_BF_FRAMESERVER'] = False
255 target_env_defs['WITH_BF_HDR'] = False
256 target_env_defs['WITH_BF_ZLIB'] = False
257 target_env_defs['WITH_BF_SDL'] = False
258 target_env_defs['WITH_BF_JPEG'] = False
259 target_env_defs['WITH_BF_PNG'] = False
260 target_env_defs['WITH_BF_BULLET'] = False
261 target_env_defs['WITH_BF_BINRELOC'] = False
262 target_env_defs['BF_BUILDINFO'] = False
263 target_env_defs['WITH_BF_FLUID'] = False
264 target_env_defs['WITH_BF_OCEANSIM'] = False
265 target_env_defs['WITH_BF_SMOKE'] = False
266 target_env_defs['WITH_BF_BOOLEAN'] = False
267 target_env_defs['WITH_BF_REMESH'] = False
268 target_env_defs['WITH_BF_PYTHON'] = False
269 target_env_defs['WITH_BF_IME'] = False
270 target_env_defs['WITH_BF_3DMOUSE'] = False
271 target_env_defs['WITH_BF_LIBMV'] = False
272 target_env_defs['WITH_BF_FREESTYLE'] = False
274 # Merge blenderlite, let command line to override
275 for k,v in target_env_defs.iteritems():
276 if k not in B.arguments:
279 if 'cudakernels' in B.targets:
280 env['WITH_BF_CYCLES'] = True
281 env['WITH_BF_CYCLES_CUDA_BINARIES'] = True
282 env['WITH_BF_PYTHON'] = False
283 env['WITH_BF_LIBMV'] = False
285 # Configure paths for automated configuration test programs
286 env['CONFIGUREDIR'] = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "sconf_temp")))
287 env['CONFIGURELOG'] = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "config.log")))
289 #############################################################################
290 ################### Automatic configuration for OSX ##################
291 #############################################################################
293 if env['OURPLATFORM']=='darwin':
298 command = ["%s"%env['CC'], "--version"]
299 line = btools.get_command_output(command)
300 ver = re.search(r'[0-9]+(\.[0-9]+[svn]+)+', line) or re.search(r'[0-9]+(\.[0-9]+)+', line) # read the "based on LLVM x.xsvn" version here, not the Apple version
302 env['CCVERSION'] = ver.group(0).strip('svn')
303 frontend = re.search(r'gcc', line) or re.search(r'clang', line) or re.search(r'llvm-gcc', line) or re.search(r'icc', line)
305 env['C_COMPILER_ID'] = frontend.group(0)
307 vendor = re.search(r'Apple', line)
309 C_VENDOR = vendor.group(0)
311 C_VENDOR = 'Open Source'
313 print B.bc.OKGREEN + "Using Compiler: " + B.bc.ENDC + env['C_COMPILER_ID'] + '-' + env['CCVERSION'] + ' ( ' + C_VENDOR + ' )'
315 cmd = 'sw_vers -productVersion'
316 MAC_CUR_VER=cmd_res=commands.getoutput(cmd)
317 cmd = 'xcodebuild -version'
318 cmd_xcode=commands.getoutput(cmd)
319 env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version
320 cmd = 'xcodebuild -showsdks'
321 cmd_sdk=commands.getoutput(cmd)
322 MACOSX_SDK_CHECK=cmd_sdk
323 cmd = 'xcode-select --print-path'
324 XCODE_SELECT_PATH=commands.getoutput(cmd)
325 if XCODE_SELECT_PATH.endswith("/Contents/Developer"):
326 XCODE_BUNDLE=XCODE_SELECT_PATH[:-19]
328 XCODE_BUNDLE=XCODE_SELECT_PATH
330 print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
331 print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '')
333 if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
334 if 'OS X 10.10' in MACOSX_SDK_CHECK:
335 env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
336 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.10.sdk'
337 elif 'OS X 10.9' in MACOSX_SDK_CHECK:
338 env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
339 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk'
340 elif 'OS X 10.8' in MACOSX_SDK_CHECK:
341 env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
342 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk'
343 elif 'OS X 10.7' in MACOSX_SDK_CHECK:
344 env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
345 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk'
346 elif 'OS X 10.6' in MACOSX_SDK_CHECK:
347 env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
348 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk'
349 elif 'OS X 10.5' in MACOSX_SDK_CHECK:
350 env['MACOSX_DEPLOYMENT_TARGET'] = '10.5'
351 env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk'
353 env['MACOSX_SDK']='/Developer/SDKs/MacOSX' + env['MACOSX_SDK'] + '.sdk'
355 if env['XCODE_CUR_VER'] >= '4.3': ## since version 4.3, XCode and developer dir are bundled ##
356 env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + env['MACOSX_SDK']
358 print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK']
360 if not env['WITH_OSX_STATICPYTHON'] == 1:
361 # python 3.3 uses Python-framework additionally installed in /Library/Frameworks
362 env['BF_PYTHON'] = '/Library/Frameworks/Python.framework/Versions/'
363 env['BF_PYTHON_INC'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/include/python' + env['BF_PYTHON_VERSION'] + 'm'
364 env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION']
365 env['BF_PYTHON_LIB'] = ''
366 env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m'
367 env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] # link to python framework
369 #Ray trace optimization
370 if env['WITH_BF_RAYOPTIMIZATION'] == 1:
371 if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'i386':
372 env['WITH_BF_RAYOPTIMIZATION'] = 1
374 env['WITH_BF_RAYOPTIMIZATION'] = 0
375 if env['MACOSX_ARCHITECTURE'] == 'i386':
376 env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse']
377 elif env['MACOSX_ARCHITECTURE'] == 'x86_64':
378 env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse','-msse2']
380 if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'ppc64':
381 ARCH_FLAGS = ['-m64']
383 ARCH_FLAGS = ['-m32']
385 env.Append(CPPFLAGS=ARCH_FLAGS)
387 SDK_FLAGS=['-isysroot', env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used
388 env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+ARCH_FLAGS+env['PLATFORM_LINKFLAGS']
389 env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS']
390 env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS']
392 #Intel Macs are CoreDuo and Up
393 if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64':
394 env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-msse','-msse2','-msse3']
395 if env['C_COMPILER_ID'] != 'clang' or (env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.3'):
396 env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize'] # clang xcode 4 does not accept flag
398 env['CCFLAGS'] = env['CCFLAGS']+['-fno-strict-aliasing']
400 # Intel 64bit Macs are Core2Duo and up
401 if env['MACOSX_ARCHITECTURE'] == 'x86_64':
402 env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3']
404 if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.3':
405 env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5
407 # 3DconnexionClient.framework, optionally install
408 if env['WITH_BF_3DMOUSE'] == 1:
409 if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
410 env['WITH_BF_3DMOUSE'] = 0
411 print B.bc.OKGREEN + "3DconnexionClient install not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
413 env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','3DconnexionClient'])
414 env['BF_3DMOUSE_INC'] = '/Library/Frameworks/3DconnexionClient.framework/Headers'
415 print B.bc.OKGREEN + "Using 3Dconnexion"
417 # Jackmp.framework, optionally install
418 if env['WITH_BF_JACK'] == 1:
419 if not os.path.exists('/Library/Frameworks/Jackmp.framework'):
420 env['WITH_BF_JACK'] = 0
421 print B.bc.OKGREEN + "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors !
423 env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp'])
424 print B.bc.OKGREEN + "Using Jack"
426 if env['WITH_BF_SDL']:
427 env.Append(LINKFLAGS=['-lazy_framework','ForceFeedback'])
429 if env['WITH_BF_QUICKTIME'] == 1:
430 env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit']
432 #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
433 # if your compiler does not have accurate suffix you may have to enable it by hand !
434 if env['WITH_BF_OPENMP'] == 1:
435 if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6.1' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4' and C_VENDOR != 'Apple':
436 env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke
437 print B.bc.OKGREEN + "Using OpenMP"
438 if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
439 OSX_OMP_LIBPATH = Dir(env.subst(env['LCGDIR'])).abspath
440 env.Append(BF_PROGRAM_LINKFLAGS=['-L'+OSX_OMP_LIBPATH+'/openmp/lib','-liomp5'])
441 env['CCFLAGS'].append('-I'+OSX_OMP_LIBPATH+'/openmp/include') # include for omp.h
443 env['WITH_BF_OPENMP'] = 0
444 print B.bc.OKGREEN + "Disabled OpenMP, not supported by compiler"
446 if env['WITH_BF_CYCLES_OSL'] == 1:
447 env['WITH_BF_LLVM'] = 1
448 OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
449 # we need 2 variants of passing the oslexec with the force_load option, string and list type atm
450 if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.8' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
451 env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
453 env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
454 env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
456 env['WITH_BF_LLVM'] = 0
458 if env['WITH_BF_LLVM'] == 0:
459 # Due duplicated generic UTF functions, we pull them either from LLVMSupport or COLLADA
460 env.Append(BF_OPENCOLLADA_LIB=' UTF')
462 # Trying to get rid of eventually clashes, we export some symbols explicite as local
463 env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
465 #for < 10.7.sdk, SystemStubs needs to be linked
466 if env['MACOSX_SDK'].endswith("10.6.sdk") or env['MACOSX_SDK'].endswith("10.5.sdk"):
467 env['LLIBS'].append('SystemStubs')
469 #############################################################################
470 ################### End Automatic configuration for OSX ##################
471 #############################################################################
473 if env['OURPLATFORM'] == 'linux' and not env['C_COMPILER_ID']:
474 command = ["%s"%env['CC'], "--version"]
475 line = btools.get_command_output(command)
476 if line.startswith('gcc'):
477 env['C_COMPILER_ID'] = 'gcc'
478 elif 'clang' in line[0]:
479 env['C_COMPILER_ID'] = 'clang'
481 if env['WITH_BF_OPENMP'] == 1:
482 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
483 env['CCFLAGS'].append('/openmp')
485 if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
486 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
487 env['CCFLAGS'].append('-openmp')
489 env.Append(CCFLAGS=['-fopenmp'])
491 if env['WITH_BF_CPP11']:
492 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
493 # Nothing special is needed, C++11 features are available by default.
496 env['CXXFLAGS'].append('-std=c++11')
498 #check for additional debug libnames
500 if env.has_key('BF_DEBUG_LIBS'):
501 B.quickdebug += env['BF_DEBUG_LIBS']
503 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
505 if len(B.quickdebug) > 0 and printdebug != 0:
506 print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
507 for l in B.quickdebug:
510 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
511 if env['WITH_BF_STATICCXX']:
512 if 'stdc++' in env['LLIBS']:
513 env['LLIBS'].remove('stdc++')
515 print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
517 # audaspace is needed for the game engine
518 if not env['WITH_BF_AUDASPACE']:
519 env['WITH_BF_GAMEENGINE'] = False
521 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
522 if 'blenderplayer' in B.targets:
523 env['WITH_BF_PLAYER'] = True
525 if 'blendernogame' in B.targets:
526 env['WITH_BF_GAMEENGINE'] = False
528 if not env['WITH_BF_GAMEENGINE']:
529 env['WITH_BF_PLAYER'] = False
531 # build without elbeem (fluidsim)?
532 if env['WITH_BF_FLUID'] == 1:
533 env['CPPFLAGS'].append('-DWITH_MOD_FLUID')
535 # build with ocean sim?
536 if env['WITH_BF_OCEANSIM'] == 1:
537 env['WITH_BF_FFTW3'] = 1 # ocean needs fftw3 so enable it
538 env['CPPFLAGS'].append('-DWITH_MOD_OCEANSIM')
541 if btools.ENDIAN == "big":
542 env['CPPFLAGS'].append('-D__BIG_ENDIAN__')
544 env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
546 # TODO, make optional (as with CMake)
547 env['CPPFLAGS'].append('-DWITH_AVI')
548 env['CPPFLAGS'].append('-DWITH_OPENNL')
550 if env['OURPLATFORM'] not in ('win32-vc', 'win64-vc'):
551 env['CPPFLAGS'].append('-DHAVE_STDBOOL_H')
555 if env['WITH_BF_AUDASPACE']:
556 env['BF_AUDASPACE_C_INC'] = '#intern/audaspace/intern'
557 env['BF_AUDASPACE_PY_INC'] = '#intern/audaspace/intern'
558 env['BF_AUDASPACE_DEF'] = ['WITH_AUDASPACE']
559 env['BF_AUDASPACE_DEF'].append('AUD_DEVICE_H="<AUD_C-API.h>"')
560 env['BF_AUDASPACE_DEF'].append('AUD_SPECIAL_H="<AUD_C-API.h>"')
561 env['BF_AUDASPACE_DEF'].append('AUD_SOUND_H="<AUD_C-API.h>"')
562 env['BF_AUDASPACE_DEF'].append('AUD_HANDLE_H="<AUD_C-API.h>"')
563 env['BF_AUDASPACE_DEF'].append('AUD_SEQUENCE_H="<AUD_C-API.h>"')
564 env['BF_AUDASPACE_DEF'].append('AUD_TYPES_H="<AUD_Space.h>"')
568 if env['WITH_BF_GL_PROFILE_COMPAT']:
569 env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_COMPAT')
571 if env['WITH_BF_GL_PROFILE_CORE']:
572 env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_CORE')
574 if env['WITH_BF_GL_PROFILE_ES20']:
575 env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_ES20')
577 if env['WITH_BF_GL_EGL']:
578 env['BF_GL_DEFINITIONS'].append('WITH_EGL')
582 if env['WITH_BF_GLEW_MX']:
583 env['BF_GL_DEFINITIONS'].append('WITH_GLEW_MX')
585 if env['WITH_BF_GLEW_ES']:
586 env['BF_GLEW_INC'] = '#extern/glew-es/include'
588 env['BF_GL_DEFINITIONS'] += ['GLEW_STATIC', 'WITH_GLEW_ES']
590 if not env['WITH_BF_GL_PROFILE_ES20']:
591 # No ES functions are needed
592 env['BF_GL_DEFINITIONS'].append('GLEW_NO_ES')
593 elif not (env['WITH_BF_GL_PROFILE_CORE'] or env['WITH_BF_GL_PROFILE_COMPAT']):
594 # ES is enabled, but the other functions are all disabled
595 env['BF_GL_DEFINITIONS'].append('GLEW_ES_ONLY')
597 if env['WITH_BF_GL_PROFILE_ES20']:
598 if env['WITH_BF_GL_EGL']:
599 env['BF_GL_DEFINITIONS'].append('GLEW_USE_LIB_ES20')
601 if env['WITH_BF_GL_EGL']:
602 env['BF_GL_DEFINITIONS'].append('GLEW_INC_EGL')
605 env['BF_GLEW_INC'] = '#extern/glew/include'
607 env['BF_GL_DEFINITIONS'].append('GLEW_STATIC')
609 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
610 B.root_build_dir = env['BF_BUILDDIR']
611 B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
612 if not B.root_build_dir[-1]==os.sep:
613 B.root_build_dir += os.sep
614 if not B.doc_build_dir[-1]==os.sep:
615 B.doc_build_dir += os.sep
617 # We do a shortcut for clean when no quicklist is given: just delete
618 # builddir without reading in SConscripts
620 if 'clean' in B.targets:
623 if not quickie and do_clean:
624 if os.path.exists(B.doc_build_dir):
625 print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
626 dirs = os.listdir(B.doc_build_dir)
628 if os.path.isdir(B.doc_build_dir + entry) == 1:
629 print "clean dir %s"%(B.doc_build_dir+entry)
630 shutil.rmtree(B.doc_build_dir+entry)
632 print "remove file %s"%(B.doc_build_dir+entry)
633 os.remove(B.root_build_dir+entry)
634 if os.path.exists(B.root_build_dir):
635 print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
636 dirs = os.listdir(B.root_build_dir)
638 if os.path.isdir(B.root_build_dir + entry) == 1:
639 print "clean dir %s"%(B.root_build_dir+entry)
640 shutil.rmtree(B.root_build_dir+entry)
642 print "remove file %s"%(B.root_build_dir+entry)
643 os.remove(B.root_build_dir+entry)
644 for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
645 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
646 if os.path.exists(confile):
647 print "clean file %s"%confile
648 if os.path.isdir(confile):
649 for root, dirs, files in os.walk(confile):
651 os.remove(os.path.join(root, name))
654 print B.bc.OKGREEN+'...done'+B.bc.ENDC
656 print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
660 # ensure python header is found since detection can fail, this could happen
661 # with _any_ library but since we used a fixed python version this tends to
662 # be most problematic.
663 if env['WITH_BF_PYTHON']:
664 found_python_h = found_pyconfig_h = False
665 for bf_python_inc in env.subst('${BF_PYTHON_INC}').split():
666 py_h = os.path.join(Dir(bf_python_inc).abspath, "Python.h")
667 if os.path.exists(py_h):
668 found_python_h = True
669 py_h = os.path.join(Dir(bf_python_inc).abspath, "pyconfig.h")
670 if os.path.exists(py_h):
671 found_pyconfig_h = True
673 if not (found_python_h and found_pyconfig_h):
674 print("""\nMissing: Python.h and/or pyconfig.h in "%s"
675 Set 'BF_PYTHON_INC' to point to valid include path(s),
676 containing Python.h and pyconfig.h for Python version "%s".
678 Example: python scons/scons.py BF_PYTHON_INC=../Python/include
679 """ % (env.subst('${BF_PYTHON_INC}'), env.subst('${BF_PYTHON_VERSION}')))
683 if not os.path.isdir ( B.root_build_dir):
684 os.makedirs ( B.root_build_dir )
685 os.makedirs ( B.root_build_dir + 'source' )
686 os.makedirs ( B.root_build_dir + 'intern' )
687 os.makedirs ( B.root_build_dir + 'extern' )
688 os.makedirs ( B.root_build_dir + 'lib' )
689 os.makedirs ( B.root_build_dir + 'bin' )
690 # # Docs not working with epy anymore
691 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
692 # os.makedirs ( B.doc_build_dir )
695 ###################################
696 # Ensure all data files are valid #
697 ###################################
698 if not os.path.isdir ( B.root_build_dir + 'data_headers'):
699 os.makedirs ( B.root_build_dir + 'data_headers' )
700 if not os.path.isdir ( B.root_build_dir + 'data_sources'):
701 os.makedirs ( B.root_build_dir + 'data_sources' )
703 env['DATA_HEADERS'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_headers")
704 env['DATA_SOURCES'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_sources")
705 def data_to_c(FILE_FROM, FILE_TO, VAR_NAME):
707 FILE_FROM = FILE_FROM.replace("/", "\\")
708 FILE_TO = FILE_TO.replace("/", "\\")
711 # first check if we need to bother.
712 if os.path.exists(FILE_TO):
713 if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
716 print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
717 fpin = open(FILE_FROM, "rb")
718 fpin.seek(0, os.SEEK_END)
722 fpout = open(FILE_TO, "w")
723 fpout.write("int %s_size = %d;\n" % (VAR_NAME, size))
724 fpout.write("char %s[] = {\n" % VAR_NAME)
731 fpout.write("%3d," % ord(fpin.read(1)))
732 fpout.write("\n 0};\n\n")
736 except KeyboardInterrupt:
737 if os.path.exists(FILE_TO):
739 raise KeyboardInterrupt
741 def data_to_c_simple(FILE_FROM):
742 filename_only = os.path.basename(FILE_FROM)
743 FILE_TO = os.path.join(env['DATA_SOURCES'], filename_only + ".c")
744 VAR_NAME = "datatoc_" + filename_only.replace(".", "_")
746 data_to_c(FILE_FROM, FILE_TO, VAR_NAME)
749 def data_to_c_simple_icon(PATH_FROM):
751 # first handle import
753 path = "source/blender/datatoc"
754 if path not in sys.path:
755 sys.path.append(path)
757 # convert the pixmaps to a png
760 filename_only = os.path.basename(PATH_FROM)
761 FILE_TO_PNG = os.path.join(env['DATA_SOURCES'], filename_only + ".png")
762 FILE_TO = FILE_TO_PNG + ".c"
763 argv = [PATH_FROM, FILE_TO_PNG]
765 datatoc_icon.main_ex(argv)
766 except KeyboardInterrupt:
767 if os.path.exists(FILE_TO_PNG):
768 os.remove(FILE_TO_PNG)
769 raise KeyboardInterrupt
771 # then the png to a c file
772 data_to_c_simple(FILE_TO_PNG)
775 if B.targets != ['cudakernels']:
776 data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl",
777 B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h",
778 "datatoc_COM_OpenCLKernels_cl")
780 data_to_c_simple("release/datafiles/startup.blend")
781 data_to_c_simple("release/datafiles/preview.blend")
782 data_to_c_simple("release/datafiles/preview_cycles.blend")
785 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_geometry.glsl")
787 data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_frag.glsl")
788 data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_color_frag.glsl")
790 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_simple_frag.glsl")
791 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_simple_vert.glsl")
792 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
793 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
794 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl")
795 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl")
796 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl")
797 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex_world.glsl")
798 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl")
799 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl")
800 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl")
801 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl")
802 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl")
803 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl")
804 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl")
805 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl")
806 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_lib.glsl")
807 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl")
808 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_vert.glsl")
809 data_to_c_simple("intern/opencolorio/gpu_shader_display_transform.glsl")
810 data_to_c_simple("intern/opensubdiv/gpu_shader_opensubd_display.glsl")
813 data_to_c_simple("release/datafiles/bfont.pfb")
814 data_to_c_simple("release/datafiles/bfont.ttf")
815 data_to_c_simple("release/datafiles/bmonofont.ttf")
817 data_to_c_simple("release/datafiles/splash.png")
818 data_to_c_simple("release/datafiles/splash_2x.png")
820 # data_to_c_simple("release/datafiles/blender_icons16.png")
821 # data_to_c_simple("release/datafiles/blender_icons32.png")
822 data_to_c_simple_icon("release/datafiles/blender_icons16")
823 data_to_c_simple_icon("release/datafiles/blender_icons32")
825 data_to_c_simple("release/datafiles/prvicons.png")
827 data_to_c_simple("release/datafiles/brushicons/add.png")
828 data_to_c_simple("release/datafiles/brushicons/blob.png")
829 data_to_c_simple("release/datafiles/brushicons/blur.png")
830 data_to_c_simple("release/datafiles/brushicons/clay.png")
831 data_to_c_simple("release/datafiles/brushicons/claystrips.png")
832 data_to_c_simple("release/datafiles/brushicons/clone.png")
833 data_to_c_simple("release/datafiles/brushicons/crease.png")
834 data_to_c_simple("release/datafiles/brushicons/darken.png")
835 data_to_c_simple("release/datafiles/brushicons/draw.png")
836 data_to_c_simple("release/datafiles/brushicons/fill.png")
837 data_to_c_simple("release/datafiles/brushicons/flatten.png")
838 data_to_c_simple("release/datafiles/brushicons/grab.png")
839 data_to_c_simple("release/datafiles/brushicons/inflate.png")
840 data_to_c_simple("release/datafiles/brushicons/layer.png")
841 data_to_c_simple("release/datafiles/brushicons/lighten.png")
842 data_to_c_simple("release/datafiles/brushicons/mask.png")
843 data_to_c_simple("release/datafiles/brushicons/mix.png")
844 data_to_c_simple("release/datafiles/brushicons/multiply.png")
845 data_to_c_simple("release/datafiles/brushicons/nudge.png")
846 data_to_c_simple("release/datafiles/brushicons/pinch.png")
847 data_to_c_simple("release/datafiles/brushicons/scrape.png")
848 data_to_c_simple("release/datafiles/brushicons/smear.png")
849 data_to_c_simple("release/datafiles/brushicons/smooth.png")
850 data_to_c_simple("release/datafiles/brushicons/snake_hook.png")
851 data_to_c_simple("release/datafiles/brushicons/soften.png")
852 data_to_c_simple("release/datafiles/brushicons/subtract.png")
853 data_to_c_simple("release/datafiles/brushicons/texdraw.png")
854 data_to_c_simple("release/datafiles/brushicons/texfill.png")
855 data_to_c_simple("release/datafiles/brushicons/texmask.png")
856 data_to_c_simple("release/datafiles/brushicons/thumb.png")
857 data_to_c_simple("release/datafiles/brushicons/twist.png")
858 data_to_c_simple("release/datafiles/brushicons/vertexdraw.png")
860 data_to_c_simple("release/datafiles/matcaps/mc01.jpg")
861 data_to_c_simple("release/datafiles/matcaps/mc02.jpg")
862 data_to_c_simple("release/datafiles/matcaps/mc03.jpg")
863 data_to_c_simple("release/datafiles/matcaps/mc04.jpg")
864 data_to_c_simple("release/datafiles/matcaps/mc05.jpg")
865 data_to_c_simple("release/datafiles/matcaps/mc06.jpg")
866 data_to_c_simple("release/datafiles/matcaps/mc07.jpg")
867 data_to_c_simple("release/datafiles/matcaps/mc08.jpg")
868 data_to_c_simple("release/datafiles/matcaps/mc09.jpg")
869 data_to_c_simple("release/datafiles/matcaps/mc10.jpg")
870 data_to_c_simple("release/datafiles/matcaps/mc11.jpg")
871 data_to_c_simple("release/datafiles/matcaps/mc12.jpg")
872 data_to_c_simple("release/datafiles/matcaps/mc13.jpg")
873 data_to_c_simple("release/datafiles/matcaps/mc14.jpg")
874 data_to_c_simple("release/datafiles/matcaps/mc15.jpg")
875 data_to_c_simple("release/datafiles/matcaps/mc16.jpg")
876 data_to_c_simple("release/datafiles/matcaps/mc17.jpg")
877 data_to_c_simple("release/datafiles/matcaps/mc18.jpg")
878 data_to_c_simple("release/datafiles/matcaps/mc19.jpg")
879 data_to_c_simple("release/datafiles/matcaps/mc20.jpg")
880 data_to_c_simple("release/datafiles/matcaps/mc21.jpg")
881 data_to_c_simple("release/datafiles/matcaps/mc22.jpg")
882 data_to_c_simple("release/datafiles/matcaps/mc23.jpg")
883 data_to_c_simple("release/datafiles/matcaps/mc24.jpg")
885 ##### END DATAFILES ##########
887 Help(opts.GenerateHelpText(env))
889 # default is new quieter output, but if you need to see the
890 # commands, do 'scons BF_QUIET=0'
891 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
893 B.set_quiet_output(env)
898 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
899 env.SConsignFile(B.root_build_dir+'scons-signatures')
902 ##### END SETUP ##########
904 ## Auto-configuration run-time tests
906 from FindSharedPtr import FindSharedPtr
907 from FindUnorderedMap import FindUnorderedMap
909 conf = Configure(env)
910 old_linkflags = conf.env['LINKFLAGS']
911 conf.env.Append(LINKFLAGS=env['PLATFORM_LINKFLAGS'])
915 FindUnorderedMap(conf)
917 conf.env['LINKFLAGS'] = old_linkflags
920 # End of auto configuration
924 VariantDir(B.root_build_dir+'/source', 'source', duplicate=0)
925 SConscript(B.root_build_dir+'/source/SConscript')
926 VariantDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
927 SConscript(B.root_build_dir+'/intern/SConscript')
928 VariantDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
929 SConscript(B.root_build_dir+'/extern/SConscript')
931 # now that we have read all SConscripts, we know what
932 # libraries will be built. Create list of
933 # libraries to give as objects to linking phase
935 for tp in B.possible_types:
936 if (not tp == 'player') and (not tp == 'player2') and (not tp == 'system'):
937 mainlist += B.create_blender_liblist(env, tp)
939 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
940 B.propose_priorities()
942 dobj = B.buildinfo(env, "dynamic") + B.resources
943 creob = B.creator(env)
944 thestatlibs, thelibincs = B.setup_staticlibs(env)
945 thesyslibs = B.setup_syslibs(env)
947 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
948 blender_progname = "blender"
949 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
950 blender_progname = "blender-app"
953 lenv.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS'])
954 targetpath = B.root_build_dir + '/blender'
955 launcher_obj = [env.Object(B.root_build_dir + 'source/creator/creator/creator_launch_win', ['#source/creator/creator_launch_win.c'])]
956 env.BlenderProg(B.root_build_dir, 'blender', [launcher_obj] + B.resources, ['bf_utfconv'] + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
958 env.BlenderProg(B.root_build_dir, blender_progname, creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
959 if env['WITH_BF_PLAYER']:
960 playerlist = B.create_blender_liblist(env, 'player')
961 playerlist += B.create_blender_liblist(env, 'player2')
962 playerlist += B.create_blender_liblist(env, 'intern')
963 playerlist += B.create_blender_liblist(env, 'extern')
964 env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
966 ##### Now define some targets
969 #------------ INSTALL
973 if env['OURPLATFORM']=='darwin':
974 for prg in B.program_list:
975 bundle = '%s.app' % prg[0]
976 bundledir = os.path.dirname(bundle)
977 for dp, dn, df in os.walk(bundle):
984 dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
985 source=[dp+os.sep+f for f in df]
986 blenderinstall.append(env.Install(dir=dir,source=source))
988 blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
990 #-- local path = config files in install dir: installdir\VERSION
991 #- dont do config and scripts for darwin, it is already in the bundle
994 datafilestargetlist = []
999 if env['OURPLATFORM']!='darwin':
1000 dotblenderinstall = []
1001 for targetdir,srcfile in zip(dottargetlist, dotblendlist):
1002 td, tf = os.path.split(targetdir)
1003 dotblenderinstall.append(env.Install(dir=td, source=srcfile))
1004 for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
1005 td, tf = os.path.split(targetdir)
1006 dotblenderinstall.append(env.Install(dir=td, source=srcfile))
1008 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
1009 scriptinstall.append(env.InstallAs(env['BF_INSTALLDIR'] + '/blender-app.exe.manifest',
1010 'source/icons/blender.exe.manifest'))
1012 if env['WITH_BF_PYTHON']:
1013 #-- local/VERSION/scripts
1014 scriptpaths=['release/scripts']
1015 for scriptpath in scriptpaths:
1016 for dp, dn, df in os.walk(scriptpath):
1019 if '__pycache__' in dn: # py3.2 cache dir
1020 dn.remove('__pycache__')
1022 # only for testing builds
1023 if VERSION_RELEASE_CYCLE == "release" and "addons_contrib" in dn:
1024 dn.remove('addons_contrib')
1026 # do not install freestyle if disabled
1027 if not env['WITH_BF_FREESTYLE'] and "freestyle" in dn:
1028 dn.remove("freestyle")
1030 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1031 dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
1033 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1034 # To ensure empty dirs are created too
1035 if len(source)==0 and not os.path.exists(dir):
1036 env.Execute(Mkdir(dir))
1037 scriptinstall.append(env.Install(dir=dir,source=source))
1038 if env['WITH_BF_CYCLES']:
1039 # cycles python code
1040 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles')
1041 source=os.listdir('intern/cycles/blender/addon')
1042 if '__pycache__' in source: source.remove('__pycache__')
1043 source=['intern/cycles/blender/addon/'+s for s in source]
1044 scriptinstall.append(env.Install(dir=dir,source=source))
1046 # cycles kernel code
1047 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
1048 source=os.listdir('intern/cycles/kernel')
1049 if '__pycache__' in source: source.remove('__pycache__')
1050 source.remove('CMakeLists.txt')
1051 source.remove('SConscript')
1052 source.remove('svm')
1053 source.remove('closure')
1054 source.remove('geom')
1055 source.remove('shaders')
1056 source.remove('osl')
1057 source.remove('split')
1058 source=['intern/cycles/kernel/'+s for s in source]
1059 source.append('intern/cycles/util/util_atomic.h')
1060 source.append('intern/cycles/util/util_color.h')
1061 source.append('intern/cycles/util/util_half.h')
1062 source.append('intern/cycles/util/util_math.h')
1063 source.append('intern/cycles/util/util_math_fast.h')
1064 source.append('intern/cycles/util/util_transform.h')
1065 source.append('intern/cycles/util/util_types.h')
1066 scriptinstall.append(env.Install(dir=dir,source=source))
1068 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'svm')
1069 source=os.listdir('intern/cycles/kernel/svm')
1070 if '__pycache__' in source: source.remove('__pycache__')
1071 source=['intern/cycles/kernel/svm/'+s for s in source]
1072 scriptinstall.append(env.Install(dir=dir,source=source))
1074 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'closure')
1075 source=os.listdir('intern/cycles/kernel/closure')
1076 if '__pycache__' in source: source.remove('__pycache__')
1077 source=['intern/cycles/kernel/closure/'+s for s in source]
1078 scriptinstall.append(env.Install(dir=dir,source=source))
1080 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'geom')
1081 source=os.listdir('intern/cycles/kernel/geom')
1082 if '__pycache__' in source: source.remove('__pycache__')
1083 source=['intern/cycles/kernel/geom/'+s for s in source]
1084 scriptinstall.append(env.Install(dir=dir,source=source))
1086 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'split')
1087 source=os.listdir('intern/cycles/kernel/split')
1088 if '__pycache__' in source: source.remove('__pycache__')
1089 source=['intern/cycles/kernel/split/'+s for s in source]
1090 scriptinstall.append(env.Install(dir=dir,source=source))
1093 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
1094 source=os.listdir('intern/cycles/doc/license')
1095 if '__pycache__' in source: source.remove('__pycache__')
1096 source.remove('CMakeLists.txt')
1097 source=['intern/cycles/doc/license/'+s for s in source]
1098 scriptinstall.append(env.Install(dir=dir,source=source))
1100 if env['WITH_BF_CYCLES']:
1102 if env['WITH_BF_CYCLES_CUDA_BINARIES']:
1103 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
1104 for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
1105 kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
1106 for suffix in ('', '_experimental'):
1107 cubin_file = os.path.join(kernel_build_dir, "kernel%s_%s.cubin" % (suffix, arch))
1108 cubininstall.append(env.Install(dir=dir,source=cubin_file))
1111 if env['WITH_BF_CYCLES_OSL']:
1112 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader')
1114 osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path
1115 oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders')
1117 headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split()
1118 source=['intern/cycles/kernel/shaders/'+s for s in headers]
1119 scriptinstall.append(env.Install(dir=dir,source=source))
1121 for f in os.listdir(osl_source_dir):
1122 if f.endswith('.osl'):
1123 oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso'))
1124 scriptinstall.append(env.Install(dir=dir,source=oso_file))
1126 if env['WITH_BF_OCIO']:
1127 colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
1129 for dp, dn, df in os.walk(colormanagement):
1130 dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
1131 dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
1133 source = [os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1135 # To ensure empty dirs are created too
1136 if len(source) == 0:
1137 env.Execute(Mkdir(dir))
1139 scriptinstall.append(env.Install(dir=dir,source=source))
1141 if env['WITH_BF_INTERNATIONAL']:
1142 internationalpaths=['release' + os.sep + 'datafiles']
1144 def check_path(path, member):
1145 return (member in path.split(os.sep))
1147 po_dir = os.path.join("release", "datafiles", "locale", "po")
1150 for intpath in internationalpaths:
1151 for dp, dn, df in os.walk(intpath):
1155 # we only care about release/datafiles/fonts, release/datafiles/locales
1156 if check_path(dp, "fonts"):
1161 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1162 dir += os.sep + os.path.basename(intpath) + dp[len(intpath):]
1164 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
1165 # To ensure empty dirs are created too
1167 env.Execute(Mkdir(dir))
1168 scriptinstall.append(env.Install(dir=dir,source=source))
1171 for f in os.listdir(po_dir):
1172 if not f.endswith(".po"):
1175 locale_name = os.path.splitext(f)[0]
1177 mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo")
1179 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1180 dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES")
1181 scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file))
1184 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
1185 dir = os.path.join(dir, "datafiles", "locale")
1186 languages_file = os.path.join("release", "datafiles", "locale", "languages")
1187 scriptinstall.append(env.InstallAs(os.path.join(dir, "languages"), languages_file))
1190 if env['OURPLATFORM']=='linux':
1194 for tp, tn, tf in os.walk('release/freedesktop/icons'):
1196 iconlist.append(os.path.join(tp, f))
1197 icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
1200 for targetdir,srcfile in zip(icontargetlist, iconlist):
1201 td, tf = os.path.split(targetdir)
1202 iconinstall.append(env.Install(dir=td, source=srcfile))
1204 scriptinstall.append(env.Install(dir=env['BF_INSTALLDIR'], source='release/bin/blender-thumbnailer.py'))
1206 # dlls for linuxcross
1207 # TODO - add more libs, for now this lets blenderlite run
1208 if env['OURPLATFORM']=='linuxcross':
1209 dir=env['BF_INSTALLDIR']
1212 if env['WITH_BF_OPENMP']:
1213 source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
1215 scriptinstall.append(env.Install(dir=dir, source=source))
1219 for tp, tn, tf in os.walk('release/text'):
1220 tf.remove("readme.html")
1222 textlist.append(tp+os.sep+f)
1224 def readme_version_patch():
1225 readme_src = "release/text/readme.html"
1226 readme_dst = os.path.abspath(os.path.normpath(os.path.join(env['BF_BUILDDIR'], "readme.html")))
1228 if not os.path.exists(readme_dst) or (os.path.getmtime(readme_dst) < os.path.getmtime(readme_src)):
1229 f = open(readme_src, "r")
1233 data = data.replace("BLENDER_VERSION", VERSION)
1234 f = open(readme_dst, "w")
1238 textlist.append(readme_dst)
1240 readme_version_patch()
1241 del readme_version_patch
1245 "release/text/readme.html"
1248 Command("file.out", "file.in", Copy(env['BF_INSTALLDIR'], "release/text/readme.html"))
1252 textlist.append('release/datafiles/LICENSE-bfont.ttf.txt')
1253 if env['WITH_BF_INTERNATIONAL']:
1254 textlist += ['release/datafiles/LICENSE-droidsans.ttf.txt', 'release/datafiles/LICENSE-bmonofont-i18n.ttf.txt']
1256 textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
1258 if env['OURPLATFORM']=='darwin':
1259 allinstall = [blenderinstall, textinstall]
1260 elif env['OURPLATFORM']=='linux':
1261 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, iconinstall, cubininstall]
1263 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, cubininstall]
1265 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
1268 # Used when linking to libtiff was dynamic
1269 # keep it here until compilation on all platform would be ok
1270 # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
1272 if env['OURPLATFORM'] != 'linuxcross':
1273 # pthreads library is already added
1274 dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
1276 if env['WITH_BF_SDL']:
1277 dllsources.append('${BF_SDL_LIBPATH}/SDL2.dll')
1279 if env['WITH_BF_PYTHON']:
1281 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
1282 dllsources.append('${BF_PYTHON_LIBPATH}/sqlite3_d.dll')
1284 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
1285 dllsources.append('${BF_PYTHON_LIBPATH}/sqlite3.dll')
1287 if env['WITH_BF_ICONV']:
1288 if env['OURPLATFORM'] == 'win64-vc':
1289 pass # we link statically to iconv on win64
1290 elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
1291 #gettext for MinGW and cross-compilation is compiled staticly
1292 dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
1294 if env['WITH_BF_OPENAL']:
1295 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
1297 if env['WITH_BF_SNDFILE']:
1298 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
1300 if env['WITH_BF_FFMPEG']:
1301 dllsources += env['BF_FFMPEG_DLL'].split()
1303 # Since the thumb handler is loaded by Explorer, architecture is
1304 # strict: the x86 build fails on x64 Windows. We need to ship
1305 # both builds in x86 packages.
1307 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
1308 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
1310 if env['WITH_BF_OCIO']:
1311 if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
1312 dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
1315 dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
1317 dllsources.append('#source/icons/blender.exe.manifest')
1319 windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
1320 allinstall += windlls
1322 # TODO(sergey): For unti we've got better way to deal with python binary
1323 if env['WITH_BF_PYTHON']:
1324 py_target = os.path.join(env['BF_INSTALLDIR'], VERSION, 'python', 'bin')
1326 allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll'])
1328 allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll'])
1331 if env['OURPLATFORM'] == 'win64-mingw':
1334 if env['WITH_BF_PYTHON']:
1336 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
1338 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
1340 if env['WITH_BF_FFMPEG']:
1341 dllsources += env['BF_FFMPEG_DLL'].split()
1343 if env['WITH_BF_OPENAL']:
1344 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
1345 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
1347 if env['WITH_BF_SNDFILE']:
1348 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
1350 if env['WITH_BF_SDL']:
1351 dllsources.append('${LCGDIR}/sdl/lib/SDL.dll')
1353 if(env['WITH_BF_OPENMP']):
1354 dllsources.append('${LCGDIR}/binaries/libgomp-1.dll')
1356 if env['WITH_BF_OCIO']:
1357 dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
1359 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
1360 dllsources.append('${LCGDIR}/binaries/libgcc_s_sjlj-1.dll')
1361 dllsources.append('${LCGDIR}/binaries/libwinpthread-1.dll')
1362 dllsources.append('${LCGDIR}/binaries/libstdc++-6.dll')
1363 dllsources.append('#source/icons/blender.exe.manifest')
1365 windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
1366 allinstall += windlls
1368 installtarget = env.Alias('install', allinstall)
1369 bininstalltarget = env.Alias('install-bin', blenderinstall)
1371 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
1372 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
1373 nsisalias = env.Alias('nsis', nsiscmd)
1375 if 'blender' in B.targets:
1376 blenderexe= env.Alias('blender', B.program_list)
1377 Depends(blenderexe,installtarget)
1379 if env['WITH_BF_PLAYER']:
1380 blenderplayer = env.Alias('blenderplayer', B.program_list)
1381 Depends(blenderplayer,installtarget)
1383 if not env['WITH_BF_GAMEENGINE']:
1384 blendernogame = env.Alias('blendernogame', B.program_list)
1385 Depends(blendernogame,installtarget)
1387 if 'blenderlite' in B.targets:
1388 blenderlite = env.Alias('blenderlite', B.program_list)
1389 Depends(blenderlite,installtarget)
1391 Depends(nsiscmd, allinstall)
1393 buildslave_action = env.Action(btools.buildslave, btools.buildslave_print)
1394 buildslave_cmd = env.Command('buildslave_exec', None, buildslave_action)
1395 buildslave_alias = env.Alias('buildslave', buildslave_cmd)
1397 Depends(buildslave_cmd, allinstall)
1399 cudakernels_action = env.Action(btools.cudakernels, btools.cudakernels_print)
1400 cudakernels_cmd = env.Command('cudakernels_exec', None, cudakernels_action)
1401 cudakernels_alias = env.Alias('cudakernels', cudakernels_cmd)
1403 cudakernel_dir = os.path.join(os.path.abspath(os.path.normpath(B.root_build_dir)), 'intern/cycles/kernel')
1406 for x in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
1407 cubin = os.path.join(cudakernel_dir, 'kernel_' + x + '.cubin')
1408 cuda_kernels.append(cubin)
1410 Depends(cudakernels_cmd, cuda_kernels)
1411 Depends(cudakernels_cmd, cubininstall)
1413 Default(B.program_list)
1415 if not env['WITHOUT_BF_INSTALL']:
1416 Default(installtarget)