detect.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "OSX"
  7. def can_build():
  8. if (sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ)):
  9. return True
  10. return False
  11. def get_opts():
  12. from SCons.Variables import EnumVariable
  13. return [
  14. ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'),
  15. EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')),
  16. ]
  17. def get_flags():
  18. return [
  19. ]
  20. def configure(env):
  21. ## Build type
  22. if (env["target"] == "release"):
  23. env.Prepend(CCFLAGS=['-O3', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
  24. if (env["debug_symbols"] == "yes"):
  25. env.Prepend(CCFLAGS=['-g1'])
  26. if (env["debug_symbols"] == "full"):
  27. env.Prepend(CCFLAGS=['-g2'])
  28. elif (env["target"] == "release_debug"):
  29. env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
  30. if (env["debug_symbols"] == "yes"):
  31. env.Prepend(CCFLAGS=['-g1'])
  32. if (env["debug_symbols"] == "full"):
  33. env.Prepend(CCFLAGS=['-g2'])
  34. elif (env["target"] == "debug"):
  35. env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  36. ## Architecture
  37. is64 = sys.maxsize > 2**32
  38. if (env["bits"] == "default"):
  39. env["bits"] = "64" if is64 else "32"
  40. ## Compiler configuration
  41. if (not os.environ.has_key("OSXCROSS_ROOT")): # regular native build
  42. if (env["bits"] == "fat"):
  43. env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  44. env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  45. elif (env["bits"] == "32"):
  46. env.Append(CCFLAGS=['-arch', 'i386'])
  47. env.Append(LINKFLAGS=['-arch', 'i386'])
  48. else: # 64-bit, default
  49. env.Append(CCFLAGS=['-arch', 'x86_64'])
  50. env.Append(LINKFLAGS=['-arch', 'x86_64'])
  51. else: # osxcross build
  52. root = os.environ.get("OSXCROSS_ROOT", 0)
  53. if env["bits"] == "fat":
  54. basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
  55. env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  56. env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  57. elif env["bits"] == "32":
  58. basecmd = root + "/target/bin/i386-apple-" + env["osxcross_sdk"] + "-"
  59. else: # 64-bit, default
  60. basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
  61. env['CC'] = basecmd + "cc"
  62. env['CXX'] = basecmd + "c++"
  63. env['AR'] = basecmd + "ar"
  64. env['RANLIB'] = basecmd + "ranlib"
  65. env['AS'] = basecmd + "as"
  66. if (env["CXX"] == "clang++"):
  67. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  68. env["CC"] = "clang"
  69. env["LD"] = "clang++"
  70. ## Dependencies
  71. if env['builtin_libtheora']:
  72. env["x86_libtheora_opt_gcc"] = True
  73. ## Flags
  74. env.Append(CPPPATH=['#platform/osx'])
  75. env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED'])
  76. env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
  77. env.Append(LIBS=['pthread'])
  78. env.Append(CPPFLAGS=['-mmacosx-version-min=10.9'])
  79. env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])