diff options
author | Chia-I Wu <olv@lunarg.com> | 2011-01-14 17:50:29 +0800 |
---|---|---|
committer | Chia-I Wu <olv@lunarg.com> | 2011-01-22 11:59:05 +0800 |
commit | bb770af3a59e5935c108c05ee45490fc5668d4a3 (patch) | |
tree | 206b869b2a2d740570349b1e4412cf51c172e56b /src/mapi/shared-glapi | |
parent | 3f04314ae2659748c8cf73ec649a035bc9e01597 (diff) |
scons: Add support for GLES.
GLES can be enabled by running scons with
$ scons gles=yes
When gles=yes is given, the build is changed in three ways. First,
libmesa.a will be built with FEATURE_ES1 and FEATURE_ES2. This makes
DRI drivers and libEGL support and advertise GLES support. Second, GLES
libraries will be created. They are libGLESv1_CM, libGLESv2, and
libglapi. Last, libGL or opengl32 will link to libglapi. This change
is required as _glapi_* will be declared as __declspec(dllimport) in
libmesa.a on windows. libmesa.a expects those symbols to be defined in
another DLL. Due to this change to GL, GLES support is marked
experimental.
Note that GLES requires libxml2-python to generate some of its sources.
Diffstat (limited to 'src/mapi/shared-glapi')
-rw-r--r-- | src/mapi/shared-glapi/SConscript | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/mapi/shared-glapi/SConscript b/src/mapi/shared-glapi/SConscript new file mode 100644 index 0000000000..b7c43a7347 --- /dev/null +++ b/src/mapi/shared-glapi/SConscript @@ -0,0 +1,116 @@ +####################################################################### +# SConscript for shared-glapi/es1api/es2api + +from sys import executable as python_cmd + +Import('*') + +def mapi_objects(env, printer, mode): + """Return mapi objects built for the given printer and mode.""" + mapi_sources = { + 'glapi': ['entry.c', 'mapi_glapi.c', 'stub.c', 'table.c', + 'u_current.c', 'u_execmem.c', 'u_thread.c'], + 'bridge': ['entry.c'], + } + mapi_defines = { + 'glapi': ['MAPI_MODE_GLAPI'], + 'bridge': ['MAPI_MODE_BRIDGE'], + } + + header_name = '%s-tmp.h' % (printer) + + # generate ABI header + header = env.CodeGenerate( + target = header_name, + script = '../mapi/mapi_abi.py', + source = '../glapi/gen/gl_and_es_API.xml', + command = python_cmd + ' $SCRIPT ' + \ + '--printer %s --mode lib $SOURCE > $TARGET' % (printer), + ) + + cpppath = [ + header[0].dir, + '#/include', + '#/src/mapi', + ] + + cppdefines = mapi_defines[mode] + [ + 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name), + ] + + if env['platform'] == 'windows': + if mode == 'glapi': + cppdefines += [ + '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h + ] + else: + cppdefines += [ + '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers + 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers + ] + + objects = [] + for s in mapi_sources[mode]: + o = env.SharedObject( + target = '%s-%s' % (printer, s[:-2]), + source = '../mapi/' + s, + CPPPATH = cpppath, + CPPDEFINES = cppdefines, + ) + objects.append(o[0]) + + env.Depends(objects, header) + + return objects + +if env['platform'] != 'winddk': + env = env.Clone() + + env['SHLIBPREFIX'] = 'lib' + env['LIBPREFIX'] = 'lib' + + shared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi') + shared_glapi = env.SharedLibrary( + target = 'glapi', + source = shared_glapi_objects, + ) + + # manually add LIBPREFIX on windows + if env['platform'] == 'windows': + libs = ['libglapi'] + else: + libs = ['glapi'] + + es1api_objects = mapi_objects(env, 'es1api', 'bridge') + es1api = env.SharedLibrary( + target = 'GLESv1_CM', + source = es1api_objects, + LIBPATH = ['.'], + LIBS = libs, + ) + + es2api_objects = mapi_objects(env, 'es2api', 'bridge') + es2api = env.SharedLibrary( + target = 'GLESv2', + source = es2api_objects, + LIBPATH = ['.'], + LIBS = libs, + ) + + env.InstallSharedLibrary(shared_glapi, version=(0, 0, 0)) + env.InstallSharedLibrary(es1api, version=(1, 0, 0)) + env.InstallSharedLibrary(es2api, version=(2, 0, 0)) + + if env['platform'] == 'windows': + shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX') + else: + shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX') + + # build glapi bridge as a convenience libarary for libgl-xlib/libgl-gdi + bridge_glapi_objects = mapi_objects(env, 'glapi', 'bridge') + bridge_glapi = env.ConvenienceLibrary( + target = 'glapi_bridge', + source = bridge_glapi_objects, + ) + + Export(['shared_glapi', 'bridge_glapi']) |