python: Get it to build on windows too.
[mesa.git] / src / gallium / state_trackers / python / SConscript
1 import sys
2 import os.path
3
4 Import('*')
5
6 if 'python' in env['statetrackers']:
7
8 env = env.Clone()
9
10 env.Append(CPPPATH = '.')
11
12 env.Tool('swig')
13 env.Append(SWIGPATH = ['#src/gallium/include', '#src/gallium/include/pipe'])
14 env.Append(SWIGFLAGS = ['-python', '-keyword'])
15
16 # http://www.scons.org/wiki/PythonExtensions
17 #env.AppendUnique(CPPATH = [distutils.sysconfig.get_python_inc()])
18 #distutils.sysconfig.get_config_vars('SO')
19
20 env['SHLIBPREFIX'] = ''
21
22 if platform in ['linux']:
23 env.ParseConfig('python-config --cflags --ldflags --libs')
24
25 if platform in ['windows']:
26 python_root = sys.prefix
27 python_version = '%u%u' % sys.version_info[:2]
28 python_include = os.path.join(python_root, 'include')
29 python_libs = os.path.join(python_root, 'libs')
30 python_lib = os.path.join(python_libs, 'python' + python_version + '.lib')
31
32 env.Append(CPPPATH = [python_include])
33 env.Append(LIBPATH = [python_libs])
34 env.Append(LIBS = ['python' + python_version + '.lib'])
35 env.Replace(SHLIBSUFFIX = '.pyd')
36
37 if env['debug']:
38 # XXX; python25_d.lib is not included in Python for windows, and
39 # we'll get missing symbols unless we undefine _DEBUG
40 cppdefines = env['CPPDEFINES']
41 cppdefines = [define for define in cppdefines if define != '_DEBUG']
42 env.Replace(CPPDEFINES = cppdefines)
43
44 # http://www.swig.org/Doc1.3/Windows.html
45 env['ENV']['PYTHON_INCLUDE'] = python_include
46 env['ENV']['PYTHON_LIB'] = python_lib
47
48 env.SharedLibrary(
49 target = '_gallium',
50 source = [
51 'gallium.i',
52 'st_device.c',
53 'st_softpipe_winsys.c',
54 ],
55 LIBS = softpipe + auxiliaries + env['LIBS'],
56 )