detect.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "iOS"
  7. def can_build():
  8. import sys
  9. if sys.platform == 'darwin':
  10. return True
  11. return False
  12. def get_opts():
  13. return [
  14. ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'),
  15. ('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
  16. ('IOS_SDK_VERSION', 'The SDK version', 'iPhoneOS'),
  17. ('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IOS_SDK_VERSION}.sdk/'),
  18. ('game_center', 'Support for game center', 'yes'),
  19. ('store_kit', 'Support for in-app store', 'yes'),
  20. ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'),
  21. ('ios_appirater', 'Enable Appirater', 'no'),
  22. ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'),
  23. ]
  24. def get_flags():
  25. return [
  26. ('tools', 'no'),
  27. ('webp', 'yes'),
  28. ('openssl','builtin'), #use builtin openssl
  29. ]
  30. def configure(env):
  31. env.Append(CPPPATH=['#platform/iphone', '#platform/iphone/include'])
  32. env['ENV']['PATH'] = env['IPHONEPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH']
  33. # env['CC'] = '$IPHONEPATH/Developer/usr/bin/gcc'
  34. # env['CXX'] = '$IPHONEPATH/Developer/usr/bin/g++'
  35. env['CC'] = '$IPHONEPATH/usr/bin/clang'
  36. env['CXX'] = '$IPHONEPATH/usr/bin/clang++'
  37. env['AR'] = 'ar'
  38. import string
  39. if (env["bits"]=="64"):
  40. #env['CCFLAGS'] = string.split('-arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -miphoneos-version-min=5.1.1 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -Wno-invalid-offsetof -ffast-math -m64 -DDEBUG -D_DEBUG -MMD -MT dependencies -isysroot $IPHONESDK')
  41. env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK')
  42. env.Append(CPPFLAGS=['-DNEED_LONG_INT'])
  43. env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
  44. else:
  45. env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=4.3 -MMD -MT dependencies -isysroot $IPHONESDK')
  46. if (env["bits"]=="64"):
  47. env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1',
  48. '-isysroot', '$IPHONESDK',
  49. #'-stdlib=libc++',
  50. '-framework', 'Foundation',
  51. '-framework', 'UIKit',
  52. '-framework', 'CoreGraphics',
  53. '-framework', 'OpenGLES',
  54. '-framework', 'QuartzCore',
  55. '-framework', 'CoreAudio',
  56. '-framework', 'AudioToolbox',
  57. '-framework', 'SystemConfiguration',
  58. '-framework', 'Security',
  59. #'-framework', 'AdSupport',
  60. '-framework', 'MediaPlayer',
  61. '-framework', 'AVFoundation',
  62. '-framework', 'CoreMedia',
  63. ])
  64. else:
  65. env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=4.3',
  66. '-isysroot', '$IPHONESDK',
  67. '-framework', 'Foundation',
  68. '-framework', 'UIKit',
  69. '-framework', 'CoreGraphics',
  70. '-framework', 'OpenGLES',
  71. '-framework', 'QuartzCore',
  72. '-framework', 'CoreAudio',
  73. '-framework', 'AudioToolbox',
  74. '-framework', 'SystemConfiguration',
  75. '-framework', 'Security',
  76. #'-framework', 'AdSupport',
  77. '-framework', 'MediaPlayer',
  78. '-framework', 'AVFoundation',
  79. '-framework', 'CoreMedia',
  80. ])
  81. if env['game_center'] == 'yes':
  82. env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED'])
  83. env.Append(LINKFLAGS=['-framework', 'GameKit'])
  84. if env['store_kit'] == 'yes':
  85. env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED'])
  86. env.Append(LINKFLAGS=['-framework', 'StoreKit'])
  87. env.Append(CPPPATH = ['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers'])
  88. if (env["target"]=="release"):
  89. env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall'])
  90. env.Append(LINKFLAGS=['-O3', '-ffast-math'])
  91. elif env["target"] == "release_debug":
  92. env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED'])
  93. env.Append(LINKFLAGS=['-Os', '-ffast-math'])
  94. env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
  95. elif (env["target"]=="debug"):
  96. env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED'])
  97. env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
  98. elif (env["target"]=="profile"):
  99. env.Append(CCFLAGS=['-g','-pg', '-Os', '-ffast-math'])
  100. env.Append(LINKFLAGS=['-pg'])
  101. env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
  102. env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT'])
  103. if env['ios_exceptions'] == 'yes':
  104. env.Append(CPPFLAGS=['-fexceptions'])
  105. else:
  106. env.Append(CPPFLAGS=['-fno-exceptions'])
  107. #env['neon_enabled']=True
  108. env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc'
  109. import methods
  110. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  111. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  112. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )