detect.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import os
  2. import sys
  3. import string
  4. def is_active():
  5. return True
  6. def get_name():
  7. return "JavaScript"
  8. def can_build():
  9. import os
  10. return os.environ.has_key("EMSCRIPTEN_ROOT")
  11. def get_opts():
  12. return [
  13. ['wasm', 'Compile to WebAssembly', 'no'],
  14. ['javascript_eval', 'Enable JavaScript eval interface', 'yes'],
  15. ]
  16. def get_flags():
  17. return [
  18. ('tools', 'no'),
  19. ('module_etc1_enabled', 'no'),
  20. ('module_mpc_enabled', 'no'),
  21. ('module_theora_enabled', 'no'),
  22. ]
  23. def configure(env):
  24. env['ENV'] = os.environ
  25. env.use_windows_spawn_fix('javascript')
  26. env.Append(CPPPATH=['#platform/javascript'])
  27. em_path = os.environ["EMSCRIPTEN_ROOT"]
  28. env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH']
  29. env['CC'] = em_path + '/emcc'
  30. env['CXX'] = em_path + '/em++'
  31. env['LINK'] = em_path + '/emcc'
  32. env['AR'] = em_path + '/emar'
  33. env['RANLIB'] = em_path + '/emranlib'
  34. env['OBJSUFFIX'] = '.bc'
  35. env['LIBSUFFIX'] = '.a'
  36. if (env["target"] == "release"):
  37. env.Append(CCFLAGS=['-O2'])
  38. elif (env["target"] == "release_debug"):
  39. env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
  40. elif (env["target"] == "debug"):
  41. env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED'])
  42. #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED'])
  43. env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
  44. # TODO: Move that to opus module's config
  45. if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
  46. env.opus_fixed_point = "yes"
  47. # These flags help keep the file size down
  48. env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti'])
  49. env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
  50. env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
  51. env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS'])
  52. if env['wasm'] == 'yes':
  53. env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
  54. # Maximum memory size is baked into the WebAssembly binary during
  55. # compilation, so we need to enable memory growth to allow setting
  56. # TOTAL_MEMORY at runtime. The value set at runtime must be higher than
  57. # what is set during compilation, check TOTAL_MEMORY in Emscripten's
  58. # src/settings.js for the default.
  59. env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
  60. env.extra_suffix = '.webassembly' + env.extra_suffix
  61. else:
  62. env.Append(CPPFLAGS=['-s', 'ASM_JS=1'])
  63. env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
  64. env.Append(LINKFLAGS=['--separate-asm'])
  65. if env['javascript_eval'] == 'yes':
  66. env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
  67. env.Append(LINKFLAGS=['-O2'])
  68. env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
  69. # env.Append(LINKFLAGS=['-g4'])
  70. import methods