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)
30 header = env.CodeGenerate(
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),
45 cppdefines = mapi_defines[mode] + [
46 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name),
49 if env['platform'] == 'windows':
52 '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h
56 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
57 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
61 for s in mapi_sources[mode]:
63 target = '%s-%s' % (printer, s[:-2]),
66 CPPDEFINES = cppdefines,
70 env.Depends(objects, header)
76 env['SHLIBPREFIX'] = 'lib'
77 env['LIBPREFIX'] = 'lib'
79 shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi')
80 shared_glapi = env.SharedLibrary(
82 source = shared_glapi_objects,
85 # manually add LIBPREFIX on windows
86 if env['platform'] == 'windows':
91 es1api_objects = mapi_objects(env, 'es1api', 'bridge')
92 es1api = env.SharedLibrary(
94 source = es1api_objects,
99 es2api_objects = mapi_objects(env, 'es2api', 'bridge')
100 es2api = env.SharedLibrary(
102 source = es2api_objects,
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))
111 if env['platform'] == 'windows':
112 shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX')
114 shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX')
116 # build glapi bridge as a convenience libarary for libgl-xlib/libgl-gdi
117 bridge_glapi_objects = mapi_objects(env, 'glapi', 'bridge')
118 bridge_glapi = env.ConvenienceLibrary(
119 target = 'glapi_bridge',
120 source = bridge_glapi_objects,
123 Export(['shared_glapi', 'bridge_glapi'])