detect.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. ('force_64_bits','Force 64 bits binary','no'),
  14. ('osxcross_sdk','OSXCross SDK version','darwin14'),
  15. ]
  16. def get_flags():
  17. return [
  18. ('opengl', 'no'),
  19. ('legacygl', 'yes'),
  20. ('builtin_zlib', 'no'),
  21. ('freetype','builtin'), #use builtin freetype
  22. ]
  23. def configure(env):
  24. env.Append(CPPPATH=['#platform/osx'])
  25. if (env["bits"]=="default"):
  26. env["bits"]="32"
  27. if (env["target"]=="release"):
  28. env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer','-ftree-vectorize','-msse2'])
  29. elif (env["target"]=="release_debug"):
  30. env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
  31. elif (env["target"]=="debug"):
  32. env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
  33. if (env["freetype"]!="no"):
  34. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  35. env.Append(CPPPATH=['#tools/freetype'])
  36. env.Append(CPPPATH=['#tools/freetype/freetype/include'])
  37. if (not os.environ.has_key("OSXCROSS_ROOT")):
  38. #regular native build
  39. if (env["bits"]=="64"):
  40. env.Append(CCFLAGS=['-arch', 'x86_64'])
  41. env.Append(LINKFLAGS=['-arch', 'x86_64'])
  42. else:
  43. env.Append(CCFLAGS=['-arch', 'i386'])
  44. env.Append(LINKFLAGS=['-arch', 'i386'])
  45. else:
  46. #osxcross build
  47. root=os.environ.get("OSXCROSS_ROOT",0)
  48. if env["bits"]=="64":
  49. basecmd=root+"/target/bin/x86_64-apple-"+env["osxcross_sdk"]+"-"
  50. else:
  51. basecmd=root+"/target/bin/i386-apple-"+env["osxcross_sdk"]+"-"
  52. env['CC'] = basecmd+"cc"
  53. env['CXX'] = basecmd+"c++"
  54. env['AR'] = basecmd+"ar"
  55. env['RANLIB'] = basecmd+"ranlib"
  56. env['AS'] = basecmd+"as"
  57. # env.Append(CPPPATH=['#platform/osx/include/freetype2', '#platform/osx/include'])
  58. # env.Append(LIBPATH=['#platform/osx/lib'])
  59. #if env['opengl'] == 'yes':
  60. # env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
  61. env.Append(CPPFLAGS=["-DAPPLE_STYLE_KEYS"])
  62. env.Append(CPPFLAGS=['-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLEW_ENABLED', '-DOSX_ENABLED'])
  63. env.Append(LIBS=['pthread'])
  64. #env.Append(CPPFLAGS=['-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-mmacosx-version-min=10.4'])
  65. #env.Append(LINKFLAGS=['-mmacosx-version-min=10.4', '-isysroot', '/Developer/SDKs/MacOSX10.4u.sdk', '-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'])
  66. env.Append(LINKFLAGS=['-g3', '-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit','-lz'])
  67. if (env["CXX"]=="clang++"):
  68. env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
  69. env["CC"]="clang"
  70. env["LD"]="clang++"
  71. if (env["colored"]=="yes"):
  72. if sys.stdout.isatty():
  73. env.Append(CPPFLAGS=["-fcolor-diagnostics"])
  74. import methods
  75. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  76. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  77. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  78. #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
  79. env["x86_opt_gcc"]=True