Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SConscript 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #######################################################################
  2. # SConscript for Mesa
  3. Import('*')
  4. import filecmp
  5. import os
  6. import subprocess
  7. from sys import executable as python_cmd
  8. env = env.Clone()
  9. env.Append(CPPPATH = [
  10. '#/src',
  11. '#/src/mapi',
  12. '#/src/glsl',
  13. '#/src/mesa',
  14. '#/src/gallium/include',
  15. '#/src/gallium/auxiliary',
  16. Dir('../mapi'), # src/mapi build path
  17. Dir('.'), # src/mesa build path
  18. ])
  19. if env['platform'] == 'windows':
  20. env.Append(CPPDEFINES = [
  21. '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
  22. 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
  23. ])
  24. if not env['gles']:
  25. # prevent _glapi_* from being declared __declspec(dllimport)
  26. env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
  27. else:
  28. env.Append(CPPDEFINES = [
  29. ('HAVE_DLOPEN', '1'),
  30. ])
  31. # parse Makefile.sources
  32. source_lists = env.ParseSourceList('Makefile.sources')
  33. env.Append(YACCFLAGS = '-d -p "_mesa_program_"')
  34. program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
  35. program_parse = env.CFile('program/program_parse.tab.c',
  36. 'program/program_parse.y')
  37. program_sources = source_lists['PROGRAM_FILES'] + [
  38. program_lex,
  39. program_parse[0],
  40. ]
  41. mesa_sources = (
  42. source_lists['MESA_FILES'] +
  43. program_sources +
  44. source_lists['STATETRACKER_FILES']
  45. )
  46. GLAPI = '#src/mapi/glapi/'
  47. get_hash_header = env.CodeGenerate(
  48. target = 'main/get_hash.h',
  49. script = 'main/get_hash_generator.py',
  50. source = GLAPI + 'gen/gl_and_es_API.xml',
  51. command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
  52. )
  53. format_info = env.CodeGenerate(
  54. target = 'main/format_info.c',
  55. script = 'main/format_info.py',
  56. source = 'main/formats.csv',
  57. command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
  58. )
  59. format_pack = env.CodeGenerate(
  60. target = 'main/format_pack.c',
  61. script = 'main/format_pack.py',
  62. source = 'main/formats.csv',
  63. command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
  64. )
  65. format_unpack = env.CodeGenerate(
  66. target = 'main/format_unpack.c',
  67. script = 'main/format_unpack.py',
  68. source = 'main/formats.csv',
  69. command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
  70. )
  71. #
  72. # Assembly sources
  73. #
  74. if (env['gcc'] or env['clang']) and \
  75. env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'):
  76. if env['machine'] == 'x86':
  77. env.Append(CPPDEFINES = [
  78. 'USE_X86_ASM',
  79. 'USE_MMX_ASM',
  80. 'USE_3DNOW_ASM',
  81. 'USE_SSE_ASM',
  82. ])
  83. mesa_sources += source_lists['X86_FILES']
  84. elif env['machine'] == 'x86_64':
  85. env.Append(CPPDEFINES = [
  86. 'USE_X86_64_ASM',
  87. ])
  88. mesa_sources += source_lists['X86_64_FILES']
  89. elif env['machine'] == 'sparc':
  90. mesa_sources += source_lists['SPARC_FILES']
  91. else:
  92. pass
  93. # Generate matypes.h
  94. if env['machine'] in ('x86', 'x86_64'):
  95. # See http://www.scons.org/wiki/UsingCodeGenerators
  96. gen_matypes = env.Program(
  97. target = 'gen_matypes',
  98. source = 'x86/gen_matypes.c',
  99. )
  100. matypes = env.Command(
  101. 'matypes.h',
  102. gen_matypes,
  103. gen_matypes[0].abspath + ' > $TARGET',
  104. )
  105. # Add the dir containing the generated header (somewhere inside the
  106. # build dir) to the include path
  107. env.Append(CPPPATH = [matypes[0].dir])
  108. def write_git_sha1_h_file(filename):
  109. """Mesa looks for a git_sha1.h file at compile time in order to display
  110. the current git hash id in the GL_VERSION string. This function tries
  111. to retrieve the git hashid and write the header file. An empty file
  112. will be created if anything goes wrong."""
  113. args = [ 'git', 'log', '-n', '1', '--oneline' ]
  114. try:
  115. (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
  116. except:
  117. # git log command didn't work
  118. if not os.path.exists(filename):
  119. # create an empty file if none already exists
  120. f = open(filename, "w")
  121. f.close()
  122. return
  123. commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
  124. tempfile = "git_sha1.h.tmp"
  125. f = open(tempfile, "w")
  126. f.write(commit)
  127. f.close()
  128. if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
  129. # The filename does not exist or it's different from the new file,
  130. # so replace old file with new.
  131. if os.path.exists(filename):
  132. os.remove(filename)
  133. os.rename(tempfile, filename)
  134. return
  135. # Create the git_sha1.h header file
  136. write_git_sha1_h_file("main/git_sha1.h")
  137. # and update CPPPATH so the git_sha1.h header can be found
  138. env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
  139. #
  140. # Libraries
  141. #
  142. mesa = env.ConvenienceLibrary(
  143. target = 'mesa',
  144. source = mesa_sources,
  145. )
  146. env.Alias('mesa', mesa)
  147. Export('mesa')
  148. SConscript('drivers/SConscript')