Home | History | Annotate | Download | only in glapi
      1 #######################################################################
      2 # SConscript for glapi
      3 
      4 
      5 from sys import executable as python_cmd
      6 
      7 Import('*')
      8 
      9 env = env.Clone()
     10 
     11 env.Append(CPPDEFINES = [
     12     'MAPI_MODE_UTIL',
     13 ])
     14 
     15 if env['platform'] == 'windows':
     16     env.Append(CPPDEFINES = [
     17         '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
     18         'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
     19     ])
     20     if env['gles']:
     21         env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])
     22     else:
     23         # prevent _glapi_* from being declared __declspec(dllimport)
     24         env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
     25 
     26 env.Append(CPPPATH = [
     27     '#/src/mapi',
     28     '#/src/mesa',
     29 ])
     30 
     31 glapi_sources = [
     32     'glapi_dispatch.c',
     33     'glapi_entrypoint.c',
     34     'glapi_getproc.c',
     35     'glapi_nop.c',
     36     'glthread.c',
     37     'glapi.c',
     38 ]
     39 
     40 mapi_sources = [
     41     'u_current.c',
     42     'u_execmem.c',
     43 ]
     44 for s in mapi_sources:
     45     o = env.SharedObject(s[:-2], '../mapi/' + s)
     46     glapi_sources.append(o)
     47 
     48 #
     49 # Assembly sources
     50 #
     51 if env['gcc'] and env['platform'] not in ('darwin', 'windows'):
     52     GLAPI = '#src/mapi/glapi/'
     53 
     54     if env['machine'] == 'x86':
     55         env.Append(CPPDEFINES = [
     56             'USE_X86_ASM',
     57         ])
     58         glapi_sources += [
     59             'glapi_x86.S',
     60         ]
     61         env.CodeGenerate(
     62             target = 'glapi_x86.S',
     63             script = GLAPI + 'gen/gl_x86_asm.py',
     64             source = GLAPI + 'gen/gl_API.xml',
     65             command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     66             )
     67     elif env['machine'] == 'x86_64':
     68         env.Append(CPPDEFINES = [
     69             'USE_X86_64_ASM',
     70         ])
     71         glapi_sources += [
     72             'glapi_x86-64.S'
     73         ]
     74         env.CodeGenerate(
     75             target = 'glapi_x86-64.S',
     76             script = GLAPI + 'gen/gl_x86-64_asm.py',
     77             source = GLAPI + 'gen/gl_API.xml',
     78             command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     79             )
     80     elif env['machine'] == 'sparc':
     81         env.Append(CPPDEFINES = [
     82             'USE_SPARC_ASM',
     83         ])
     84         glapi_sources += [
     85             'glapi_sparc.S'
     86         ]
     87         env.CodeGenerate(
     88             target = 'glapi_sparc.S',
     89             script = GLAPI + 'gen/gl_SPARC_asm.py',
     90             source = GLAPI + 'gen/gl_API.xml',
     91             command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
     92             )
     93     else:
     94         pass
     95 
     96 if env['toolchain'] == 'crossmingw':
     97     # compile these files without -gstabs option
     98     glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_dispatch.c")
     99     glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_getproc.c")
    100 
    101 glapi = env.ConvenienceLibrary(
    102     target = 'glapi',
    103     source = glapi_sources,
    104 )
    105 Export('glapi')
    106 
    107 
    108 env.Depends(glapi_sources, glapi_headers)
    109