detect.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 os.environ.has_key("OSXCROSS_ROOT")):
  9. return True
  10. return False
  11. def get_opts():
  12. return [
  13. ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'),
  14. ]
  15. def get_flags():
  16. return [
  17. ]
  18. def configure(env):
  19. ## Build type
  20. if (env["target"] == "release"):
  21. env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
  22. elif (env["target"] == "release_debug"):
  23. env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
  24. elif (env["target"] == "debug"):
  25. env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
  26. ## Architecture
  27. is64 = sys.maxsize > 2**32
  28. if (env["bits"] == "default"):
  29. env["bits"] = "64" if is64 else "32"
  30. ## Compiler configuration
  31. if (not os.environ.has_key("OSXCROSS_ROOT")): # regular native build
  32. if (env["bits"] == "fat"):
  33. env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  34. env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
  35. elif (env["bits"] == "32"):
  36. env.Append(CCFLAGS=['-arch', 'i386'])
  37. env.Append(LINKFLAGS=['-arch', 'i386'])
  38. else: # 64-bit, default
  39. env.Append(CCFLAGS=['-arch', 'x86_64'])
  40. env.Append(LINKFLAGS=['-arch', 'x86_64'])
  41. else: # osxcross build
  42. root = os.environ.get("OSXCROSS_ROOT", 0)
  43. if env["bits"] == "64":
  44. basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
  45. else:
  46. basecmd = root + "/target/bin/i386-apple-" + env["osxcross_sdk"] + "-"
  47. env['CC'] = basecmd + "cc"
  48. env['CXX'] = basecmd + "c++"
  49. env['AR'] = basecmd + "ar"
  50. env['RANLIB'] = basecmd + "ranlib"
  51. env['AS'] = basecmd + "as"
  52. if (env["CXX"] == "clang++"):
  53. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  54. env["CC"] = "clang"
  55. env["LD"] = "clang++"
  56. ## Dependencies
  57. if (env['builtin_libtheora'] != 'no'):
  58. env["x86_libtheora_opt_gcc"] = True
  59. ## Flags
  60. env.Append(CPPPATH=['#platform/osx'])
  61. env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS'])
  62. env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
  63. env.Append(LIBS=['pthread'])
  64. env.Append(CPPFLAGS=['-mmacosx-version-min=10.9'])
  65. env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])