SConscript revision 848b8605
1#######################################################################
2# SConscript for glapi
3
4
5from sys import executable as python_cmd
6
7Import('*')
8
9env = env.Clone()
10
11env.Append(CPPDEFINES = [
12    'MAPI_MODE_UTIL',
13])
14
15if env['platform'] == 'windows':
16    env.Append(CPPDEFINES = [
17        '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
18        'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
19    ])
20    if env['gles']:
21        env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])
22    else:
23        # prevent _glapi_* from being declared __declspec(dllimport)
24        env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
25
26env.Append(CPPPATH = [
27    '#/src/mapi',
28    '#/src/mesa',
29    Dir('..'), # src/mapi build path
30])
31
32glapi_sources = [
33    'glapi_dispatch.c',
34    'glapi_entrypoint.c',
35    'glapi_getproc.c',
36    'glapi_nop.c',
37    'glapi.c',
38]
39
40mapi_sources = [
41    'u_current.c',
42    'u_execmem.c',
43]
44for s in mapi_sources:
45    o = env.SharedObject(s[:-2], '../' + s)
46    glapi_sources.append(o)
47
48#
49# Assembly sources
50#
51if (env['gcc'] or env['clang']) and \
52   env['platform'] not in ('cygwin', 'darwin', 'windows'):
53    GLAPI = '#src/mapi/glapi/'
54    sources = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml')
55
56    if env['machine'] == 'x86':
57        env.Append(CPPDEFINES = [
58            'USE_X86_ASM',
59        ])
60        glapi_sources += [
61            'glapi_x86.S',
62        ]
63        env.CodeGenerate(
64            target = 'glapi_x86.S',
65            script = GLAPI + 'gen/gl_x86_asm.py',
66            source = sources,
67            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
68            )
69    elif env['machine'] == 'x86_64':
70        env.Append(CPPDEFINES = [
71            'USE_X86_64_ASM',
72        ])
73        glapi_sources += [
74            'glapi_x86-64.S'
75        ]
76        env.CodeGenerate(
77            target = 'glapi_x86-64.S',
78            script = GLAPI + 'gen/gl_x86-64_asm.py',
79            source = sources,
80            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
81            )
82    elif env['machine'] == 'sparc':
83        env.Append(CPPDEFINES = [
84            'USE_SPARC_ASM',
85        ])
86        glapi_sources += [
87            'glapi_sparc.S'
88        ]
89        env.CodeGenerate(
90            target = 'glapi_sparc.S',
91            script = GLAPI + 'gen/gl_SPARC_asm.py',
92            source = sources,
93            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
94            )
95    else:
96        pass
97
98glapi = env.ConvenienceLibrary(
99    target = 'glapi',
100    source = glapi_sources,
101)
102Export('glapi')
103