summaryrefslogtreecommitdiff
path: root/src/mapi/glapi/SConscript
blob: ac11148ffcf821b3e3662494a955f217743a5ad1 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#######################################################################
# SConscript for glapi


from sys import executable as python_cmd

Import('*')

env = env.Clone()

env.Append(CPPDEFINES = [
    'MAPI_MODE_UTIL',
])

if env['platform'] == 'windows':
    env.Append(CPPDEFINES = [
        '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
        'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
    ])
    if env['gles']:
        env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])
    else:
        # prevent _glapi_* from being declared __declspec(dllimport)
        env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])

env.Append(CPPPATH = [
    '#/src/mapi',
    '#/src/mesa',
    Dir('..'), # src/mapi build path
])

glapi_sources = [
    'glapi_dispatch.c',
    'glapi_entrypoint.c',
    'glapi_getproc.c',
    'glapi_nop.c',
    'glthread.c',
    'glapi.c',
]

mapi_sources = [
    'u_current.c',
    'u_execmem.c',
]
for s in mapi_sources:
    o = env.SharedObject(s[:-2], '../' + s)
    glapi_sources.append(o)

#
# Assembly sources
#
if (env['gcc'] or env['clang']) and \
   env['platform'] not in ('cygwin', 'darwin', 'windows'):
    GLAPI = '#src/mapi/glapi/'

    if env['machine'] == 'x86':
        env.Append(CPPDEFINES = [
            'USE_X86_ASM',
        ])
        glapi_sources += [
            'glapi_x86.S',
        ]
        env.CodeGenerate(
            target = 'glapi_x86.S',
            script = GLAPI + 'gen/gl_x86_asm.py',
            source = GLAPI + 'gen/gl_and_es_API.xml',
            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
            )
    elif env['machine'] == 'x86_64':
        env.Append(CPPDEFINES = [
            'USE_X86_64_ASM',
        ])
        glapi_sources += [
            'glapi_x86-64.S'
        ]
        env.CodeGenerate(
            target = 'glapi_x86-64.S',
            script = GLAPI + 'gen/gl_x86-64_asm.py',
            source = GLAPI + 'gen/gl_and_es_API.xml',
            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
            )
    elif env['machine'] == 'sparc':
        env.Append(CPPDEFINES = [
            'USE_SPARC_ASM',
        ])
        glapi_sources += [
            'glapi_sparc.S'
        ]
        env.CodeGenerate(
            target = 'glapi_sparc.S',
            script = GLAPI + 'gen/gl_SPARC_asm.py',
            source = GLAPI + 'gen/gl_and_es_API.xml',
            command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
            )
    else:
        pass

if env['toolchain'] == 'crossmingw':
    # compile these files without -gstabs option
    glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_dispatch.c")
    glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_getproc.c")

glapi = env.ConvenienceLibrary(
    target = 'glapi',
    source = glapi_sources,
)
Export('glapi')