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
108
109
110
111
112
113
114
115
|
#######################################################################
# SConscript for shared-glapi/es1api/es2api
from sys import executable as python_cmd
Import('*')
def mapi_objects(env, printer, mode):
"""Return mapi objects built for the given printer and mode."""
mapi_sources = {
'glapi': ['entry.c', 'mapi_glapi.c', 'stub.c', 'table.c',
'u_current.c', 'u_execmem.c', 'u_thread.c'],
'bridge': ['entry.c'],
}
mapi_defines = {
'glapi': ['MAPI_MODE_GLAPI'],
'bridge': ['MAPI_MODE_BRIDGE'],
}
header_name = '%s-tmp.h' % (printer)
# generate ABI header
header = env.CodeGenerate(
target = header_name,
script = '../mapi/mapi_abi.py',
source = '../glapi/gen/gl_and_es_API.xml',
command = python_cmd + ' $SCRIPT ' + \
'--printer %s --mode lib $SOURCE > $TARGET' % (printer),
)
cpppath = [
header[0].dir,
'#/include',
'#/src/mapi',
]
cppdefines = mapi_defines[mode] + [
'MAPI_ABI_HEADER=\\"%s\\"' % (header_name),
]
if env['platform'] == 'windows':
if mode == 'glapi':
cppdefines += [
'_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h
]
else:
cppdefines += [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
]
objects = []
for s in mapi_sources[mode]:
o = env.SharedObject(
target = '%s-%s' % (printer, s[:-2]),
source = '../mapi/' + s,
CPPPATH = cpppath,
CPPDEFINES = cppdefines,
)
objects.append(o[0])
env.Depends(objects, header)
return objects
env = env.Clone()
env['SHLIBPREFIX'] = 'lib'
env['LIBPREFIX'] = 'lib'
shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi')
shared_glapi = env.SharedLibrary(
target = 'glapi',
source = shared_glapi_objects,
)
# manually add LIBPREFIX on windows
if env['platform'] == 'windows':
libs = ['libglapi']
else:
libs = ['glapi']
es1api_objects = mapi_objects(env, 'es1api', 'bridge')
es1api = env.SharedLibrary(
target = 'GLESv1_CM',
source = es1api_objects,
LIBPATH = ['.'],
LIBS = libs,
)
es2api_objects = mapi_objects(env, 'es2api', 'bridge')
es2api = env.SharedLibrary(
target = 'GLESv2',
source = es2api_objects,
LIBPATH = ['.'],
LIBS = libs,
)
env.InstallSharedLibrary(shared_glapi, version=(0, 0, 0))
env.InstallSharedLibrary(es1api, version=(1, 0, 0))
env.InstallSharedLibrary(es2api, version=(2, 0, 0))
if env['platform'] == 'windows':
shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX')
else:
shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX')
# build glapi bridge as a convenience libarary for libgl-xlib/libgl-gdi
bridge_glapi_objects = mapi_objects(env, 'glapi', 'bridge')
bridge_glapi = env.ConvenienceLibrary(
target = 'glapi_bridge',
source = bridge_glapi_objects,
)
Export(['shared_glapi', 'bridge_glapi'])
|