detect.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "Haiku"
  7. def can_build():
  8. if os.name != "posix" or sys.platform == "darwin":
  9. return False
  10. return True
  11. def get_opts():
  12. from SCons.Variables import EnumVariable
  13. return [
  14. EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")),
  15. ]
  16. def get_flags():
  17. return []
  18. def configure(env):
  19. ## Build type
  20. if env["target"] == "release":
  21. env.Prepend(CCFLAGS=["-O3"])
  22. if env["debug_symbols"] == "yes":
  23. env.Prepend(CCFLAGS=["-g1"])
  24. if env["debug_symbols"] == "full":
  25. env.Prepend(CCFLAGS=["-g2"])
  26. elif env["target"] == "release_debug":
  27. env.Prepend(CCFLAGS=["-O2", "-DDEBUG_ENABLED"])
  28. if env["debug_symbols"] == "yes":
  29. env.Prepend(CCFLAGS=["-g1"])
  30. if env["debug_symbols"] == "full":
  31. env.Prepend(CCFLAGS=["-g2"])
  32. elif env["target"] == "debug":
  33. env.Prepend(CCFLAGS=["-g3", "-DDEBUG_ENABLED", "-DDEBUG_MEMORY_ENABLED"])
  34. ## Architecture
  35. is64 = sys.maxsize > 2 ** 32
  36. if env["bits"] == "default":
  37. env["bits"] = "64" if is64 else "32"
  38. ## Compiler configuration
  39. env["CC"] = "gcc-x86"
  40. env["CXX"] = "g++-x86"
  41. ## Dependencies
  42. if not env["builtin_libwebp"]:
  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"] or env["builtin_libpng"] or env["builtin_zlib"]:
  47. env["builtin_freetype"] = True
  48. env["builtin_libpng"] = True
  49. env["builtin_zlib"] = True
  50. if not env["builtin_freetype"]:
  51. env.ParseConfig("pkg-config freetype2 --cflags --libs")
  52. if not env["builtin_libpng"]:
  53. env.ParseConfig("pkg-config libpng16 --cflags --libs")
  54. if not env["builtin_bullet"]:
  55. # We need at least version 2.88
  56. import subprocess
  57. bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip()
  58. if bullet_version < "2.88":
  59. # Abort as system bullet was requested but too old
  60. print(
  61. "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(
  62. bullet_version, "2.88"
  63. )
  64. )
  65. sys.exit(255)
  66. env.ParseConfig("pkg-config bullet --cflags --libs")
  67. if not env["builtin_enet"]:
  68. env.ParseConfig("pkg-config libenet --cflags --libs")
  69. if not env["builtin_squish"]:
  70. env.ParseConfig("pkg-config libsquish --cflags --libs")
  71. if not env["builtin_zstd"]:
  72. env.ParseConfig("pkg-config libzstd --cflags --libs")
  73. # Sound and video libraries
  74. # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
  75. if not env["builtin_libtheora"]:
  76. env["builtin_libogg"] = False # Needed to link against system libtheora
  77. env["builtin_libvorbis"] = False # Needed to link against system libtheora
  78. env.ParseConfig("pkg-config theora theoradec --cflags --libs")
  79. if not env["builtin_libvpx"]:
  80. env.ParseConfig("pkg-config vpx --cflags --libs")
  81. if not env["builtin_libvorbis"]:
  82. env["builtin_libogg"] = False # Needed to link against system libvorbis
  83. env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
  84. if not env["builtin_opus"]:
  85. env["builtin_libogg"] = False # Needed to link against system opus
  86. env.ParseConfig("pkg-config opus opusfile --cflags --libs")
  87. if not env["builtin_libogg"]:
  88. env.ParseConfig("pkg-config ogg --cflags --libs")
  89. if env["builtin_libtheora"]:
  90. list_of_x86 = ["x86_64", "x86", "i386", "i586"]
  91. if any(platform.machine() in s for s in list_of_x86):
  92. env["x86_libtheora_opt_gcc"] = True
  93. if not env["builtin_wslay"]:
  94. env.ParseConfig("pkg-config libwslay --cflags --libs")
  95. if not env["builtin_mbedtls"]:
  96. # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
  97. env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
  98. if not env["builtin_miniupnpc"]:
  99. # No pkgconfig file so far, hardcode default paths.
  100. env.Prepend(CPPPATH=["/system/develop/headers/x86/miniupnpc"])
  101. env.Append(LIBS=["miniupnpc"])
  102. # On Linux wchar_t should be 32-bits
  103. # 16-bit library shouldn't be required due to compiler optimisations
  104. if not env["builtin_pcre2"]:
  105. env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
  106. ## Flags
  107. env.Prepend(CPPPATH=["#platform/haiku"])
  108. env.Append(CPPDEFINES=["UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED"])
  109. env.Append(CPPDEFINES=["MEDIA_KIT_ENABLED"])
  110. env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) # TODO: enable when we have pthread_setname_np
  111. env.Append(LIBS=["be", "game", "media", "network", "bnetapi", "z", "GL"])