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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
36 import platform as pltfrm
38 # Need a better way to do this. Automagical maybe is not the best thing, maybe it is.
39 if pltfrm.architecture()[0] == '64bit':
51 from tempfile import mkdtemp
54 toolpath=os.path.join(".", "build_files", "scons", "tools")
56 # needed for importing tools
57 sys.path.append(toolpath)
63 EnsureSConsVersion(1,0,0)
65 # Before we do anything, let's check if we have a sane os.environ
66 if not btools.check_environ():
69 BlenderEnvironment = Blender.BlenderEnvironment
72 VERSION = btools.VERSION # This is used in creating the local config directories
73 VERSION_RELEASE_CYCLE = btools.VERSION_RELEASE_CYCLE
76 platform = sys.platform
80 ##### BEGIN SETUP #####
82 B.possible_types = ['core', 'player', 'player2', 'intern', 'extern']
84 B.binarykind = ['blender' , 'blenderplayer']
85 ##################################
86 # target and argument validation #
87 ##################################
88 # XX cheating for BF_FANCY, we check for BF_FANCY before args are validated
89 use_color = ARGUMENTS.get('BF_FANCY', '1')
93 if not use_color=='1':
96 #on defaut white Os X terminal, some colors are totally unlegible
97 if platform=='darwin':
98 B.bc.OKGREEN = '\033[34m'
99 B.bc.WARNING = '\033[36m'
102 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
103 B.arguments = btools.validate_arguments(ARGUMENTS, B.bc)
104 btools.print_arguments(B.arguments, B.bc)
107 print B.bc.HEADER+'Command-line targets'+B.bc.ENDC
108 B.targets = btools.validate_targets(COMMAND_LINE_TARGETS, B.bc)
109 btools.print_targets(B.targets, B.bc)
111 ##########################
112 # setting up environment #
113 ##########################
115 # handling cmd line arguments & config file
118 tempbitness = int(B.arguments.get('BF_BITNESS', bitness)) # default to bitness found as per starting python
119 if tempbitness in (32, 64): # only set if 32 or 64 has been given
120 bitness = int(tempbitness)
125 B.bitness = tempbitness
128 # first check cmdline for toolset and we create env to work on
129 quickie = B.arguments.get('BF_QUICK', None)
130 quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
133 B.quickdebug=string.split(quickdebug, ',')
138 B.quickie=string.split(quickie,',')
142 toolset = B.arguments.get('BF_TOOLSET', None)
144 print "Using " + toolset
145 if toolset=='mstoolkit':
146 env = BlenderEnvironment(ENV = os.environ)
147 env.Tool('mstoolkit', [toolpath])
149 env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
151 btools.SetupSpawn(env)
153 if bitness==64 and platform=='win32':
154 env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
156 env = BlenderEnvironment(ENV = os.environ)
159 print "Could not create a build environment"
162 cc = B.arguments.get('CC', None)
163 cxx = B.arguments.get('CXX', None)
169 if sys.platform=='win32':
170 if env['CC'] in ['cl', 'cl.exe']:
171 platform = 'win64-vc' if bitness == 64 else 'win32-vc'
172 elif env['CC'] in ['gcc']:
173 platform = 'win64-mingw' if bitness == 64 else 'win32-mingw'
175 env.SConscriptChdir(0)
177 # Remove major kernel version from linux platform.
178 # After Linus switched kernel to new version model this major version
179 # shouldn't take much sense for building rules.
181 if re.match('linux[0-9]+', platform):
184 crossbuild = B.arguments.get('BF_CROSS', None)
185 if crossbuild and platform not in ('win32-vc', 'win64-vc'):
186 platform = 'linuxcross'
188 env['OURPLATFORM'] = platform
190 configfile = os.path.join("build_files", "scons", "config", platform + "-config.py")
192 if os.path.exists(configfile):
193 print B.bc.OKGREEN + "Using config file: " + B.bc.ENDC + configfile
195 print B.bc.FAIL + configfile + " doesn't exist" + B.bc.ENDC
197 if crossbuild and env['PLATFORM'] != 'win32':
198 print B.bc.HEADER+"Preparing for crossbuild"+B.bc.ENDC
199 env.Tool('crossmingw', [toolpath])
200 # todo: determine proper libs/includes etc.
201 # Needed for gui programs, console programs should do without it
203 # Now we don't need this option to have console window
204 # env.Append(LINKFLAGS=['-mwindows'])
206 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
207 # first read platform config. B.arguments will override
208 optfiles = [configfile]
209 if os.path.exists(userconfig):
210 print B.bc.OKGREEN + "Using user-config file: " + B.bc.ENDC + userconfig
211 optfiles += [userconfig]
213 print B.bc.WARNING + userconfig + " not found, no user overrides" + B.bc.ENDC
215 opts = btools.read_opts(env, optfiles, B.arguments)
218 if sys.platform=='win32':
220 env.Append(CPPFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally
222 if not env['BF_FANCY']:
226 # remove install dir so old and new files are not mixed.
227 # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
228 # TODO: perhaps we need an option (off by default) to not do this altogether...
229 if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
230 scriptsDir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts')
231 if os.path.isdir(scriptsDir):
232 print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
233 shutil.rmtree(scriptsDir)
236 SetOption('num_jobs', int(env['BF_NUMJOBS']))
237 print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
238 print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
240 if 'blenderlite' in B.targets:
242 target_env_defs['WITH_BF_GAMEENGINE'] = False
243 target_env_defs['WITH_BF_CYCLES'] = False
244 target_env_defs['WITH_BF_OPENAL'] = False
245 target_env_defs['WITH_BF_OPENEXR'] = False
246 target_env_defs['WITH_BF_OPENMP'] = False
247 target_env_defs['WITH_BF_ICONV'] = False
248 target_env_defs['WITH_BF_INTERNATIONAL'] = False
249 target_env_defs['WITH_BF_OPENJPEG'] = False
250 target_env_defs['WITH_BF_FFMPEG'] = False
251 target_env_defs['WITH_BF_QUICKTIME'] = False
252 target_env_defs['WITH_BF_REDCODE'] = False
253 target_env_defs['WITH_BF_DDS'] = False
254 target_env_defs['WITH_BF_CINEON'] = False
255 target_env_defs['WITH_BF_FRAMESERVER'] = False
256 target_env_defs['WITH_BF_HDR'] = False
257 target_env_defs['WITH_BF_ZLIB'] = False
258 target_env_defs['WITH_BF_SDL'] = False
259 target_env_defs['WITH_BF_JPEG'] = False
260 target_env_defs['WITH_BF_PNG'] = False
261 target_env_defs['WITH_BF_BULLET'] = False
262 target_env_defs['WITH_BF_BINRELOC'] = False
263 target_env_defs['BF_BUILDINFO'] = False
264 target_env_defs['WITH_BF_FLUID'] = False
265 target_env_defs['WITH_BF_OCEANSIM'] = False
266 target_env_defs['WITH_BF_SMOKE'] = False
267 target_env_defs['WITH_BF_BOOLEAN'] = False
268 target_env_defs['WITH_BF_REMESH'] = False
269 target_env_defs['WITH_BF_PYTHON'] = False
270 target_env_defs['WITH_BF_3DMOUSE'] = False
271 target_env_defs['WITH_BF_LIBMV'] = False
273 # Merge blenderlite, let command line to override
274 for k,v in target_env_defs.iteritems():
275 if k not in B.arguments:
278 # Extended OSX_SDK and 3D_CONNEXION_CLIENT_LIBRARY and JAckOSX detection for OSX
279 if env['OURPLATFORM']=='darwin':
280 print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
281 print "Available " + env['MACOSX_SDK_CHECK']
282 if not 'Mac OS X 10.6' in env['MACOSX_SDK_CHECK']:
283 print B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.7.sdk"
284 elif not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
285 print B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.6.sdk"
287 print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk"
289 # for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion
290 # necessary header file lives here when installed:
291 # /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h
292 if env['WITH_BF_3DMOUSE'] == 1:
293 if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'):
294 print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
295 env['WITH_BF_3DMOUSE'] = 0
297 env.Append(LINKFLAGS=['-Xlinker','-weak_framework','-Xlinker','3DconnexionClient'])
299 # for now, Mac builders must download and install the JackOSX framework
300 # necessary header file lives here when installed:
301 # /Library/Frameworks/Jackmp.framework/Versions/A/Headers/jack.h
302 if env['WITH_BF_JACK'] == 1:
303 if not os.path.exists('/Library/Frameworks/Jackmp.framework'):
304 print "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors !
305 env['WITH_BF_JACK'] = 0
307 env.Append(LINKFLAGS=['-Xlinker','-weak_framework','-Xlinker','Jackmp'])
309 if env['WITH_BF_CYCLES_OSL'] == 1:
310 OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
311 # we need 2 variants of passing the oslexec with the force_load option, string and list type atm
312 env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
313 env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a'])
315 # Trying to get rid of eventually clashes, we export some explicite as local symbols
316 env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map'])
318 if env['WITH_BF_OPENMP'] == 1:
319 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
320 env['CCFLAGS'].append('/openmp')
322 if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
323 env.Append(LINKFLAGS=['-openmp', '-static-intel'])
324 env['CCFLAGS'].append('-openmp')
326 env.Append(CCFLAGS=['-fopenmp'])
328 if env['WITH_GHOST_COCOA'] == True:
329 env.Append(CPPFLAGS=['-DGHOST_COCOA'])
331 if env['USE_QTKIT'] == True:
332 env.Append(CPPFLAGS=['-DUSE_QTKIT'])
334 #check for additional debug libnames
336 if env.has_key('BF_DEBUG_LIBS'):
337 B.quickdebug += env['BF_DEBUG_LIBS']
339 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
341 if len(B.quickdebug) > 0 and printdebug != 0:
342 print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
343 for l in B.quickdebug:
346 # remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
347 if env['WITH_BF_STATICCXX']:
348 if 'stdc++' in env['LLIBS']:
349 env['LLIBS'].remove('stdc++')
351 print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
353 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
354 if 'blenderplayer' in B.targets:
355 env['WITH_BF_PLAYER'] = True
357 if 'blendernogame' in B.targets:
358 env['WITH_BF_GAMEENGINE'] = False
360 # build without elbeem (fluidsim)?
361 if env['WITH_BF_FLUID'] == 1:
362 env['CPPFLAGS'].append('-DWITH_MOD_FLUID')
364 # build with ocean sim?
365 if env['WITH_BF_OCEANSIM'] == 1:
366 env['WITH_BF_FFTW3'] = 1 # ocean needs fftw3 so enable it
367 env['CPPFLAGS'].append('-DWITH_MOD_OCEANSIM')
370 if btools.ENDIAN == "big":
371 env['CPPFLAGS'].append('-D__BIG_ENDIAN__')
373 env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
375 # TODO, make optional
376 env['CPPFLAGS'].append('-DWITH_AUDASPACE')
377 env['CPPFLAGS'].append('-DWITH_AVI')
379 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
380 B.root_build_dir = env['BF_BUILDDIR']
381 B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
382 if not B.root_build_dir[-1]==os.sep:
383 B.root_build_dir += os.sep
384 if not B.doc_build_dir[-1]==os.sep:
385 B.doc_build_dir += os.sep
387 # We do a shortcut for clean when no quicklist is given: just delete
388 # builddir without reading in SConscripts
390 if 'clean' in B.targets:
393 if not quickie and do_clean:
394 if os.path.exists(B.doc_build_dir):
395 print B.bc.HEADER+'Cleaning doc dir...'+B.bc.ENDC
396 dirs = os.listdir(B.doc_build_dir)
398 if os.path.isdir(B.doc_build_dir + entry) == 1:
399 print "clean dir %s"%(B.doc_build_dir+entry)
400 shutil.rmtree(B.doc_build_dir+entry)
402 print "remove file %s"%(B.doc_build_dir+entry)
403 os.remove(B.root_build_dir+entry)
404 if os.path.exists(B.root_build_dir):
405 print B.bc.HEADER+'Cleaning build dir...'+B.bc.ENDC
406 dirs = os.listdir(B.root_build_dir)
408 if os.path.isdir(B.root_build_dir + entry) == 1:
409 print "clean dir %s"%(B.root_build_dir+entry)
410 shutil.rmtree(B.root_build_dir+entry)
412 print "remove file %s"%(B.root_build_dir+entry)
413 os.remove(B.root_build_dir+entry)
414 for confile in ['extern/ffmpeg/config.mak', 'extern/x264/config.mak',
415 'extern/xvidcore/build/generic/platform.inc', 'extern/ffmpeg/include']:
416 if os.path.exists(confile):
417 print "clean file %s"%confile
418 if os.path.isdir(confile):
419 for root, dirs, files in os.walk(confile):
421 os.remove(os.path.join(root, name))
424 print B.bc.OKGREEN+'...done'+B.bc.ENDC
426 print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
430 # ensure python header is found since detection can fail, this could happen
431 # with _any_ library but since we used a fixed python version this tends to
432 # be most problematic.
433 if env['WITH_BF_PYTHON']:
434 found_python_h = found_pyconfig_h = False
435 for bf_python_inc in env.subst('${BF_PYTHON_INC}').split():
436 py_h = os.path.join(Dir(bf_python_inc).abspath, "Python.h")
437 if os.path.exists(py_h):
438 found_python_h = True
439 py_h = os.path.join(Dir(bf_python_inc).abspath, "pyconfig.h")
440 if os.path.exists(py_h):
441 found_pyconfig_h = True
443 if not (found_python_h and found_pyconfig_h):
444 print("\nMissing: Python.h and/or pyconfig.h in\"" + env.subst('${BF_PYTHON_INC}') + "\",\n"
445 " Set 'BF_PYTHON_INC' to point "
446 "to valid python include path(s).\n Containing "
447 "Python.h and pyconfig.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"")
452 if not os.path.isdir ( B.root_build_dir):
453 os.makedirs ( B.root_build_dir )
454 os.makedirs ( B.root_build_dir + 'source' )
455 os.makedirs ( B.root_build_dir + 'intern' )
456 os.makedirs ( B.root_build_dir + 'extern' )
457 os.makedirs ( B.root_build_dir + 'lib' )
458 os.makedirs ( B.root_build_dir + 'bin' )
459 # # Docs not working with epy anymore
460 # if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
461 # os.makedirs ( B.doc_build_dir )
463 ###################################
464 # Ensure all data files are valid #
465 ###################################
466 if not os.path.isdir ( B.root_build_dir + 'data_headers'):
467 os.makedirs ( B.root_build_dir + 'data_headers' )
468 if not os.path.isdir ( B.root_build_dir + 'data_sources'):
469 os.makedirs ( B.root_build_dir + 'data_sources' )
471 env['DATA_HEADERS'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_headers")
472 env['DATA_SOURCES'] = os.path.join(os.path.abspath(env['BF_BUILDDIR']), "data_sources")
473 def data_to_c(FILE_FROM, FILE_TO, VAR_NAME):
475 FILE_FROM = FILE_FROM.replace("/", "\\")
476 FILE_TO = FILE_TO.replace("/", "\\")
478 # first check if we need to bother.
479 if os.path.exists(FILE_TO):
480 if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
483 print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
484 fpin = open(FILE_FROM, "rb")
485 fpin.seek(0, os.SEEK_END)
489 fpout = open(FILE_TO, "w")
490 fpout.write("int %s_size = %d;\n" % (VAR_NAME, size))
491 fpout.write("char %s[] = {\n" % VAR_NAME)
498 fpout.write("%3d," % ord(fpin.read(1)))
499 fpout.write("\n 0};\n\n")
504 def data_to_c_simple(FILE_FROM):
505 filename_only = os.path.basename(FILE_FROM)
506 FILE_TO = os.path.join(env['DATA_SOURCES'], filename_only + ".c")
507 VAR_NAME = "datatoc_" + filename_only.replace(".", "_")
509 data_to_c(FILE_FROM, FILE_TO, VAR_NAME)
512 data_to_c("source/blender/compositor/operations/COM_OpenCLKernels.cl",
513 B.root_build_dir + "data_headers/COM_OpenCLKernels.cl.h",
514 "datatoc_COM_OpenCLKernels_cl")
516 data_to_c_simple("release/datafiles/startup.blend")
517 data_to_c_simple("release/datafiles/preview.blend")
520 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
521 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vertex.glsl")
522 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl")
523 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl")
524 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_material.glsl")
525 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl")
526 data_to_c_simple("source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl")
529 data_to_c_simple("release/datafiles/bfont.pfb")
530 data_to_c_simple("release/datafiles/bfont.ttf")
531 data_to_c_simple("release/datafiles/bmonofont.ttf")
533 data_to_c_simple("release/datafiles/splash.png")
534 data_to_c_simple("release/datafiles/blender_icons.png")
535 data_to_c_simple("release/datafiles/prvicons.png")
537 data_to_c_simple("release/datafiles/brushicons/add.png")
538 data_to_c_simple("release/datafiles/brushicons/blob.png")
539 data_to_c_simple("release/datafiles/brushicons/blur.png")
540 data_to_c_simple("release/datafiles/brushicons/clay.png")
541 data_to_c_simple("release/datafiles/brushicons/claystrips.png")
542 data_to_c_simple("release/datafiles/brushicons/clone.png")
543 data_to_c_simple("release/datafiles/brushicons/crease.png")
544 data_to_c_simple("release/datafiles/brushicons/darken.png")
545 data_to_c_simple("release/datafiles/brushicons/draw.png")
546 data_to_c_simple("release/datafiles/brushicons/fill.png")
547 data_to_c_simple("release/datafiles/brushicons/flatten.png")
548 data_to_c_simple("release/datafiles/brushicons/grab.png")
549 data_to_c_simple("release/datafiles/brushicons/inflate.png")
550 data_to_c_simple("release/datafiles/brushicons/layer.png")
551 data_to_c_simple("release/datafiles/brushicons/lighten.png")
552 data_to_c_simple("release/datafiles/brushicons/mask.png")
553 data_to_c_simple("release/datafiles/brushicons/mix.png")
554 data_to_c_simple("release/datafiles/brushicons/multiply.png")
555 data_to_c_simple("release/datafiles/brushicons/nudge.png")
556 data_to_c_simple("release/datafiles/brushicons/pinch.png")
557 data_to_c_simple("release/datafiles/brushicons/scrape.png")
558 data_to_c_simple("release/datafiles/brushicons/smear.png")
559 data_to_c_simple("release/datafiles/brushicons/smooth.png")
560 data_to_c_simple("release/datafiles/brushicons/snake_hook.png")
561 data_to_c_simple("release/datafiles/brushicons/soften.png")
562 data_to_c_simple("release/datafiles/brushicons/subtract.png")
563 data_to_c_simple("release/datafiles/brushicons/texdraw.png")
564 data_to_c_simple("release/datafiles/brushicons/thumb.png")
565 data_to_c_simple("release/datafiles/brushicons/twist.png")
566 data_to_c_simple("release/datafiles/brushicons/vertexdraw.png")
568 ##### END DATAFILES ##########
570 Help(opts.GenerateHelpText(env))
572 # default is new quieter output, but if you need to see the
573 # commands, do 'scons BF_QUIET=0'
574 bf_quietoutput = B.arguments.get('BF_QUIET', '1')
576 B.set_quiet_output(env)
581 print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
582 env.SConsignFile(B.root_build_dir+'scons-signatures')
585 ##### END SETUP ##########
589 VariantDir(B.root_build_dir+'/source', 'source', duplicate=0)
590 SConscript(B.root_build_dir+'/source/SConscript')
591 VariantDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
592 SConscript(B.root_build_dir+'/intern/SConscript')
593 VariantDir(B.root_build_dir+'/extern', 'extern', duplicate=0)
594 SConscript(B.root_build_dir+'/extern/SConscript')
596 # now that we have read all SConscripts, we know what
597 # libraries will be built. Create list of
598 # libraries to give as objects to linking phase
600 for tp in B.possible_types:
601 if (not tp == 'player') and (not tp == 'player2'):
602 mainlist += B.create_blender_liblist(env, tp)
604 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
605 B.propose_priorities()
607 dobj = B.buildinfo(env, "dynamic") + B.resources
608 creob = B.creator(env)
609 thestatlibs, thelibincs = B.setup_staticlibs(env)
610 thesyslibs = B.setup_syslibs(env)
612 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
613 env.BlenderProg(B.root_build_dir, "blender", creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
614 if env['WITH_BF_PLAYER']:
615 playerlist = B.create_blender_liblist(env, 'player')
616 playerlist += B.create_blender_liblist(env, 'player2')
617 playerlist += B.create_blender_liblist(env, 'intern')
618 playerlist += B.create_blender_liblist(env, 'extern')
619 env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
621 ##### Now define some targets
624 #------------ INSTALL
628 if env['OURPLATFORM']=='darwin':
629 for prg in B.program_list:
630 bundle = '%s.app' % prg[0]
631 bundledir = os.path.dirname(bundle)
632 for dp, dn, df in os.walk(bundle):
637 dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
638 source=[dp+os.sep+f for f in df]
639 blenderinstall.append(env.Install(dir=dir,source=source))
641 blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
643 #-- local path = config files in install dir: installdir\VERSION
644 #- dont do config and scripts for darwin, it is already in the bundle
647 datafilestargetlist = []
651 if env['OURPLATFORM']!='darwin':
652 dotblenderinstall = []
653 for targetdir,srcfile in zip(dottargetlist, dotblendlist):
654 td, tf = os.path.split(targetdir)
655 dotblenderinstall.append(env.Install(dir=td, source=srcfile))
656 for targetdir,srcfile in zip(datafilestargetlist, datafileslist):
657 td, tf = os.path.split(targetdir)
658 dotblenderinstall.append(env.Install(dir=td, source=srcfile))
660 if env['WITH_BF_PYTHON']:
661 #-- local/VERSION/scripts
662 scriptpaths=['release/scripts']
663 for scriptpath in scriptpaths:
664 for dp, dn, df in os.walk(scriptpath):
669 if '__pycache__' in dn: # py3.2 cache dir
670 dn.remove('__pycache__')
672 # only for testing builds
673 if VERSION_RELEASE_CYCLE == "release" and "addons_contrib" in dn:
674 dn.remove('addons_contrib')
676 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
677 dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
679 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
680 # To ensure empty dirs are created too
681 if len(source)==0 and not os.path.exists(dir):
682 env.Execute(Mkdir(dir))
683 scriptinstall.append(env.Install(dir=dir,source=source))
684 if env['WITH_BF_CYCLES']:
686 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles')
687 source=os.listdir('intern/cycles/blender/addon')
688 if '.svn' in source: source.remove('.svn')
689 if '_svn' in source: source.remove('_svn')
690 if '__pycache__' in source: source.remove('__pycache__')
691 source=['intern/cycles/blender/addon/'+s for s in source]
692 scriptinstall.append(env.Install(dir=dir,source=source))
695 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
696 source=os.listdir('intern/cycles/kernel')
697 if '.svn' in source: source.remove('.svn')
698 if '_svn' in source: source.remove('_svn')
699 if '__pycache__' in source: source.remove('__pycache__')
700 source.remove('kernel.cpp')
701 source.remove('CMakeLists.txt')
703 source.remove('closure')
704 source.remove('shaders')
706 source=['intern/cycles/kernel/'+s for s in source]
707 source.append('intern/cycles/util/util_color.h')
708 source.append('intern/cycles/util/util_math.h')
709 source.append('intern/cycles/util/util_transform.h')
710 source.append('intern/cycles/util/util_types.h')
711 scriptinstall.append(env.Install(dir=dir,source=source))
713 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'svm')
714 source=os.listdir('intern/cycles/kernel/svm')
715 if '.svn' in source: source.remove('.svn')
716 if '_svn' in source: source.remove('_svn')
717 if '__pycache__' in source: source.remove('__pycache__')
718 source=['intern/cycles/kernel/svm/'+s for s in source]
719 scriptinstall.append(env.Install(dir=dir,source=source))
721 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'closure')
722 source=os.listdir('intern/cycles/kernel/closure')
723 if '.svn' in source: source.remove('.svn')
724 if '_svn' in source: source.remove('_svn')
725 if '__pycache__' in source: source.remove('__pycache__')
726 source=['intern/cycles/kernel/closure/'+s for s in source]
727 scriptinstall.append(env.Install(dir=dir,source=source))
730 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
731 source=os.listdir('intern/cycles/doc/license')
732 if '.svn' in source: source.remove('.svn')
733 if '_svn' in source: source.remove('_svn')
734 if '__pycache__' in source: source.remove('__pycache__')
735 source.remove('CMakeLists.txt')
736 source=['intern/cycles/doc/license/'+s for s in source]
737 scriptinstall.append(env.Install(dir=dir,source=source))
740 if env['WITH_BF_CYCLES_CUDA_BINARIES']:
741 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
742 for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
743 kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
744 cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
745 scriptinstall.append(env.Install(dir=dir,source=cubin_file))
748 if env['WITH_BF_CYCLES_OSL']:
749 dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader')
751 osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path
752 oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders')
754 headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split()
755 source=['intern/cycles/kernel/shaders/'+s for s in headers]
756 scriptinstall.append(env.Install(dir=dir,source=source))
758 for f in os.listdir(osl_source_dir):
759 if f.endswith('.osl'):
760 oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso'))
761 scriptinstall.append(env.Install(dir=dir,source=oso_file))
763 if env['WITH_BF_OCIO']:
764 colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
766 for dp, dn, df in os.walk(colormanagement):
772 dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
773 dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
775 source = [os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
777 # To ensure empty dirs are created too
779 env.Execute(Mkdir(dir))
781 scriptinstall.append(env.Install(dir=dir,source=source))
783 if env['WITH_BF_INTERNATIONAL']:
784 internationalpaths=['release' + os.sep + 'datafiles']
786 def check_path(path, member):
787 return (member in path.split(os.sep))
789 for intpath in internationalpaths:
790 for dp, dn, df in os.walk(intpath):
796 # we only care about release/datafiles/fonts, release/datafiles/locales
797 if check_path(dp, "fonts") or check_path(dp, "locale"):
802 dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
803 dir += os.sep + os.path.basename(intpath) + dp[len(intpath):]
805 source=[os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
806 # To ensure empty dirs are created too
808 env.Execute(Mkdir(dir))
809 scriptinstall.append(env.Install(dir=dir,source=source))
812 if env['OURPLATFORM']=='linux':
816 for tp, tn, tf in os.walk('release/freedesktop/icons'):
822 iconlist.append(os.path.join(tp, f))
823 icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
826 for targetdir,srcfile in zip(icontargetlist, iconlist):
827 td, tf = os.path.split(targetdir)
828 iconinstall.append(env.Install(dir=td, source=srcfile))
830 # dlls for linuxcross
831 # TODO - add more libs, for now this lets blenderlite run
832 if env['OURPLATFORM']=='linuxcross':
833 dir=env['BF_INSTALLDIR']
836 if env['WITH_BF_OPENMP']:
837 source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
839 scriptinstall.append(env.Install(dir=dir, source=source))
843 for tp, tn, tf in os.walk('release/text'):
849 textlist.append(tp+os.sep+f)
851 textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
853 if env['OURPLATFORM']=='darwin':
854 allinstall = [blenderinstall, textinstall]
855 elif env['OURPLATFORM']=='linux':
856 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, iconinstall]
858 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall]
860 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
863 dllsources += ['${BF_ZLIB_LIBPATH}/zlib.dll']
864 # Used when linking to libtiff was dynamic
865 # keep it here until compilation on all platform would be ok
866 # dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
868 if env['OURPLATFORM'] != 'linuxcross':
869 # pthreads library is already added
870 dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
872 if env['WITH_BF_SDL']:
873 if env['OURPLATFORM'] == 'win64-vc':
874 pass # we link statically already to SDL on win64
876 dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
878 if env['WITH_BF_PYTHON']:
880 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
882 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
884 if env['WITH_BF_ICONV']:
885 if env['OURPLATFORM'] == 'win64-vc':
886 pass # we link statically to iconv on win64
887 elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
888 #gettext for MinGW and cross-compilation is compiled staticly
889 dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
891 if env['WITH_BF_OPENAL']:
892 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
893 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
895 if env['WITH_BF_SNDFILE']:
896 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
898 if env['WITH_BF_FFMPEG']:
899 dllsources += env['BF_FFMPEG_DLL'].split()
901 # Since the thumb handler is loaded by Explorer, architecture is
902 # strict: the x86 build fails on x64 Windows. We need to ship
903 # both builds in x86 packages.
905 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
906 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
908 if env['WITH_BF_OCIO']:
909 if not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
910 dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
913 dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
915 dllsources.append('#source/icons/blender.exe.manifest')
917 windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
918 allinstall += windlls
920 if env['OURPLATFORM'] == 'win64-mingw':
923 if env['WITH_BF_PYTHON']:
925 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
927 dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
929 if env['WITH_BF_FFMPEG']:
930 dllsources += env['BF_FFMPEG_DLL'].split()
932 if env['WITH_BF_OPENAL']:
933 dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
934 dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
936 if env['WITH_BF_SNDFILE']:
937 dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
939 if env['WITH_BF_SDL']:
940 dllsources.append('${LCGDIR}/sdl/lib/SDL.dll')
942 if(env['WITH_BF_OPENMP']):
943 dllsources.append('${LCGDIR}/binaries/libgomp-1.dll')
945 if env['WITH_BF_OCIO']:
946 dllsources.append('${LCGDIR}/opencolorio/bin/libOpenColorIO.dll')
948 dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
949 dllsources.append('${LCGDIR}/binaries/libgcc_s_sjlj-1.dll')
950 dllsources.append('${LCGDIR}/binaries/libwinpthread-1.dll')
951 dllsources.append('${LCGDIR}/binaries/libstdc++-6.dll')
952 dllsources.append('#source/icons/blender.exe.manifest')
954 windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
955 allinstall += windlls
957 installtarget = env.Alias('install', allinstall)
958 bininstalltarget = env.Alias('install-bin', blenderinstall)
960 nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
961 nsiscmd = env.Command('nsisinstaller', None, nsisaction)
962 nsisalias = env.Alias('nsis', nsiscmd)
964 if 'blender' in B.targets:
965 blenderexe= env.Alias('blender', B.program_list)
966 Depends(blenderexe,installtarget)
968 if env['WITH_BF_PLAYER']:
969 blenderplayer = env.Alias('blenderplayer', B.program_list)
970 Depends(blenderplayer,installtarget)
972 if not env['WITH_BF_GAMEENGINE']:
973 blendernogame = env.Alias('blendernogame', B.program_list)
974 Depends(blendernogame,installtarget)
976 if 'blenderlite' in B.targets:
977 blenderlite = env.Alias('blenderlite', B.program_list)
978 Depends(blenderlite,installtarget)
980 Depends(nsiscmd, allinstall)
982 buildslave_action = env.Action(btools.buildslave, btools.buildslave_print)
983 buildslave_cmd = env.Command('buildslave_exec', None, buildslave_action)
984 buildslave_alias = env.Alias('buildslave', buildslave_cmd)
986 Depends(buildslave_cmd, allinstall)
988 Default(B.program_list)
990 if not env['WITHOUT_BF_INSTALL']:
991 Default(installtarget)