detect.py 3.6 KB

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