scons: Remove gles option.
[mesa.git] / src / mapi / shared-glapi / SConscript
1 #######################################################################
2 # SConscript for shared-glapi/es1api/es2api
3
4 from sys import executable as python_cmd
5
6 Import('*')
7
8 def mapi_objects(env, printer, mode):
9 """Return mapi objects built for the given printer and mode."""
10 mapi_sources = {
11 'glapi': [
12 'entry.c',
13 'mapi_glapi.c',
14 'stub.c',
15 'table.c',
16 'u_current.c',
17 'u_execmem.c',
18 ],
19 'bridge': ['entry.c'],
20 }
21 mapi_defines = {
22 'glapi': ['MAPI_MODE_GLAPI'],
23 'bridge': ['MAPI_MODE_BRIDGE'],
24 }
25
26 header_name = '%s-tmp.h' % (printer)
27
28 # generate ABI header
29 GLAPI = '../glapi/'
30 header = env.CodeGenerate(
31 target = header_name,
32 script = '../mapi_abi.py',
33 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
34 command = python_cmd + ' $SCRIPT ' + \
35 '--printer %s $SOURCE > $TARGET' % (printer),
36 )
37
38 cpppath = [
39 header[0].dir,
40 '#/include',
41 '#/src',
42 '#/src/mapi',
43 ]
44
45 cppdefines = mapi_defines[mode] + [
46 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name),
47 ]
48
49 if env['platform'] == 'windows':
50 if mode == 'glapi':
51 cppdefines += [
52 '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h
53 ]
54 else:
55 cppdefines += [
56 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
57 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
58 ]
59
60 objects = []
61 for s in mapi_sources[mode]:
62 o = env.SharedObject(
63 target = '%s-%s' % (printer, s[:-2]),
64 source = '../' + s,
65 CPPPATH = cpppath,
66 CPPDEFINES = cppdefines,
67 )
68 objects.append(o[0])
69
70 env.Depends(objects, header)
71
72 return objects
73
74 env = env.Clone()
75
76 env['SHLIBPREFIX'] = 'lib'
77 env['LIBPREFIX'] = 'lib'
78
79 shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi')
80 shared_glapi = env.SharedLibrary(
81 target = 'glapi',
82 source = shared_glapi_objects,
83 )
84
85 # manually add LIBPREFIX on windows
86 if env['platform'] == 'windows':
87 libs = ['libglapi']
88 else:
89 libs = ['glapi']
90
91 es1api_objects = mapi_objects(env, 'es1api', 'bridge')
92 es1api = env.SharedLibrary(
93 target = 'GLESv1_CM',
94 source = es1api_objects,
95 LIBPATH = ['.'],
96 LIBS = libs,
97 )
98
99 es2api_objects = mapi_objects(env, 'es2api', 'bridge')
100 es2api = env.SharedLibrary(
101 target = 'GLESv2',
102 source = es2api_objects,
103 LIBPATH = ['.'],
104 LIBS = libs,
105 )
106
107 env.InstallSharedLibrary(shared_glapi, version=(0, 0, 0))
108 env.InstallSharedLibrary(es1api, version=(1, 0, 0))
109 env.InstallSharedLibrary(es2api, version=(2, 0, 0))
110
111 if env['platform'] == 'windows':
112 shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX')
113 else:
114 shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX')
115
116 Export(['shared_glapi'])