detect.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. ]
  19. def configure(env):
  20. ## Build type
  21. if (env["target"] == "release"):
  22. env.Prepend(CCFLAGS=['-O3', '-ffast-math'])
  23. if (env["debug_symbols"] == "yes"):
  24. env.Prepend(CCFLAGS=['-g1'])
  25. if (env["debug_symbols"] == "full"):
  26. env.Prepend(CCFLAGS=['-g2'])
  27. elif (env["target"] == "release_debug"):
  28. env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
  29. if (env["debug_symbols"] == "yes"):
  30. env.Prepend(CCFLAGS=['-g1'])
  31. if (env["debug_symbols"] == "full"):
  32. env.Prepend(CCFLAGS=['-g2'])
  33. elif (env["target"] == "debug"):
  34. env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  35. ## Architecture
  36. is64 = sys.maxsize > 2**32
  37. if (env["bits"] == "default"):
  38. env["bits"] = "64" if is64 else "32"
  39. ## Compiler configuration
  40. env["CC"] = "gcc-x86"
  41. env["CXX"] = "g++-x86"
  42. ## Dependencies
  43. if not env['builtin_libwebp']:
  44. env.ParseConfig('pkg-config libwebp --cflags --libs')
  45. # freetype depends on libpng and zlib, so bundling one of them while keeping others
  46. # as shared libraries leads to weird issues
  47. if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']:
  48. env['builtin_freetype'] = True
  49. env['builtin_libpng'] = True
  50. env['builtin_zlib'] = True
  51. if not env['builtin_freetype']:
  52. env.ParseConfig('pkg-config freetype2 --cflags --libs')
  53. if not env['builtin_libpng']:
  54. env.ParseConfig('pkg-config libpng --cflags --libs')
  55. if not env['builtin_bullet']:
  56. # We need at least version 2.88
  57. import subprocess
  58. bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip()
  59. if bullet_version < "2.88":
  60. # Abort as system bullet was requested but too old
  61. print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88"))
  62. sys.exit(255)
  63. env.ParseConfig('pkg-config bullet --cflags --libs')
  64. if not env['builtin_enet']:
  65. env.ParseConfig('pkg-config libenet --cflags --libs')
  66. if not env['builtin_squish'] and env['tools']:
  67. env.ParseConfig('pkg-config libsquish --cflags --libs')
  68. if not env['builtin_zstd']:
  69. env.ParseConfig('pkg-config libzstd --cflags --libs')
  70. # Sound and video libraries
  71. # Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
  72. if not env['builtin_libtheora']:
  73. env['builtin_libogg'] = False # Needed to link against system libtheora
  74. env['builtin_libvorbis'] = False # Needed to link against system libtheora
  75. env.ParseConfig('pkg-config theora theoradec --cflags --libs')
  76. if not env['builtin_libvpx']:
  77. env.ParseConfig('pkg-config vpx --cflags --libs')
  78. if not env['builtin_libvorbis']:
  79. env['builtin_libogg'] = False # Needed to link against system libvorbis
  80. env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs')
  81. if not env['builtin_opus']:
  82. env['builtin_libogg'] = False # Needed to link against system opus
  83. env.ParseConfig('pkg-config opus opusfile --cflags --libs')
  84. if not env['builtin_libogg']:
  85. env.ParseConfig('pkg-config ogg --cflags --libs')
  86. if env['builtin_libtheora']:
  87. list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
  88. if any(platform.machine() in s for s in list_of_x86):
  89. env["x86_libtheora_opt_gcc"] = True
  90. if not env['builtin_libwebsockets']:
  91. env.ParseConfig('pkg-config libwebsockets --cflags --libs')
  92. if not env['builtin_mbedtls']:
  93. # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
  94. env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509'])
  95. if not env['builtin_miniupnpc']:
  96. # No pkgconfig file so far, hardcode default paths.
  97. env.Append(CPPPATH=["/system/develop/headers/x86/miniupnpc"])
  98. env.Append(LIBS=["miniupnpc"])
  99. # On Linux wchar_t should be 32-bits
  100. # 16-bit library shouldn't be required due to compiler optimisations
  101. if not env['builtin_pcre2']:
  102. env.ParseConfig('pkg-config libpcre2-32 --cflags --libs')
  103. ## Flags
  104. env.Append(CPPPATH=['#platform/haiku'])
  105. env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES_ENABLED'])
  106. env.Append(CPPFLAGS=['-DMEDIA_KIT_ENABLED'])
  107. # env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  108. env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
  109. env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL'])