detect.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "Server"
  7. def can_build():
  8. if (os.name != "posix" or sys.platform == "darwin"):
  9. return False
  10. return True
  11. def get_opts():
  12. return [
  13. ('use_llvm', 'Use the LLVM compiler', 'no'),
  14. ]
  15. def get_flags():
  16. return [
  17. ]
  18. def configure(env):
  19. ## Build type
  20. if (env["target"] == "release"):
  21. env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
  22. elif (env["target"] == "release_debug"):
  23. env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
  24. elif (env["target"] == "debug"):
  25. env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  26. ## Architecture
  27. is64 = sys.maxsize > 2**32
  28. if (env["bits"] == "default"):
  29. env["bits"] = "64" if is64 else "32"
  30. ## Compiler configuration
  31. if (env["use_llvm"] == "yes"):
  32. if ('clang++' not in env['CXX']):
  33. env["CC"] = "clang"
  34. env["CXX"] = "clang++"
  35. env["LD"] = "clang++"
  36. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  37. env.extra_suffix = ".llvm" + env.extra_suffix
  38. ## Dependencies
  39. # FIXME: Check for existence of the libs before parsing their flags with pkg-config
  40. if (env['builtin_openssl'] == 'no'):
  41. env.ParseConfig('pkg-config openssl --cflags --libs')
  42. if (env['builtin_libwebp'] == 'no'):
  43. env.ParseConfig('pkg-config libwebp --cflags --libs')
  44. # freetype depends on libpng and zlib, so bundling one of them while keeping others
  45. # as shared libraries leads to weird issues
  46. if (env['builtin_freetype'] == 'yes' or env['builtin_libpng'] == 'yes' or env['builtin_zlib'] == 'yes'):
  47. env['builtin_freetype'] = 'yes'
  48. env['builtin_libpng'] = 'yes'
  49. env['builtin_zlib'] = 'yes'
  50. if (env['builtin_freetype'] == 'no'):
  51. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  52. if (env['builtin_libpng'] == 'no'):
  53. env.ParseConfig('pkg-config libpng --cflags --libs')
  54. if (env['builtin_enet'] == 'no'):
  55. env.ParseConfig('pkg-config libenet --cflags --libs')
  56. if (env['builtin_squish'] == 'no' and env["tools"] == "yes"):
  57. env.ParseConfig('pkg-config libsquish --cflags --libs')
  58. # Sound and video libraries
  59. # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
  60. if (env['builtin_libtheora'] == 'no'):
  61. env['builtin_libogg'] = 'no' # Needed to link against system libtheora
  62. env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora
  63. env.ParseConfig('pkg-config theora theoradec --cflags --libs')
  64. if (env['builtin_libvpx'] == 'no'):
  65. env.ParseConfig('pkg-config vpx --cflags --libs')
  66. if (env['builtin_libvorbis'] == 'no'):
  67. env['builtin_libogg'] = 'no' # Needed to link against system libvorbis
  68. env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')
  69. if (env['builtin_opus'] == 'no'):
  70. env['builtin_libogg'] = 'no' # Needed to link against system opus
  71. env.ParseConfig('pkg-config opus opusfile --cflags --libs')
  72. if (env['builtin_libogg'] == 'no'):
  73. env.ParseConfig('pkg-config ogg --cflags --libs')
  74. ## Flags
  75. # Linkflags below this line should typically stay the last ones
  76. if (env['builtin_zlib'] == 'no'):
  77. env.ParseConfig('pkg-config zlib --cflags --libs')
  78. env.Append(CPPPATH=['#platform/server'])
  79. env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
  80. env.Append(LIBS=['pthread'])