detect.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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"):
  9. return False
  10. return True # enabled
  11. def get_opts():
  12. return [
  13. ('use_llvm', 'Use llvm compiler', 'no'),
  14. ('force_32_bits', 'Force 32 bits binary', 'no')
  15. ]
  16. def get_flags():
  17. return [
  18. ]
  19. def configure(env):
  20. env.Append(CPPPATH=['#platform/server'])
  21. if (env["use_llvm"] == "yes"):
  22. env["CC"] = "clang"
  23. env["CXX"] = "clang++"
  24. env["LD"] = "clang++"
  25. is64 = sys.maxsize > 2**32
  26. if (env["bits"] == "default"):
  27. if (is64):
  28. env["bits"] = "64"
  29. else:
  30. env["bits"] = "32"
  31. # if (env["tools"]=="no"):
  32. # #no tools suffix
  33. # env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  34. # env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  35. if (env["target"] == "release"):
  36. env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
  37. elif (env["target"] == "release_debug"):
  38. env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
  39. elif (env["target"] == "debug"):
  40. env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  41. # Shared libraries, when requested
  42. if (env['builtin_openssl'] == 'no'):
  43. env.ParseConfig('pkg-config openssl --cflags --libs')
  44. if (env['builtin_libwebp'] == 'no'):
  45. env.ParseConfig('pkg-config libwebp --cflags --libs')
  46. if (env['builtin_freetype'] == 'no'):
  47. env['builtin_libpng'] = 'no' # Freetype links against libpng
  48. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  49. if (env['builtin_libpng'] == 'no'):
  50. env.ParseConfig('pkg-config libpng16 --cflags --libs')
  51. # Sound and video libraries
  52. # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
  53. if (env['builtin_libtheora'] == 'no'):
  54. env['builtin_libogg'] = 'no' # Needed to link against system libtheora
  55. env['builtin_libvorbis'] = 'no' # Needed to link against system libtheora
  56. env.ParseConfig('pkg-config theora theoradec --cflags --libs')
  57. if (env['builtin_libvorbis'] == 'no'):
  58. env['builtin_libogg'] = 'no' # Needed to link against system libvorbis
  59. env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')
  60. if (env['builtin_opus'] == 'no'):
  61. env['builtin_libogg'] = 'no' # Needed to link against system opus
  62. env.ParseConfig('pkg-config opus opusfile --cflags --libs')
  63. if (env['builtin_libogg'] == 'no'):
  64. env.ParseConfig('pkg-config ogg --cflags --libs')
  65. env.Append(CPPFLAGS=['-DSERVER_ENABLED', '-DUNIX_ENABLED'])
  66. env.Append(LIBS=['pthread', 'z']) # TODO detect linux/BSD!
  67. if (env["CXX"] == "clang++"):
  68. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  69. env["CC"] = "clang"
  70. env["LD"] = "clang++"