1 #######################################################################
2 # SConscript for shared-glapi/es1api/es2api
4 from sys import executable as python_cmd
8 def mapi_objects(env, printer, mode):
9 """Return mapi objects built for the given printer and mode."""
19 'bridge': ['entry.c'],
22 'glapi': ['MAPI_MODE_GLAPI'],
23 'bridge': ['MAPI_MODE_BRIDGE'],
26 header_name = '%s-tmp.h' % (printer)
29 header = env.CodeGenerate(
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),
43 cppdefines = mapi_defines[mode] + [
44 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name),
47 if env['platform'] == 'windows':
50 '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h
54 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
55 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
59 for s in mapi_sources[mode]:
61 target = '%s-%s' % (printer, s[:-2]),
64 CPPDEFINES = cppdefines,
68 env.Depends(objects, header)
74 env['SHLIBPREFIX'] = 'lib'
75 env['LIBPREFIX'] = 'lib'
77 shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi')
78 shared_glapi = env.SharedLibrary(
80 source = shared_glapi_objects,
83 # manually add LIBPREFIX on windows
84 if env['platform'] == 'windows':
89 es1api_objects = mapi_objects(env, 'es1api', 'bridge')
90 es1api = env.SharedLibrary(
92 source = es1api_objects,
97 es2api_objects = mapi_objects(env, 'es2api', 'bridge')
98 es2api = env.SharedLibrary(
100 source = es2api_objects,
105 env.InstallSharedLibrary(shared_glapi, version=(0, 0, 0))
106 env.InstallSharedLibrary(es1api, version=(1, 0, 0))
107 env.InstallSharedLibrary(es2api, version=(2, 0, 0))
109 if env['platform'] == 'windows':
110 shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX')
112 shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX')
114 # build glapi bridge as a convenience libarary for libgl-xlib/libgl-gdi
115 bridge_glapi_objects = mapi_objects(env, 'glapi', 'bridge')
116 bridge_glapi = env.ConvenienceLibrary(
117 target = 'glapi_bridge',
118 source = bridge_glapi_objects,
121 Export(['shared_glapi', 'bridge_glapi'])