1 ####################################################################### 2 # SConscript for Mesa 3 4 5 Import('*') 6 from sys import executable as python_cmd 7 8 env = env.Clone() 9 10 env.MSVC2013Compat() 11 12 env.Append(CPPPATH = [ 13 '../compiler/nir', # for generated nir_opcodes.h, etc 14 '../compiler/glsl', # for generated headers 15 '#/src', 16 Dir('../mapi'), # src/mapi build path 17 '#/src/mapi', 18 Dir('.'), # src/mesa build path 19 '#/src/mesa', 20 Dir('main'), # src/mesa/main/ build path 21 '#/src/mesa/main', 22 '#/src/gallium/include', 23 '#/src/gallium/auxiliary', 24 ]) 25 26 if env['platform'] == 'windows': 27 env.Append(CPPDEFINES = [ 28 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers 29 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers 30 ]) 31 if not env['gles']: 32 # prevent _glapi_* from being declared __declspec(dllimport) 33 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) 34 35 # parse Makefile.sources 36 source_lists = env.ParseSourceList('Makefile.sources') 37 38 env.Append(YACCFLAGS = ['-d', '-p', '_mesa_program_']) 39 env.CFile('program/lex.yy.c', 'program/program_lexer.l') 40 env.CFile('program/program_parse.tab.c', 'program/program_parse.y') 41 42 mesa_sources = ( 43 source_lists['MESA_FILES'] + 44 source_lists['PROGRAM_FILES'] + 45 source_lists['STATETRACKER_FILES'] 46 ) 47 48 GLAPI = '#src/mapi/glapi/' 49 50 get_hash_header = env.CodeGenerate( 51 target = 'main/get_hash.h', 52 script = 'main/get_hash_generator.py', 53 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), 54 command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET' 55 ) 56 57 format_info = env.CodeGenerate( 58 target = 'main/format_info.h', 59 script = 'main/format_info.py', 60 source = 'main/formats.csv', 61 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' 62 ) 63 64 format_pack = env.CodeGenerate( 65 target = 'main/format_pack.c', 66 script = 'main/format_pack.py', 67 source = 'main/formats.csv', 68 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' 69 ) 70 71 format_unpack = env.CodeGenerate( 72 target = 'main/format_unpack.c', 73 script = 'main/format_unpack.py', 74 source = 'main/formats.csv', 75 command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' 76 ) 77 78 format_fallback = env.CodeGenerate( 79 target = 'main/format_fallback.c', 80 script = 'main/format_fallback.py', 81 source = 'main/formats.csv', 82 command = python_cmd + ' $SCRIPT ' + ' $SOURCE ' + ' $TARGET' 83 ) 84 85 # 86 # Assembly sources 87 # 88 if env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'): 89 if env['machine'] == 'x86': 90 env.Append(CPPDEFINES = [ 91 'USE_X86_ASM', 92 'USE_MMX_ASM', 93 'USE_3DNOW_ASM', 94 'USE_SSE_ASM', 95 ]) 96 mesa_sources += source_lists['X86_FILES'] 97 elif env['machine'] == 'x86_64': 98 env.Append(CPPDEFINES = [ 99 'USE_X86_64_ASM', 100 ]) 101 mesa_sources += source_lists['X86_64_FILES'] 102 elif env['machine'] == 'sparc': 103 mesa_sources += source_lists['SPARC_FILES'] 104 else: 105 pass 106 107 # Generate matypes.h 108 if env['machine'] in ('x86', 'x86_64'): 109 # See http://www.scons.org/wiki/UsingCodeGenerators 110 gen_matypes = env.Program( 111 target = 'gen_matypes', 112 source = 'x86/gen_matypes.c', 113 ) 114 matypes = env.Command( 115 'matypes.h', 116 gen_matypes, 117 gen_matypes[0].abspath + ' > $TARGET', 118 ) 119 # Add the dir containing the generated header (somewhere inside the 120 # build dir) to the include path 121 env.Prepend(CPPPATH = [matypes[0].dir]) 122 123 124 # The marshal_generated.c file is generated from the GL/ES API.xml file 125 env.CodeGenerate( 126 target = 'main/marshal_generated.c', 127 script = GLAPI + 'gen/gl_marshal.py', 128 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), 129 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET' 130 ) 131 132 # The marshal_generated.h file is generated from the GL/ES API.xml file 133 env.CodeGenerate( 134 target = 'main/marshal_generated.h', 135 script = GLAPI + 'gen/gl_marshal_h.py', 136 source = [GLAPI + 'gen/gl_and_es_API.xml'] + env.Glob(GLAPI + 'gen/*.xml'), 137 command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET' 138 ) 139 140 # 141 # Libraries 142 # 143 144 mesa = env.ConvenienceLibrary( 145 target = 'mesa', 146 source = mesa_sources, 147 ) 148 149 env.Alias('mesa', mesa) 150 151 Export('mesa') 152 153 SConscript('drivers/SConscript') 154