scons: wire the new generator for es1 and es2
[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 if printer != 'glapi':
31 if printer == 'es1api':
32 abi_tag = 'glesv1'
33 else:
34 abi_tag = 'glesv2'
35
36 header = env.CodeGenerate(
37 target = header_name,
38 script = '../new/gen_gldispatch_mapi.py',
39 source = GLAPI + 'registry/gl.xml'
40 command = python_cmd + ' $SCRIPT ' + \
41 '%s $SOURCE > $TARGET' % (abi_tag),
42 )
43 else:
44 header = env.CodeGenerate(
45 target = header_name,
46 script = '../mapi_abi.py',
47 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'),
48 command = python_cmd + ' $SCRIPT ' + \
49 '--printer %s $SOURCE > $TARGET' % (printer),
50 )
51
52 cpppath = [
53 header[0].dir,
54 '#/include',
55 '#/src',
56 '#/src/mapi',
57 ]
58
59 cppdefines = mapi_defines[mode] + [
60 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name),
61 ]
62
63 if env['platform'] == 'windows':
64 if mode == 'glapi':
65 cppdefines += [
66 '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h
67 ]
68 else:
69 cppdefines += [
70 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
71 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
72 ]
73
74 objects = []
75 for s in mapi_sources[mode]:
76 o = env.SharedObject(
77 target = '%s-%s' % (printer, s[:-2]),
78 source = '../' + s,
79 CPPPATH = cpppath,
80 CPPDEFINES = cppdefines,
81 )
82 objects.append(o[0])
83
84 env.Depends(objects, header)
85
86 return objects
87
88 env = env.Clone()
89
90 env['SHLIBPREFIX'] = 'lib'
91 env['LIBPREFIX'] = 'lib'
92
93 shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi')
94 shared_glapi = env.SharedLibrary(
95 target = 'glapi',
96 source = shared_glapi_objects,
97 )
98
99 # manually add LIBPREFIX on windows
100 if env['platform'] == 'windows':
101 libs = ['libglapi']
102 else:
103 libs = ['glapi']
104
105 es1api_objects = mapi_objects(env, 'es1api', 'bridge')
106 es1api = env.SharedLibrary(
107 target = 'GLESv1_CM',
108 source = es1api_objects,
109 LIBPATH = ['.'],
110 LIBS = libs,
111 )
112
113 es2api_objects = mapi_objects(env, 'es2api', 'bridge')
114 es2api = env.SharedLibrary(
115 target = 'GLESv2',
116 source = es2api_objects,
117 LIBPATH = ['.'],
118 LIBS = libs,
119 )
120
121 env.InstallSharedLibrary(shared_glapi, version=(0, 0, 0))
122 env.InstallSharedLibrary(es1api, version=(1, 0, 0))
123 env.InstallSharedLibrary(es2api, version=(2, 0, 0))
124
125 if env['platform'] == 'windows':
126 shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX')
127 else:
128 shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX')
129
130 Export(['shared_glapi'])