detect.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import os
  2. import sys
  3. import platform
  4. def is_active():
  5. return True
  6. def get_name():
  7. return "X11"
  8. def can_build():
  9. if (os.name!="posix"):
  10. return False
  11. if sys.platform == "darwin":
  12. return False # no x11 on mac for now
  13. errorval=os.system("pkg-config --version > /dev/null")
  14. if (errorval):
  15. print("pkg-config not found.. x11 disabled.")
  16. return False
  17. x11_error=os.system("pkg-config x11 --modversion > /dev/null ")
  18. if (x11_error):
  19. print("X11 not found.. x11 disabled.")
  20. return False
  21. ssl_error=os.system("pkg-config openssl --modversion > /dev/null ")
  22. if (ssl_error):
  23. print("OpenSSL not found.. x11 disabled.")
  24. return False
  25. x11_error=os.system("pkg-config xcursor --modversion > /dev/null ")
  26. if (x11_error):
  27. print("xcursor not found.. x11 disabled.")
  28. return False
  29. x11_error=os.system("pkg-config xinerama --modversion > /dev/null ")
  30. if (x11_error):
  31. print("xinerama not found.. x11 disabled.")
  32. return False
  33. return True # X11 enabled
  34. def get_opts():
  35. return [
  36. ('use_llvm','Use llvm compiler','no'),
  37. ('use_sanitizer','Use llvm compiler sanitize address','no'),
  38. ('use_leak_sanitizer','Use llvm compiler sanitize memory leaks','no'),
  39. ('pulseaudio','Detect & Use pulseaudio','yes'),
  40. ('new_wm_api', 'Use experimental window management API','no'),
  41. ('debug_release', 'Add debug symbols to release version','no'),
  42. ]
  43. def get_flags():
  44. return [
  45. ('builtin_zlib', 'no'),
  46. ("openssl", "yes"),
  47. #("theora","no"),
  48. ]
  49. def configure(env):
  50. is64=sys.maxsize > 2**32
  51. if (env["bits"]=="default"):
  52. if (is64):
  53. env["bits"]="64"
  54. else:
  55. env["bits"]="32"
  56. env.Append(CPPPATH=['#platform/x11'])
  57. if (env["use_llvm"]=="yes"):
  58. if 'clang++' not in env['CXX']:
  59. env["CC"]="clang"
  60. env["CXX"]="clang++"
  61. env["LD"]="clang++"
  62. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  63. env.extra_suffix=".llvm"
  64. if (env["colored"]=="yes"):
  65. if sys.stdout.isatty():
  66. env.Append(CXXFLAGS=["-fcolor-diagnostics"])
  67. if (env["use_sanitizer"]=="yes"):
  68. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  69. env.Append(LINKFLAGS=['-fsanitize=address'])
  70. env.extra_suffix+="s"
  71. if (env["use_leak_sanitizer"]=="yes"):
  72. env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
  73. env.Append(LINKFLAGS=['-fsanitize=address'])
  74. env.extra_suffix+="s"
  75. #if (env["tools"]=="no"):
  76. # #no tools suffix
  77. # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  78. # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  79. if (env["target"]=="release"):
  80. if (env["debug_release"]=="yes"):
  81. env.Append(CCFLAGS=['-g2'])
  82. else:
  83. env.Append(CCFLAGS=['-O3','-ffast-math'])
  84. elif (env["target"]=="release_debug"):
  85. env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
  86. if (env["debug_release"]=="yes"):
  87. env.Append(CCFLAGS=['-g2'])
  88. elif (env["target"]=="debug"):
  89. env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
  90. env.ParseConfig('pkg-config x11 --cflags --libs')
  91. env.ParseConfig('pkg-config xinerama --cflags --libs')
  92. env.ParseConfig('pkg-config xcursor --cflags --libs')
  93. if (env["openssl"]=="yes"):
  94. env.ParseConfig('pkg-config openssl --cflags --libs')
  95. if (env["freetype"]=="yes"):
  96. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  97. if (env["freetype"]!="no"):
  98. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  99. if (env["freetype"]=="builtin"):
  100. env.Append(CPPPATH=['#tools/freetype'])
  101. env.Append(CPPPATH=['#tools/freetype/freetype/include'])
  102. env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
  103. if platform.system() == 'Linux':
  104. env.Append(CPPFLAGS=["-DALSA_ENABLED"])
  105. env.Append(LIBS=['asound', 'evdev', 'udev'])
  106. if (env["pulseaudio"]=="yes"):
  107. if not os.system("pkg-config --exists libpulse-simple"):
  108. print("Enabling PulseAudio")
  109. env.Append(CPPFLAGS=["-DPULSEAUDIO_ENABLED"])
  110. env.ParseConfig('pkg-config --cflags --libs libpulse-simple')
  111. else:
  112. print("PulseAudio development libraries not found, disabling driver")
  113. env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
  114. env.Append(LIBS=['GL', 'GLU', 'pthread', 'z'])
  115. #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
  116. #host compiler is default..
  117. if (is64 and env["bits"]=="32"):
  118. env.Append(CPPFLAGS=['-m32'])
  119. env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
  120. elif (not is64 and env["bits"]=="64"):
  121. env.Append(CPPFLAGS=['-m64'])
  122. env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
  123. import methods
  124. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  125. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  126. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  127. #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
  128. if(env["new_wm_api"]=="yes"):
  129. env.Append(CPPFLAGS=['-DNEW_WM_API'])
  130. env.ParseConfig('pkg-config xinerama --cflags --libs')
  131. env["x86_opt_gcc"]=True