detect.py 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import os
  10. if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"):
  11. return True
  12. return False
  13. def get_opts():
  14. return [
  15. ('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'),
  16. ('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
  17. ('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/${IPHONEPLATFORM}.platform/Developer/SDKs/${IPHONEPLATFORM}.sdk/'),
  18. ('game_center', 'Support for game center', 'yes'),
  19. ('store_kit', 'Support for in-app store', 'yes'),
  20. ('icloud', 'Support for iCloud', 'yes'),
  21. ('ios_gles22_override', 'Force GLES2.0 on iOS', 'yes'),
  22. ('ios_appirater', 'Enable Appirater', 'no'),
  23. ('ios_exceptions', 'Use exceptions when compiling on playbook', 'yes'),
  24. ('ios_triple', 'Triple for ios toolchain', ''),
  25. ('ios_sim', 'Build simulator binary', 'no'),
  26. ]
  27. def get_flags():
  28. return [
  29. ('tools', 'no'),
  30. ('webp', 'yes'),
  31. ('openssl','builtin'), #use builtin openssl
  32. ]
  33. def configure(env):
  34. env.Append(CPPPATH=['#platform/iphone'])
  35. env['ENV']['PATH'] = env['IPHONEPATH']+"/Developer/usr/bin/:"+env['ENV']['PATH']
  36. env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang'
  37. env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++'
  38. env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar'
  39. env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib'
  40. import string
  41. if (env["ios_sim"]=="yes" or env["arch"] == "x86"): # i386, simulator
  42. env["arch"]="x86"
  43. env["bits"]="32"
  44. env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"')
  45. elif (env["arch"]=="arm64"): # arm64
  46. env["bits"] = "64"
  47. 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 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK')
  48. env.Append(CPPFLAGS=['-DNEED_LONG_INT'])
  49. env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
  50. else: # armv7
  51. env["arch"] = "arm"
  52. env["bits"] = "32"
  53. 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 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK')
  54. if (env["arch"]=="x86"):
  55. env['IPHONEPLATFORM'] = 'iPhoneSimulator'
  56. env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3',
  57. '-isysroot', '$IPHONESDK',
  58. #'-mmacosx-version-min=10.6',
  59. '-Xlinker',
  60. '-objc_abi_version',
  61. '-Xlinker', '2',
  62. '-framework', 'AudioToolbox',
  63. '-framework', 'AVFoundation',
  64. '-framework', 'CoreAudio',
  65. '-framework', 'CoreGraphics',
  66. '-framework', 'CoreMedia',
  67. '-framework', 'Foundation',
  68. '-framework', 'Security',
  69. '-framework', 'UIKit',
  70. '-framework', 'MediaPlayer',
  71. '-framework', 'OpenGLES',
  72. '-framework', 'QuartzCore',
  73. '-framework', 'SystemConfiguration',
  74. '-F$IPHONESDK',
  75. ])
  76. elif (env["arch"]=="arm64"):
  77. env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1',
  78. '-isysroot', '$IPHONESDK',
  79. #'-stdlib=libc++',
  80. '-framework', 'Foundation',
  81. '-framework', 'UIKit',
  82. '-framework', 'CoreGraphics',
  83. '-framework', 'OpenGLES',
  84. '-framework', 'QuartzCore',
  85. '-framework', 'CoreAudio',
  86. '-framework', 'AudioToolbox',
  87. '-framework', 'SystemConfiguration',
  88. '-framework', 'Security',
  89. #'-framework', 'AdSupport',
  90. '-framework', 'MediaPlayer',
  91. '-framework', 'AVFoundation',
  92. '-framework', 'CoreMedia',
  93. ])
  94. else:
  95. env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1',
  96. '-isysroot', '$IPHONESDK',
  97. '-framework', 'Foundation',
  98. '-framework', 'UIKit',
  99. '-framework', 'CoreGraphics',
  100. '-framework', 'OpenGLES',
  101. '-framework', 'QuartzCore',
  102. '-framework', 'CoreAudio',
  103. '-framework', 'AudioToolbox',
  104. '-framework', 'SystemConfiguration',
  105. '-framework', 'Security',
  106. #'-framework', 'AdSupport',
  107. '-framework', 'MediaPlayer',
  108. '-framework', 'AVFoundation',
  109. '-framework', 'CoreMedia',
  110. ])
  111. if env['game_center'] == 'yes':
  112. env.Append(CPPFLAGS=['-fblocks', '-DGAME_CENTER_ENABLED'])
  113. env.Append(LINKFLAGS=['-framework', 'GameKit'])
  114. if env['store_kit'] == 'yes':
  115. env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED'])
  116. env.Append(LINKFLAGS=['-framework', 'StoreKit'])
  117. if env['icloud'] == 'yes':
  118. env.Append(CPPFLAGS=['-DICLOUD_ENABLED'])
  119. env.Append(CPPPATH = ['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers'])
  120. if (env["target"]=="release"):
  121. env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1','-Wall', '-gdwarf-2']) # removed -ffast-math
  122. env.Append(LINKFLAGS=['-O3']) #
  123. elif env["target"] == "release_debug":
  124. env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED'])
  125. env.Append(LINKFLAGS=['-Os'])
  126. env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
  127. elif (env["target"]=="debug"):
  128. env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED'])
  129. env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
  130. elif (env["target"]=="profile"):
  131. env.Append(CCFLAGS=['-g','-pg', '-Os'])
  132. env.Append(LINKFLAGS=['-pg'])
  133. if (env["ios_sim"]=="yes"): #TODO: Check if needed?
  134. env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
  135. env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
  136. env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT'])
  137. # TODO: Move that to opus module's config
  138. if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
  139. env.opus_fixed_point="yes"
  140. if env["arch"]=="x86":
  141. pass
  142. elif(env["arch"]=="arm64"):
  143. env.Append(CFLAGS=["-DOPUS_ARM64_OPT"])
  144. else:
  145. env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
  146. if env['ios_exceptions'] == 'yes':
  147. env.Append(CPPFLAGS=['-fexceptions'])
  148. else:
  149. env.Append(CPPFLAGS=['-fno-exceptions'])
  150. #env['neon_enabled']=True
  151. env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc'
  152. import methods
  153. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  154. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  155. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )