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