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