src/SConscript
branchpyrit
changeset 93 96d65f841791
parent 92 9af5c039b678
child 99 f3abdaa2e8fb
equal deleted inserted replaced
92:9af5c039b678 93:96d65f841791
     1 Import('env buildmodule cc')
     1 Import('env pyenv buildmodule cc')
     2 
       
     3 myenv = env.Clone(CPPPATH = '#include')
       
     4 pyenv = myenv.Clone()
       
     5 if env['PLATFORM'] == 'win32':
       
     6 	import sys
       
     7 	pythonver = '%c%c' % (sys.version[0], sys.version[2])
       
     8 	pythonlib = 'python'+pythonver
       
     9 	pythonpath = [env['pythonpath'],
       
    10 		'C:\\Program Files\\Python'+pythonver]
       
    11 	pyenv.Append(LIBS=pythonlib)
       
    12 	pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath])
       
    13 	pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath])
       
    14 	pyenv.Replace(SHLIBSUFFIX='.pyd')
       
    15 else:
       
    16 	pyenv.ParseConfig('python-config --includes --libs')
       
    17 
     2 
    18 sources = [
     3 sources = [
    19 	'raytracer.cc', 'scene.cc', 'shapes.cc', 'sampler.cc',
     4 	'common.cc', 'raytracer.cc', 'sampler.cc', 'scene.cc',
    20 	'container.cc', 'kdtree.cc', 'octree.cc', 'material.cc',
     5 	'shapes.cc', 'material.cc', 'pixmap.cc', 'serialize.cc',
    21 	'serialize.cc', 'pixmap.cc']
     6 	'container.cc', 'kdtree.cc', 'octree.cc']
    22 
       
    23 objs = []
       
    24 shared_objs = []
       
    25 for src in sources:
       
    26 	objs.append( myenv.Object(src) )
       
    27 	shared_objs.append( myenv.SharedObject(src) )
       
    28 
     7 
    29 if buildmodule:
     8 if buildmodule:
       
     9 	shared_objs = []
       
    10 	for src in sources:
       
    11 		shared_objs.append( pyenv.SharedObject(src) )
    30 	if cc == 'gcc':
    12 	if cc == 'gcc':
    31 		ccflags = '$CCFLAGS -Wno-write-strings'
    13 		ccflags = '$CCFLAGS -Wno-write-strings'
    32 	else:
    14 	else:
    33 		ccflags = '$CCFLAGS'
    15 		ccflags = '$CCFLAGS'
       
    16 	if cc == 'msvc':
       
    17 		linkflags = '$LINKFLAGS /export:initpyrit'
       
    18 	else:
       
    19 		linkflags = '$LINKFLAGS'
    34 	pymodule = pyenv.SharedLibrary('pyrit',
    20 	pymodule = pyenv.SharedLibrary('pyrit',
    35 		['raytracermodule.cc']+shared_objs,
    21 		['raytracermodule.cc']+shared_objs,
    36 		SHLIBPREFIX = '', CCFLAGS = ccflags)
    22 		SHLIBPREFIX = '', CCFLAGS = ccflags,
       
    23 		LINKFLAGS=linkflags)
       
    24 	if cc == 'msvc':	
       
    25 		pyenv.AddPostAction(pymodule, 'mt /nologo /manifest ${TARGET}.manifest /outputresource:$TARGET;2')
    37 	env.Alias('shared-objs', shared_objs)
    26 	env.Alias('shared-objs', shared_objs)
    38 	env.Alias('python-module', pymodule)
    27 	env.Alias('python-module', pymodule)
    39 	Return('pymodule')
    28 	Return('pymodule')
    40 else:
    29 else:
    41 	lib = myenv.StaticLibrary('pyrit', objs)
    30 	objs = []
       
    31 	for src in sources:
       
    32 		objs.append( env.Object(src) )
       
    33 	lib = env.StaticLibrary('pyrit', objs)
    42 	env.Alias('objs', objs)
    34 	env.Alias('objs', objs)
    43 	env.Alias('static-lib', lib)
    35 	env.Alias('static-lib', lib)
    44 	Return('lib')
    36 	Return('lib')