* add Brecht's small patch to make values to BF_QUICK and BF_QUICKDEBUG function as partial search entries.

- this means you can do BF_QUICK=bf_ and it would build all libs that contain bf_ in their name. This makes
    it easier to use, since you don't have to remember the exact names

* Update documentation to mention scons-local.
This commit is contained in:
Nathan Letwory 2008-11-09 21:00:49 +00:00
parent d5ae032a60
commit 0a8e8c8c9e
2 changed files with 413 additions and 408 deletions

View File

@ -26,8 +26,9 @@ $Id$
----------------
To build Blender with the SCons scripts you need a full Python
install, version 2.4 or later (http://www.python.org) and a SCons
installation, version v1.1.0 (http://www.scons.org).
install, version 2.4 or later (http://www.python.org). We already provide
a scons-local installation, which can be found in the scons/ subdirectory.
This document uses the scons-local installation for its examples.
Check from the page
http://www.blender.org/development/building-blender/getting-dependencies/
@ -38,9 +39,14 @@ $Id$
In the base directory of the sources (from now on called $BLENDERHOME)
you'll see a file named SConstruct. This is the entry point for the
SCons build system. In a terminal, change to this directory. To just
build, issue the command 'scons':
build, start the SCons entry script on Windows (will be used for the remainder
of this document):
% scons
% python scons\scons.py
On a Unix-compatible system it would be
% python ./scons/scons.py
This will start the build process with default values. Depending
on your platform you may see colour in your output (non-Windows
@ -49,8 +55,9 @@ $Id$
build are configured.
The build uses BF_BUILDDIR to build into and BF_INSTALLDIR to
finally copy all needed files to get a proper setup. These
variabbles have default values for every platform in
finally copy all needed files to get a proper setup. The BF_DOCDIR is
used to generate Blender Python documentation files to. These
variables have default values for every platform in
$BLENDERHOME/config/(platform)-config.py. After the build successfully
completes, you can find everything you need in BF_INSTALLDIR.
@ -59,7 +66,7 @@ $Id$
As an extra dependency, you need the MoreInfo plugin too. The creation of
the installer is tied into the build process and can be triggered with:
% scons nsis
% python scons\scons.py nsis
Configuring the build
@ -76,20 +83,21 @@ $Id$
(TBD: add cygwin, solaris and freebsd support)
These files you will normally not change. If you need to override
a default value, make a copy of the proper configuration to
$BLENDERHOME/user-config.py. This file you can modify to your
likings. Any value set here will override the ones from the
(platform)-config.py.
a default value, make a file called $BLENDERHOME/user-config.py, and copy
settings from the config/(platform)-config.py that you want to change. Don't
copy the entire file (unless explicitely stated in the configuration file),
because you may not get updated options you don't change yourself, which may
result in build errors.
You can use BF_CONFIG argument to override the default user-config.py
check. This is just like the user-config.py, but just with another name:
% scons BF_CONFIG=myownsettings
% python scons\scons.py BF_CONFIG=myownsettings
If you want to quickly test a new setting, you can give the option
also on the command-line:
% scons BF_BUILDDIR=../mybuilddir WITH_BF_OPENEXR=0
% python scons\scons.py BF_BUILDDIR=../mybuilddir WITH_BF_OPENEXR=0
This command sets the build directory to BF_BUILDDIR and disables
OpenEXR support.
@ -97,7 +105,7 @@ $Id$
If you need to know what can be set through the command-line, run
scons with -h:
% scons -h
% python scons\scons.py -h
This command will print a long list with settable options and what
every option means. Many of the default values will be empty, and
@ -118,11 +126,11 @@ $Id$
you need to see the full command-line for compiles, then you can
change that behaviour. Also the use of colours can be changed:
% scons BF_FANCY=0
% python scons\scons.py BF_FANCY=0
This will disable the use of colours.
% scons BF_QUIET=0
% python scons\scons.py BF_QUIET=0
This will give the old, noisy output. Every command-line per
compile is printed out in its full glory. This is very useful when
@ -133,11 +141,11 @@ $Id$
Compiling Only Some Libraries
-----------------------------
Scons now has support for specifying a list of libraries that are
Our implementation now has support for specifying a list of libraries that are
exclusively compiled, ignoring all other libraries. This is invoked
with the BF_QUICK arguments; for example:
% scons BF_QUICK=src,bf_blenkernel
% python scons\scons.py BF_QUICK=src,bf_blenkernel
Note that this not the same as passing a list of folders as in the
makefile's "quicky" command. In Scons, all of Blender's code modules
@ -157,7 +165,7 @@ $Id$
BF_QUICKDEBUG is similar to BF_QUICK:
% scons BF_QUICKDEBUG=src,bf_blenkernel,some-other-lib
% python scons\scons.py BF_QUICKDEBUG=src,bf_blenkernel,some-other-lib
To use BF_DEBUG_LIBS, put something like the following in you user-config.py:
@ -184,14 +192,8 @@ $Id$
On Windows with all of the three toolset installed you need to
specify what toolset to use
% scons BF_TOOLSET=msvc
% scons BF_TOOLSET=mingw
If you have only the toolkit installed, you will also need to give
BF_TOOLSET=mstoolkit on the command-line, to make sure everything is
setup properly. Currently there is no good mechanism to automatically
determine wether the found 'cl.exe' is from the toolkit or from a
complete install.
% python scons\scons.py BF_TOOLSET=msvc
% python scons\scons.py BF_TOOLSET=mingw
LINUX and OS X
@ -204,30 +206,26 @@ $Id$
Build Blender with the defaults:
% scons
% python scons\scons.py
Build Blender, but disable OpenEXR support:
% scons WITH_BF_OPENEXR=0
% python scons\scons.py WITH_BF_OPENEXR=0
Build Blender, enable debug symbols:
% scons BF_DEBUG=1
% python scons\scons.py BF_DEBUG=1
Build Blender, install to different directory:
% scons BF_INSTALLDIR=/tmp/testbuild
% python scons\scons.py BF_INSTALLDIR=../myown/installdir
Build Blender in /tmp/obj and install to /usr/local:
Build Blender in ../myown/builddir and install to ../myown/installdir:
% scons BF_BUILDDIR=/tmp/obj BF_INSTALLDIR=/usr/local
% python scons\scons.py BF_BUILDDIR=../myown/builddir BF_INSTALLDIR=../myown/installdir
Clean BF_BUILDDIR:
% scons clean
Clean out the installed files:
% scons -c
% python scons\scons.py clean
/Nathan Letwory (jesterKing)

View File

@ -52,443 +52,450 @@ possible_types = ['core'] # can be set in ie. SConstruct
libs = {}
def getresources():
return resources
return resources
def init_lib_dict():
for pt in possible_types:
libs[pt] = {}
for pt in possible_types:
libs[pt] = {}
# helper func for add_lib_to_dict
def internal_lib_to_dict(dict = None, libtype = None, libname = None, priority = 100):
if not libname in dict[libtype]:
done = None
while not done:
if dict[libtype].has_key(priority):
priority = priority + 1
else:
done = True
dict[libtype][priority] = libname
if not libname in dict[libtype]:
done = None
while not done:
if dict[libtype].has_key(priority):
priority = priority + 1
else:
done = True
dict[libtype][priority] = libname
# libtype and priority can both be lists, for defining lib in multiple places
def add_lib_to_dict(env, dict = None, libtype = None, libname = None, priority = 100):
if not dict or not libtype or not libname:
print "Passed wrong arg"
env.Exit()
if not dict or not libtype or not libname:
print "Passed wrong arg"
env.Exit()
if type(libtype) is str and type(priority) is int:
internal_lib_to_dict(dict, libtype, libname, priority)
elif type(libtype) is list and type(priority) is list:
if len(libtype)==len(priority):
for lt, p in zip(libtype, priority):
internal_lib_to_dict(dict, lt, libname, p)
else:
print "libtype and priority lists are unequal in length"
env.Exit()
else:
print "Wrong type combinations for libtype and priority. Only str and int or list and list"
env.Exit()
if type(libtype) is str and type(priority) is int:
internal_lib_to_dict(dict, libtype, libname, priority)
elif type(libtype) is list and type(priority) is list:
if len(libtype)==len(priority):
for lt, p in zip(libtype, priority):
internal_lib_to_dict(dict, lt, libname, p)
else:
print "libtype and priority lists are unequal in length"
env.Exit()
else:
print "Wrong type combinations for libtype and priority. Only str and int or list and list"
env.Exit()
def create_blender_liblist(lenv = None, libtype = None):
if not lenv or not libtype:
print "missing arg"
if not lenv or not libtype:
print "missing arg"
lst = []
if libtype in possible_types:
curlib = libs[libtype]
sortlist = curlib.keys()
sortlist.sort()
for sk in sortlist:
v = curlib[sk]
lst.append('#' + root_build_dir + 'lib/'+lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX'])
lst = []
if libtype in possible_types:
curlib = libs[libtype]
sortlist = curlib.keys()
sortlist.sort()
for sk in sortlist:
v = curlib[sk]
lst.append('#' + root_build_dir + 'lib/'+lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX'])
return lst
return lst
## TODO: static linking
def setup_staticlibs(lenv):
statlibs = [
#here libs for static linking
]
libincs = [
'/usr/lib',
lenv['BF_OPENGL_LIBPATH'],
lenv['BF_JPEG_LIBPATH'],
lenv['BF_PNG_LIBPATH'],
lenv['BF_ZLIB_LIBPATH'],
lenv['BF_ICONV_LIBPATH']
]
statlibs = [
#here libs for static linking
]
libincs = [
'/usr/lib',
lenv['BF_OPENGL_LIBPATH'],
lenv['BF_JPEG_LIBPATH'],
lenv['BF_PNG_LIBPATH'],
lenv['BF_ZLIB_LIBPATH'],
lenv['BF_ICONV_LIBPATH']
]
if lenv['WITH_BF_PYTHON']:
libincs += Split(lenv['BF_PYTHON_LIBPATH'])
if lenv['WITH_BF_SDL']:
libincs += Split(lenv['BF_SDL_LIBPATH'])
if lenv['WITH_BF_FFMPEG']:
libincs += Split(lenv['BF_FFMPEG_LIBPATH'])
if lenv['WITH_BF_STATICCXX']:
statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
if lenv['WITH_BF_OPENEXR']:
libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
if lenv['WITH_BF_STATICOPENEXR']:
statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC'])
if lenv['WITH_BF_INTERNATIONAL']:
libincs += Split(lenv['BF_GETTEXT_LIBPATH'])
libincs += Split(lenv['BF_FREETYPE_LIBPATH'])
if lenv['WITH_BF_OPENAL']:
libincs += Split(lenv['BF_OPENAL_LIBPATH'])
if lenv['WITH_BF_STATICOPENAL']:
statlibs += Split(lenv['BF_OPENAL_LIB_STATIC'])
if lenv['WITH_BF_STATICOPENGL']:
statlibs += Split(lenv['BF_OPENGL_LIB_STATIC'])
if lenv['WITH_BF_PYTHON']:
libincs += Split(lenv['BF_PYTHON_LIBPATH'])
if lenv['WITH_BF_SDL']:
libincs += Split(lenv['BF_SDL_LIBPATH'])
if lenv['WITH_BF_FFMPEG']:
libincs += Split(lenv['BF_FFMPEG_LIBPATH'])
if lenv['WITH_BF_STATICCXX']:
statlibs += Split(lenv['BF_CXX_LIB_STATIC'])
if lenv['WITH_BF_OPENEXR']:
libincs += Split(lenv['BF_OPENEXR_LIBPATH'])
if lenv['WITH_BF_STATICOPENEXR']:
statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC'])
if lenv['WITH_BF_INTERNATIONAL']:
libincs += Split(lenv['BF_GETTEXT_LIBPATH'])
libincs += Split(lenv['BF_FREETYPE_LIBPATH'])
if lenv['WITH_BF_OPENAL']:
libincs += Split(lenv['BF_OPENAL_LIBPATH'])
if lenv['WITH_BF_STATICOPENAL']:
statlibs += Split(lenv['BF_OPENAL_LIB_STATIC'])
if lenv['WITH_BF_STATICOPENGL']:
statlibs += Split(lenv['BF_OPENGL_LIB_STATIC'])
if lenv['WITH_BF_PYTHON'] and lenv['WITH_BF_STATICPYTHON']:
statlibs += Split(lenv['BF_PYTHON_LIB_STATIC'])
if lenv['WITH_BF_PYTHON'] and lenv['WITH_BF_STATICPYTHON']:
statlibs += Split(lenv['BF_PYTHON_LIB_STATIC'])
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'):
libincs += Split(lenv['BF_PTHREADS_LIBPATH'])
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'):
libincs += Split(lenv['BF_PTHREADS_LIBPATH'])
return statlibs, libincs
return statlibs, libincs
def setup_syslibs(lenv):
syslibs = [
lenv['BF_JPEG_LIB'],
lenv['BF_PNG_LIB'],
lenv['BF_ZLIB_LIB']
]
syslibs = [
lenv['BF_JPEG_LIB'],
lenv['BF_PNG_LIB'],
lenv['BF_ZLIB_LIB']
]
if lenv['WITH_BF_PYTHON'] and not lenv['WITH_BF_STATICPYTHON']:
if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc'):
syslibs.append(lenv['BF_PYTHON_LIB']+'_d')
else:
syslibs.append(lenv['BF_PYTHON_LIB'])
if lenv['WITH_BF_INTERNATIONAL']:
syslibs += Split(lenv['BF_FREETYPE_LIB'])
syslibs += Split(lenv['BF_GETTEXT_LIB'])
if lenv['WITH_BF_OPENAL']:
if not lenv['WITH_BF_STATICOPENAL']:
syslibs += Split(lenv['BF_OPENAL_LIB'])
if lenv['WITH_BF_OPENMP'] and lenv['CC'] != 'icc':
if lenv['CC'] == 'cl.exe':
syslibs += ['vcomp']
else:
syslibs += ['gomp']
if lenv['WITH_BF_ICONV']:
syslibs += Split(lenv['BF_ICONV_LIB'])
if lenv['WITH_BF_OPENEXR']:
if not lenv['WITH_BF_STATICOPENEXR']:
syslibs += Split(lenv['BF_OPENEXR_LIB'])
if lenv['WITH_BF_FFMPEG']:
syslibs += Split(lenv['BF_FFMPEG_LIB'])
if lenv['WITH_BF_OGG']:
syslibs += Split(lenv['BF_OGG_LIB'])
if lenv['WITH_BF_SDL']:
syslibs += Split(lenv['BF_SDL_LIB'])
if not lenv['WITH_BF_STATICOPENGL']:
syslibs += Split(lenv['BF_OPENGL_LIB'])
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross'):
syslibs += Split(lenv['BF_PTHREADS_LIB'])
if lenv['WITH_BF_PYTHON'] and not lenv['WITH_BF_STATICPYTHON']:
if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc'):
syslibs.append(lenv['BF_PYTHON_LIB']+'_d')
else:
syslibs.append(lenv['BF_PYTHON_LIB'])
if lenv['WITH_BF_INTERNATIONAL']:
syslibs += Split(lenv['BF_FREETYPE_LIB'])
syslibs += Split(lenv['BF_GETTEXT_LIB'])
if lenv['WITH_BF_OPENAL']:
if not lenv['WITH_BF_STATICOPENAL']:
syslibs += Split(lenv['BF_OPENAL_LIB'])
if lenv['WITH_BF_OPENMP'] and lenv['CC'] != 'icc':
if lenv['CC'] == 'cl.exe':
syslibs += ['vcomp']
else:
syslibs += ['gomp']
if lenv['WITH_BF_ICONV']:
syslibs += Split(lenv['BF_ICONV_LIB'])
if lenv['WITH_BF_OPENEXR']:
if not lenv['WITH_BF_STATICOPENEXR']:
syslibs += Split(lenv['BF_OPENEXR_LIB'])
if lenv['WITH_BF_FFMPEG']:
syslibs += Split(lenv['BF_FFMPEG_LIB'])
if lenv['WITH_BF_OGG']:
syslibs += Split(lenv['BF_OGG_LIB'])
if lenv['WITH_BF_SDL']:
syslibs += Split(lenv['BF_SDL_LIB'])
if not lenv['WITH_BF_STATICOPENGL']:
syslibs += Split(lenv['BF_OPENGL_LIB'])
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross'):
syslibs += Split(lenv['BF_PTHREADS_LIB'])
syslibs += Split(lenv['LLIBS'])
syslibs += Split(lenv['LLIBS'])
return syslibs
return syslibs
def propose_priorities():
print bc.OKBLUE+"Priorities:"+bc.ENDC
for t in possible_types:
print bc.OKGREEN+"\t"+t+bc.ENDC
new_priority = 0
curlib = libs[t]
sortlist = curlib.keys()
sortlist.sort()
print bc.OKBLUE+"Priorities:"+bc.ENDC
for t in possible_types:
print bc.OKGREEN+"\t"+t+bc.ENDC
new_priority = 0
curlib = libs[t]
sortlist = curlib.keys()
sortlist.sort()
for sk in sortlist:
v = curlib[sk]
#for p,v in sorted(libs[t].iteritems()):
print "\t\t",new_priority, v
new_priority += 5
for sk in sortlist:
v = curlib[sk]
#for p,v in sorted(libs[t].iteritems()):
print "\t\t",new_priority, v
new_priority += 5
## TODO: see if this can be made in an emitter
def buildinfo(lenv, build_type):
"""
Generate a buildinfo object
"""
build_date = time.strftime ("%Y-%m-%d")
build_time = time.strftime ("%H:%M:%S")
build_rev = os.popen('svnversion').read()[:-1] # remove \n
"""
Generate a buildinfo object
"""
build_date = time.strftime ("%Y-%m-%d")
build_time = time.strftime ("%H:%M:%S")
build_rev = os.popen('svnversion').read()[:-1] # remove \n
obj = []
if lenv['BF_BUILDINFO']:
if sys.platform=='win32':
build_info_file = open("source/creator/winbuildinfo.h", 'w')
build_info_file.write("char *build_date=\"%s\";\n"%build_date)
build_info_file.write("char *build_time=\"%s\";\n"%build_time)
build_info_file.write("char *build_rev=\"%s\";\n"%build_rev)
build_info_file.write("char *build_platform=\"win32\";\n")
build_info_file.write("char *build_type=\"dynamic\";\n")
build_info_file.close()
lenv.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
else:
lenv.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
'BUILD_DATE=\'"%s"\''%(build_date),
'BUILD_TYPE=\'"dynamic"\'',
'BUILD_REV=\'"%s"\''%(build_rev),
'NAN_BUILDINFO',
'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
obj = [lenv.Object (root_build_dir+'source/creator/%s_buildinfo'%build_type,
[root_build_dir+'source/creator/buildinfo.c'])]
return obj
obj = []
if lenv['BF_BUILDINFO']:
if sys.platform=='win32':
build_info_file = open("source/creator/winbuildinfo.h", 'w')
build_info_file.write("char *build_date=\"%s\";\n"%build_date)
build_info_file.write("char *build_time=\"%s\";\n"%build_time)
build_info_file.write("char *build_rev=\"%s\";\n"%build_rev)
build_info_file.write("char *build_platform=\"win32\";\n")
build_info_file.write("char *build_type=\"dynamic\";\n")
build_info_file.close()
lenv.Append (CPPDEFINES = ['NAN_BUILDINFO', 'BUILD_DATE'])
else:
lenv.Append (CPPDEFINES = ['BUILD_TIME=\'"%s"\''%(build_time),
'BUILD_DATE=\'"%s"\''%(build_date),
'BUILD_TYPE=\'"dynamic"\'',
'BUILD_REV=\'"%s"\''%(build_rev),
'NAN_BUILDINFO',
'BUILD_PLATFORM=\'"%s"\''%(sys.platform)])
obj = [lenv.Object (root_build_dir+'source/creator/%s_buildinfo'%build_type,
[root_build_dir+'source/creator/buildinfo.c'])]
return obj
##### END LIB STUFF ############
##### ACTION STUFF #############
def my_compile_print(target, source, env):
a = '%s' % (source[0])
d, f = os.path.split(a)
return bc.OKBLUE+"Compiling"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
a = '%s' % (source[0])
d, f = os.path.split(a)
return bc.OKBLUE+"Compiling"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
def my_moc_print(target, source, env):
a = '%s' % (source[0])
d, f = os.path.split(a)
return bc.OKBLUE+"Creating MOC"+bc.ENDC+ " ==> '"+bc.OKGREEN+"%s" %(f) + "'"+bc.ENDC
a = '%s' % (source[0])
d, f = os.path.split(a)
return bc.OKBLUE+"Creating MOC"+bc.ENDC+ " ==> '"+bc.OKGREEN+"%s" %(f) + "'"+bc.ENDC
def my_linking_print(target, source, env):
t = '%s' % (target[0])
d, f = os.path.split(t)
return bc.OKBLUE+"Linking library"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
t = '%s' % (target[0])
d, f = os.path.split(t)
return bc.OKBLUE+"Linking library"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
def my_program_print(target, source, env):
t = '%s' % (target[0])
d, f = os.path.split(t)
return bc.OKBLUE+"Linking program"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
t = '%s' % (target[0])
d, f = os.path.split(t)
return bc.OKBLUE+"Linking program"+bc.ENDC +" ==> '"+bc.OKGREEN+"%s" % (f) + "'"+bc.ENDC
def msvc_hack(env):
static_lib = SCons.Tool.createStaticLibBuilder(env)
program = SCons.Tool.createProgBuilder(env)
env['BUILDERS']['Library'] = static_lib
env['BUILDERS']['StaticLibrary'] = static_lib
env['BUILDERS']['Program'] = program
static_lib = SCons.Tool.createStaticLibBuilder(env)
program = SCons.Tool.createProgBuilder(env)
env['BUILDERS']['Library'] = static_lib
env['BUILDERS']['StaticLibrary'] = static_lib
env['BUILDERS']['Program'] = program
def set_quiet_output(env):
mycaction = Action("$CCCOM", strfunction=my_compile_print)
myshcaction = Action("$SHCCCOM", strfunction=my_compile_print)
mycppaction = Action("$CXXCOM", strfunction=my_compile_print)
myshcppaction = Action("$SHCXXCOM", strfunction=my_compile_print)
mylibaction = Action("$ARCOM", strfunction=my_linking_print)
mylinkaction = Action("$LINKCOM", strfunction=my_program_print)
mycaction = Action("$CCCOM", strfunction=my_compile_print)
myshcaction = Action("$SHCCCOM", strfunction=my_compile_print)
mycppaction = Action("$CXXCOM", strfunction=my_compile_print)
myshcppaction = Action("$SHCXXCOM", strfunction=my_compile_print)
mylibaction = Action("$ARCOM", strfunction=my_linking_print)
mylinkaction = Action("$LINKCOM", strfunction=my_program_print)
static_ob, shared_ob = SCons.Tool.createObjBuilders(env)
static_ob.add_action('.c', mycaction)
static_ob.add_action('.cpp', mycppaction)
shared_ob.add_action('.c', myshcaction)
shared_ob.add_action('.cpp', myshcppaction)
static_ob, shared_ob = SCons.Tool.createObjBuilders(env)
static_ob.add_action('.c', mycaction)
static_ob.add_action('.cpp', mycppaction)
shared_ob.add_action('.c', myshcaction)
shared_ob.add_action('.cpp', myshcppaction)
static_lib = SCons.Builder.Builder(action = mylibaction,
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '$LIBSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'StaticObject')
static_lib = SCons.Builder.Builder(action = mylibaction,
emitter = '$LIBEMITTER',
prefix = '$LIBPREFIX',
suffix = '$LIBSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'StaticObject')
program = SCons.Builder.Builder(action = mylinkaction,
emitter = '$PROGEMITTER',
prefix = '$PROGPREFIX',
suffix = '$PROGSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'Object',
target_scanner = SCons.Defaults.ProgScan)
program = SCons.Builder.Builder(action = mylinkaction,
emitter = '$PROGEMITTER',
prefix = '$PROGPREFIX',
suffix = '$PROGSUFFIX',
src_suffix = '$OBJSUFFIX',
src_builder = 'Object',
target_scanner = SCons.Defaults.ProgScan)
env['BUILDERS']['Object'] = static_ob
env['BUILDERS']['StaticObject'] = static_ob
env['BUILDERS']['StaticLibrary'] = static_lib
env['BUILDERS']['Library'] = static_lib
env['BUILDERS']['Program'] = program
env['BUILDERS']['Object'] = static_ob
env['BUILDERS']['StaticObject'] = static_ob
env['BUILDERS']['StaticLibrary'] = static_lib
env['BUILDERS']['Library'] = static_lib
env['BUILDERS']['Program'] = program
def my_appit_print(target, source, env):
a = '%s' % (target[0])
d, f = os.path.split(a)
return "making bundle for " + f
a = '%s' % (target[0])
d, f = os.path.split(a)
return "making bundle for " + f
def AppIt(target=None, source=None, env=None):
import shutil
import commands
import os.path
a = '%s' % (target[0])
builddir, b = os.path.split(a)
import shutil
import commands
import os.path
a = '%s' % (target[0])
builddir, b = os.path.split(a)
bldroot = env.Dir('.').abspath
binary = env['BINARYKIND']
if b=='verse':
print bc.OKBLUE+"no bundle for verse"+bc.ENDC
return 0
bldroot = env.Dir('.').abspath
binary = env['BINARYKIND']
if b=='verse':
print bc.OKBLUE+"no bundle for verse"+bc.ENDC
return 0
sourcedir = bldroot + '/source/darwin/%s.app'%binary
sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary
cmd = builddir + '/' +'%s.app'%binary
if os.path.isdir(cmd):
shutil.rmtree(cmd)
shutil.copytree(sourcedir, cmd)
cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
commands.getoutput(cmd)
cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary)
commands.getoutput(cmd)
cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary)
print cmd
commands.getoutput(cmd)
cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary
shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd)
shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd)
cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp %s/bin/.blender/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary)
commands.getoutput(cmd)
cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(builddir, binary)
commands.getoutput(cmd)
cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
commands.getoutput(cmd)
sourcedir = bldroot + '/source/darwin/%s.app'%binary
sourceinfo = bldroot + "/source/darwin/%s.app/Contents/Info.plist"%binary
targetinfo = builddir +'/' + "%s.app/Contents/Info.plist"%binary
cmd = builddir + '/' +'%s.app'%binary
if os.path.isdir(cmd):
shutil.rmtree(cmd)
shutil.copytree(sourcedir, cmd)
cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo)
commands.getoutput(cmd)
cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,builddir, binary, binary)
commands.getoutput(cmd)
cmd = 'mkdir %s/%s.app/Contents/MacOS/.blender/'%(builddir, binary)
print cmd
commands.getoutput(cmd)
cmd = builddir + '/%s.app/Contents/MacOS/.blender'%binary
shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd)
shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd)
cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp -R %s/bin/.blender/locale %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp %s/bin/.blender/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/.blender/'%(bldroot,builddir,binary)
commands.getoutput(cmd)
cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(builddir,binary, binary)
commands.getoutput(cmd)
cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(builddir, binary)
commands.getoutput(cmd)
cmd = 'find %s/%s.app -name .DS_Store -exec rm -rf {} \;'%(builddir, binary)
commands.getoutput(cmd)
#### END ACTION STUFF #########
def bsc(env, target, source):
bd = os.path.dirname(target[0].abspath)
bscfile = '\"'+target[0].abspath+'\"'
bscpathcollect = '\"'+bd + os.sep + '*.sbr\"'
bscpathtmp = '\"'+bd + os.sep + 'bscmake.tmp\"'
bd = os.path.dirname(target[0].abspath)
bscfile = '\"'+target[0].abspath+'\"'
bscpathcollect = '\"'+bd + os.sep + '*.sbr\"'
bscpathtmp = '\"'+bd + os.sep + 'bscmake.tmp\"'
os.system('dir /b/s '+bscpathcollect+' >'+bscpathtmp)
os.system('dir /b/s '+bscpathcollect+' >'+bscpathtmp)
myfile = open(bscpathtmp[1:-1], 'r')
lines = myfile.readlines()
myfile.close()
myfile = open(bscpathtmp[1:-1], 'r')
lines = myfile.readlines()
myfile.close()
newfile = open(bscpathtmp[1:-1], 'w')
for l in lines:
newfile.write('\"'+l[:-1]+'\"\n')
newfile.close()
os.system('bscmake /nologo /n /o'+bscfile+' @'+bscpathtmp)
os.system('del '+bscpathtmp)
newfile = open(bscpathtmp[1:-1], 'w')
for l in lines:
newfile.write('\"'+l[:-1]+'\"\n')
newfile.close()
os.system('bscmake /nologo /n /o'+bscfile+' @'+bscpathtmp)
os.system('del '+bscpathtmp)
class BlenderEnvironment(SConsEnvironment):
def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]):
global libs
if not self or not libname or not source:
print bc.FAIL+'Cannot continue. Missing argument for BlenderRes '+libname+bc.ENDC
self.Exit()
if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross'):
print bc.FAIL+'BlenderRes is for windows only!'+bc.END
self.Exit()
print bc.HEADER+'Configuring resource '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC
lenv = self.Clone()
res = lenv.RES('#'+root_build_dir+'lib/'+libname, source)
SConsEnvironment.Default(self, res)
resources.append(res)
def BlenderRes(self=None, libname=None, source=None, libtype=['core'], priority=[100]):
global libs
if not self or not libname or not source:
print bc.FAIL+'Cannot continue. Missing argument for BlenderRes '+libname+bc.ENDC
self.Exit()
if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross'):
print bc.FAIL+'BlenderRes is for windows only!'+bc.END
self.Exit()
print bc.HEADER+'Configuring resource '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC
lenv = self.Clone()
res = lenv.RES('#'+root_build_dir+'lib/'+libname, source)
SConsEnvironment.Default(self, res)
resources.append(res)
def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None):
if not self or not libname or not sources:
print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC
self.Exit()
if libname in quickie or len(quickie)==0:
if libname in quickdebug:
print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname +bc.ENDC+bc.OKBLUE+ " (debug mode)" + bc.ENDC
else:
print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname + bc.ENDC
lenv = self.Clone()
lenv.Append(CPPPATH=includes)
lenv.Append(CPPDEFINES=defines)
if lenv['WITH_BF_GAMEENGINE']:
lenv.Append(CPPDEFINES=['GAMEBLENDER=1'])
if lenv['WITH_BF_BULLET']:
lenv.Append(CPPDEFINES=['WITH_BULLET=1'])
if lenv['BF_DEBUG'] or (libname in quickdebug):
lenv.Append(CFLAGS = lenv['BF_DEBUG_CFLAGS'])
lenv.Append(CCFLAGS = lenv['BF_DEBUG_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['BF_DEBUG_CXXFLAGS'])
else:
lenv.Append(CFLAGS = lenv['REL_CFLAGS'])
lenv.Append(CCFLAGS = lenv['REL_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['REL_CXXFLAGS'])
if lenv['BF_PROFILE']:
lenv.Append(CFLAGS = lenv['BF_PROFILE_CFLAGS'])
lenv.Append(CCFLAGS = lenv['BF_PROFILE_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['BF_PROFILE_CXXFLAGS'])
if compileflags:
lenv.Append(CFLAGS = compileflags)
if cc_compileflags:
lenv.Append(CCFLAGS = cc_compileflags)
if cxx_compileflags:
lenv.Append(CXXFLAGS = cxx_compileflags)
lenv.Append(CFLAGS = lenv['C_WARN'])
lenv.Append(CCLAGS = lenv['CC_WARN'])
lenv.Append(CXXFLAGS = lenv['CXX_WARN'])
lib = lenv.Library(target= '#'+root_build_dir+'lib/'+libname, source=sources)
SConsEnvironment.Default(self, lib) # we add to default target, because this way we get some kind of progress info during build
else:
print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
# note: libs is a global
add_lib_to_dict(self, libs, libtype, libname, priority)
def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None):
if not self or not libname or not sources:
print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC
self.Exit()
def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC
lenv = self.Clone()
if lenv['OURPLATFORM'] in ['win32-vc', 'cygwin']:
lenv.Append(LINKFLAGS = Split(lenv['PLATFORM_LINKFLAGS']))
if lenv['BF_DEBUG']:
lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb'])
if lenv['OURPLATFORM']=='linux2':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
if lenv['OURPLATFORM']=='sunos5':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
if lenv['CXX'].endswith('CC'):
lenv.Replace(LINK = '$CXX')
if lenv['OURPLATFORM']=='darwin':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
lenv.Append(LINKFLAGS = lenv['BF_OPENGL_LINKFLAGS'])
if lenv['BF_PROFILE']:
lenv.Append(LINKFLAGS = lenv['BF_PROFILE_FLAGS'])
lenv.Append(CPPPATH=includes)
lenv.Append(LIBPATH=libpath)
lenv.Append(LIBS=libs)
if lenv['WITH_BF_QUICKTIME']:
lenv.Append(LIBS = lenv['BF_QUICKTIME_LIB'])
lenv.Append(LIBPATH = lenv['BF_QUICKTIME_LIBPATH'])
prog = lenv.Program(target=builddir+'bin/'+progname, source=sources)
if lenv['BF_DEBUG'] and lenv['OURPLATFORM']=='win32-vc' and lenv['BF_BSC']:
f = lenv.File(progname + '.bsc', builddir)
brs = lenv.Command(f, prog, [bsc])
SConsEnvironment.Default(self, brs)
SConsEnvironment.Default(self, prog)
program_list.append(prog)
if lenv['OURPLATFORM']=='darwin':
lenv['BINARYKIND'] = binarykind
lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
return prog
def list_substring(quickie, libname):
for q in quickie:
if libname.find(q) != -1:
return True
return False
def Glob(lenv, pattern):
path = string.replace(GetBuildPath(lenv,'SConscript'),'SConscript', '')
files = []
for i in glob.glob(path + pattern):
files.append(string.replace(i, path, ''))
return files
if list_substring(quickie, libname) or len(quickie)==0:
if list_substring(quickdebug, libname):
print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname +bc.ENDC+bc.OKBLUE+ " (debug mode)" + bc.ENDC
else:
print bc.HEADER+'Configuring library '+bc.ENDC+bc.OKGREEN+libname + bc.ENDC
lenv = self.Clone()
lenv.Append(CPPPATH=includes)
lenv.Append(CPPDEFINES=defines)
if lenv['WITH_BF_GAMEENGINE']:
lenv.Append(CPPDEFINES=['GAMEBLENDER=1'])
if lenv['WITH_BF_BULLET']:
lenv.Append(CPPDEFINES=['WITH_BULLET=1'])
if lenv['BF_DEBUG'] or (libname in quickdebug):
lenv.Append(CFLAGS = lenv['BF_DEBUG_CFLAGS'])
lenv.Append(CCFLAGS = lenv['BF_DEBUG_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['BF_DEBUG_CXXFLAGS'])
else:
lenv.Append(CFLAGS = lenv['REL_CFLAGS'])
lenv.Append(CCFLAGS = lenv['REL_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['REL_CXXFLAGS'])
if lenv['BF_PROFILE']:
lenv.Append(CFLAGS = lenv['BF_PROFILE_CFLAGS'])
lenv.Append(CCFLAGS = lenv['BF_PROFILE_CCFLAGS'])
lenv.Append(CXXFLAGS = lenv['BF_PROFILE_CXXFLAGS'])
if compileflags:
lenv.Append(CFLAGS = compileflags)
if cc_compileflags:
lenv.Append(CCFLAGS = cc_compileflags)
if cxx_compileflags:
lenv.Append(CXXFLAGS = cxx_compileflags)
lenv.Append(CFLAGS = lenv['C_WARN'])
lenv.Append(CCLAGS = lenv['CC_WARN'])
lenv.Append(CXXFLAGS = lenv['CXX_WARN'])
lib = lenv.Library(target= '#'+root_build_dir+'lib/'+libname, source=sources)
SConsEnvironment.Default(self, lib) # we add to default target, because this way we get some kind of progress info during build
else:
print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
# note: libs is a global
add_lib_to_dict(self, libs, libtype, libname, priority)
def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC
lenv = self.Clone()
if lenv['OURPLATFORM'] in ['win32-vc', 'cygwin']:
lenv.Append(LINKFLAGS = Split(lenv['PLATFORM_LINKFLAGS']))
if lenv['BF_DEBUG']:
lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb'])
if lenv['OURPLATFORM']=='linux2':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
if lenv['OURPLATFORM']=='sunos5':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
if lenv['CXX'].endswith('CC'):
lenv.Replace(LINK = '$CXX')
if lenv['OURPLATFORM']=='darwin':
lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
if lenv['WITH_BF_PYTHON']:
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
lenv.Append(LINKFLAGS = lenv['BF_OPENGL_LINKFLAGS'])
if lenv['BF_PROFILE']:
lenv.Append(LINKFLAGS = lenv['BF_PROFILE_FLAGS'])
lenv.Append(CPPPATH=includes)
lenv.Append(LIBPATH=libpath)
lenv.Append(LIBS=libs)
if lenv['WITH_BF_QUICKTIME']:
lenv.Append(LIBS = lenv['BF_QUICKTIME_LIB'])
lenv.Append(LIBPATH = lenv['BF_QUICKTIME_LIBPATH'])
prog = lenv.Program(target=builddir+'bin/'+progname, source=sources)
if lenv['BF_DEBUG'] and lenv['OURPLATFORM']=='win32-vc' and lenv['BF_BSC']:
f = lenv.File(progname + '.bsc', builddir)
brs = lenv.Command(f, prog, [bsc])
SConsEnvironment.Default(self, brs)
SConsEnvironment.Default(self, prog)
program_list.append(prog)
if lenv['OURPLATFORM']=='darwin':
lenv['BINARYKIND'] = binarykind
lenv.AddPostAction(prog,Action(AppIt,strfunction=my_appit_print))
return prog
def Glob(lenv, pattern):
path = string.replace(GetBuildPath(lenv,'SConscript'),'SConscript', '')
files = []
for i in glob.glob(path + pattern):
files.append(string.replace(i, path, ''))
return files