summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/python/SConscript
blob: 854cd83b7c26cbb1fdf5c9bfa68caa046a4edf5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import os.path

Import('*')

if 'python' in env['statetrackers']:

    env = env.Clone()
    
    env.Append(CPPPATH = '.')
    
    env.Tool('swig')
    env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe'])
    env.Append(SWIGFLAGS = ['-python', '-keyword'])
    
    # http://www.scons.org/wiki/PythonExtensions
    #env.AppendUnique(CPPATH = [distutils.sysconfig.get_python_inc()])
    #distutils.sysconfig.get_config_vars('SO')
        
    env['SHLIBPREFIX'] = ''
    
    if platform in ['linux']:
        env.ParseConfig('python-config --cflags --ldflags --libs')
        
    if platform in ['windows']:
        python_root = sys.prefix
        python_version = '%u%u' % sys.version_info[:2]
        python_include = os.path.join(python_root, 'include')
        python_libs = os.path.join(python_root, 'libs')
        python_lib = os.path.join(python_libs, 'python' + python_version + '.lib')
        
        env.Append(CPPPATH = [python_include])
        env.Append(LIBPATH = [python_libs])
        env.Append(LIBS = ['python' + python_version + '.lib'])
        env.Replace(SHLIBSUFFIX = '.pyd')
        
        if env['debug']:
            # XXX; python25_d.lib is not included in Python for windows, and 
            # we'll get missing symbols unless we undefine _DEBUG
            cppdefines = env['CPPDEFINES']
            cppdefines = [define for define in cppdefines if define != '_DEBUG']
            env.Replace(CPPDEFINES = cppdefines)
        
        # http://www.swig.org/Doc1.3/Windows.html
        env['ENV']['PYTHON_INCLUDE'] = python_include
        env['ENV']['PYTHON_LIB'] = python_lib
        
    env.SharedLibrary(
    	target = '_gallium',
    	source = [
    		'gallium.i',
            'st_device.c',
            'st_softpipe_winsys.c',
    	],
        LIBS = softpipe + auxiliaries + env['LIBS'],
    )