SConscript revision b8e80941
1848b8605Smrg####################################################################### 2848b8605Smrg# SConscript for shared-glapi/es1api/es2api 3848b8605Smrg 4848b8605Smrgfrom sys import executable as python_cmd 5848b8605Smrg 6848b8605SmrgImport('*') 7848b8605Smrg 8848b8605Smrgdef mapi_objects(env, printer, mode): 9848b8605Smrg """Return mapi objects built for the given printer and mode.""" 10848b8605Smrg mapi_sources = { 11848b8605Smrg 'glapi': [ 12848b8605Smrg 'entry.c', 13848b8605Smrg 'mapi_glapi.c', 14848b8605Smrg 'stub.c', 15848b8605Smrg 'table.c', 16848b8605Smrg 'u_current.c', 17848b8605Smrg 'u_execmem.c', 18848b8605Smrg ], 19848b8605Smrg 'bridge': ['entry.c'], 20848b8605Smrg } 21848b8605Smrg mapi_defines = { 22848b8605Smrg 'glapi': ['MAPI_MODE_GLAPI'], 23848b8605Smrg 'bridge': ['MAPI_MODE_BRIDGE'], 24848b8605Smrg } 25848b8605Smrg 26848b8605Smrg header_name = '%s-tmp.h' % (printer) 27848b8605Smrg 28848b8605Smrg # generate ABI header 29b8e80941Smrg GLAPI = '../glapi/' 30b8e80941Smrg if printer != 'glapi': 31b8e80941Smrg if printer == 'es1api': 32b8e80941Smrg abi_tag = 'glesv1' 33b8e80941Smrg else: 34b8e80941Smrg abi_tag = 'glesv2' 35b8e80941Smrg 36b8e80941Smrg header = env.CodeGenerate( 37b8e80941Smrg target = header_name, 38b8e80941Smrg script = '../new/gen_gldispatch_mapi.py', 39b8e80941Smrg source = GLAPI + 'registry/gl.xml' 40b8e80941Smrg command = python_cmd + ' $SCRIPT ' + \ 41b8e80941Smrg '%s $SOURCE > $TARGET' % (abi_tag), 42b8e80941Smrg ) 43b8e80941Smrg else: 44b8e80941Smrg header = env.CodeGenerate( 45b8e80941Smrg target = header_name, 46b8e80941Smrg script = '../mapi_abi.py', 47b8e80941Smrg source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), 48b8e80941Smrg command = python_cmd + ' $SCRIPT ' + \ 49b8e80941Smrg '--printer %s $SOURCE > $TARGET' % (printer), 50b8e80941Smrg ) 51848b8605Smrg 52848b8605Smrg cpppath = [ 53848b8605Smrg header[0].dir, 54848b8605Smrg '#/include', 55b8e80941Smrg '#/src', 56848b8605Smrg '#/src/mapi', 57848b8605Smrg ] 58b8e80941Smrg 59848b8605Smrg cppdefines = mapi_defines[mode] + [ 60848b8605Smrg 'MAPI_ABI_HEADER=\\"%s\\"' % (header_name), 61848b8605Smrg ] 62848b8605Smrg 63848b8605Smrg if env['platform'] == 'windows': 64848b8605Smrg if mode == 'glapi': 65848b8605Smrg cppdefines += [ 66848b8605Smrg '_GLAPI_DLL_EXPORTS', # declare _glapi_* as __declspec(dllexport) in glapi.h 67848b8605Smrg ] 68848b8605Smrg else: 69848b8605Smrg cppdefines += [ 70848b8605Smrg '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers 71848b8605Smrg 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers 72848b8605Smrg ] 73848b8605Smrg 74848b8605Smrg objects = [] 75848b8605Smrg for s in mapi_sources[mode]: 76848b8605Smrg o = env.SharedObject( 77848b8605Smrg target = '%s-%s' % (printer, s[:-2]), 78848b8605Smrg source = '../' + s, 79848b8605Smrg CPPPATH = cpppath, 80848b8605Smrg CPPDEFINES = cppdefines, 81848b8605Smrg ) 82848b8605Smrg objects.append(o[0]) 83848b8605Smrg 84848b8605Smrg env.Depends(objects, header) 85848b8605Smrg 86848b8605Smrg return objects 87848b8605Smrg 88848b8605Smrgenv = env.Clone() 89848b8605Smrg 90848b8605Smrgenv['SHLIBPREFIX'] = 'lib' 91848b8605Smrgenv['LIBPREFIX'] = 'lib' 92848b8605Smrg 93848b8605Smrgshared_glapi_objects = mapi_objects(env, 'shared-glapi', 'glapi') 94848b8605Smrgshared_glapi = env.SharedLibrary( 95848b8605Smrg target = 'glapi', 96848b8605Smrg source = shared_glapi_objects, 97848b8605Smrg) 98848b8605Smrg 99848b8605Smrg# manually add LIBPREFIX on windows 100848b8605Smrgif env['platform'] == 'windows': 101848b8605Smrg libs = ['libglapi'] 102848b8605Smrgelse: 103848b8605Smrg libs = ['glapi'] 104848b8605Smrg 105848b8605Smrges1api_objects = mapi_objects(env, 'es1api', 'bridge') 106848b8605Smrges1api = env.SharedLibrary( 107848b8605Smrg target = 'GLESv1_CM', 108848b8605Smrg source = es1api_objects, 109848b8605Smrg LIBPATH = ['.'], 110848b8605Smrg LIBS = libs, 111848b8605Smrg) 112848b8605Smrg 113848b8605Smrges2api_objects = mapi_objects(env, 'es2api', 'bridge') 114848b8605Smrges2api = env.SharedLibrary( 115848b8605Smrg target = 'GLESv2', 116848b8605Smrg source = es2api_objects, 117848b8605Smrg LIBPATH = ['.'], 118848b8605Smrg LIBS = libs, 119848b8605Smrg) 120848b8605Smrg 121848b8605Smrgenv.InstallSharedLibrary(shared_glapi, version=(0, 0, 0)) 122848b8605Smrgenv.InstallSharedLibrary(es1api, version=(1, 0, 0)) 123848b8605Smrgenv.InstallSharedLibrary(es2api, version=(2, 0, 0)) 124848b8605Smrg 125848b8605Smrgif env['platform'] == 'windows': 126848b8605Smrg shared_glapi = env.FindIxes(shared_glapi, 'LIBPREFIX', 'LIBSUFFIX') 127848b8605Smrgelse: 128848b8605Smrg shared_glapi = env.FindIxes(shared_glapi, 'SHLIBPREFIX', 'SHLIBSUFFIX') 129848b8605Smrg 130b8e80941SmrgExport(['shared_glapi']) 131