SConstruct 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. EnsureSConsVersion(0,14);
  2. import string
  3. import os
  4. import os.path
  5. import glob
  6. import sys
  7. import methods
  8. import multiprocessing
  9. # Enable aggresive compile mode if building on a multi core box
  10. # only is we have not set the number of jobs already or we do
  11. # not want it
  12. if ARGUMENTS.get('spawn_jobs', 'no') == 'yes' and \
  13. int(GetOption('num_jobs')) <= 1:
  14. NUM_JOBS = multiprocessing.cpu_count()
  15. if NUM_JOBS > 1:
  16. SetOption('num_jobs', NUM_JOBS+1)
  17. methods.update_version()
  18. # scan possible build platforms
  19. platform_list = [] # list of platforms
  20. platform_opts = {} # options for each platform
  21. platform_flags = {} # flags for each platform
  22. active_platforms=[]
  23. active_platform_ids=[]
  24. platform_exporters=[]
  25. global_defaults=[]
  26. for x in glob.glob("platform/*"):
  27. if (not os.path.isdir(x)):
  28. continue
  29. tmppath="./"+x
  30. sys.path.append(tmppath)
  31. import detect
  32. if (os.path.exists(x+"/export/export.cpp")):
  33. platform_exporters.append(x[9:])
  34. if (os.path.exists(x+"/globals/global_defaults.cpp")):
  35. global_defaults.append(x[9:])
  36. if (detect.is_active()):
  37. active_platforms.append( detect.get_name() )
  38. active_platform_ids.append(x);
  39. if (detect.can_build()):
  40. x=x.replace("platform/","") # rest of world
  41. x=x.replace("platform\\","") # win32
  42. platform_list+=[x]
  43. platform_opts[x]=detect.get_opts()
  44. platform_flags[x]=detect.get_flags()
  45. sys.path.remove(tmppath)
  46. sys.modules.pop('detect')
  47. module_list=methods.detect_modules()
  48. print "Detected Platforms: "+str(platform_list)
  49. print("Detected Modules: "+str(module_list))
  50. methods.save_active_platforms(active_platforms,active_platform_ids)
  51. custom_tools=['default']
  52. if (os.name=="posix"):
  53. pass
  54. elif (os.name=="nt"):
  55. if (os.getenv("VSINSTALLDIR")==None):
  56. custom_tools=['mingw']
  57. env_base=Environment(tools=custom_tools,ENV = {'PATH' : os.environ['PATH']});
  58. #env_base=Environment(tools=custom_tools);
  59. env_base.global_defaults=global_defaults
  60. env_base.android_source_modules=[]
  61. env_base.android_source_files=[]
  62. env_base.android_module_libraries=[]
  63. env_base.android_manifest_chunk=""
  64. env_base.disabled_modules=[]
  65. env_base.__class__.android_module_source = methods.android_module_source
  66. env_base.__class__.android_module_library = methods.android_module_library
  67. env_base.__class__.android_module_file = methods.android_module_file
  68. env_base.__class__.android_module_manifest = methods.android_module_manifest
  69. env_base.__class__.disable_module = methods.disable_module
  70. env_base.__class__.add_source_files = methods.add_source_files
  71. customs = ['custom.py']
  72. profile = ARGUMENTS.get("profile", False)
  73. if profile:
  74. import os.path
  75. if os.path.isfile(profile):
  76. customs.append(profile)
  77. elif os.path.isfile(profile+".py"):
  78. customs.append(profile+".py")
  79. opts=Variables(customs, ARGUMENTS)
  80. opts.Add('target', 'Compile Target (debug/profile/release).', "debug")
  81. opts.Add('platform','Platform: '+str(platform_list)+'(sfml).',"")
  82. opts.Add('python','Build Python Support: (yes/no)','no')
  83. opts.Add('squirrel','Build Squirrel Support: (yes/no)','no')
  84. opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes')
  85. opts.Add('lua','Build Lua Support: (yes/no)','no')
  86. opts.Add('rfd','Remote Filesystem Driver: (yes/no)','no')
  87. opts.Add('gdscript','Build GDSCript support: (yes/no)','yes')
  88. opts.Add('vorbis','Build Ogg Vorbis Support: (yes/no)','yes')
  89. opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes')
  90. opts.Add('opengl', 'Build OpenGL Support: (yes/no)', 'yes')
  91. opts.Add('game', 'Game (custom) Code Directory', "")
  92. opts.Add('squish','Squish BC Texture Compression (yes/no)','yes')
  93. opts.Add('theora','Theora Video (yes/no)','yes')
  94. opts.Add('freetype','Freetype support in editor','yes')
  95. opts.Add('speex','Speex Audio (yes/no)','yes')
  96. opts.Add('xml','XML Save/Load support (yes/no)','yes')
  97. opts.Add('png','PNG Image loader support (yes/no)','yes')
  98. opts.Add('jpg','JPG Image loader support (yes/no)','yes')
  99. opts.Add('webp','WEBP Image loader support (yes/no)','yes')
  100. opts.Add('dds','DDS Texture loader support (yes/no)','yes')
  101. opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes')
  102. opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
  103. opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no')
  104. opts.Add('musepack','Musepack Audio (yes/no)','yes')
  105. opts.Add('default_gui_theme','Default GUI theme (yes/no)','yes')
  106. opts.Add("CXX", "Compiler");
  107. opts.Add("nedmalloc", "Add nedmalloc support", 'yes');
  108. opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
  109. opts.Add("CFLAGS", "Custom flags for the C compiler");
  110. opts.Add("LINKFLAGS", "Custom flags for the linker");
  111. opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
  112. opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
  113. opts.Add('old_scenes', 'Compatibility with old-style scenes', "yes")
  114. # add platform specific options
  115. for k in platform_opts.keys():
  116. opt_list = platform_opts[k]
  117. for o in opt_list:
  118. opts.Add(o[0],o[1],o[2])
  119. for x in module_list:
  120. opts.Add('module_'+x+'_enabled', "Enable module '"+x+"'.", "yes")
  121. opts.Update(env_base) # update environment
  122. Help(opts.GenerateHelpText(env_base)) # generate help
  123. # add default include paths
  124. env_base.Append(CPPPATH=['#core','#core/math','#tools','#drivers','#'])
  125. # configure ENV for platform
  126. env_base.detect_python=True
  127. env_base.platform_exporters=platform_exporters
  128. """
  129. sys.path.append("./platform/"+env_base["platform"])
  130. import detect
  131. detect.configure(env_base)
  132. sys.path.remove("./platform/"+env_base["platform"])
  133. sys.modules.pop('detect')
  134. """
  135. if (env_base['target']=='debug'):
  136. env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']);
  137. env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
  138. env_base.platforms = {}
  139. for p in platform_list:
  140. if env_base['platform'] != "" and env_base['platform'] != p:
  141. continue
  142. sys.path.append("./platform/"+p)
  143. import detect
  144. if "create" in dir(detect):
  145. env = detect.create(env_base)
  146. else:
  147. env = env_base.Clone()
  148. CCFLAGS = env.get('CCFLAGS', '')
  149. env['CCFLAGS'] = ''
  150. env.Append(CCFLAGS=string.split(str(CCFLAGS)))
  151. CFLAGS = env.get('CFLAGS', '')
  152. env['CFLAGS'] = ''
  153. env.Append(CFLAGS=string.split(str(CFLAGS)))
  154. LINKFLAGS = env.get('LINKFLAGS', '')
  155. env['LINKFLAGS'] = ''
  156. env.Append(LINKFLAGS=string.split(str(LINKFLAGS)))
  157. detect.configure(env)
  158. env['platform'] = p
  159. if not env.has_key('platform_libsuffix'):
  160. env['platform_libsuffix'] = env['LIBSUFFIX']
  161. sys.path.remove("./platform/"+p)
  162. sys.modules.pop('detect')
  163. flag_list = platform_flags[p]
  164. for f in flag_list:
  165. env[f[0]] = f[1]
  166. print(f[0]+":"+f[1])
  167. env.module_list=[]
  168. for x in module_list:
  169. if env['module_'+x+'_enabled'] != "yes":
  170. continue
  171. tmppath="./modules/"+x
  172. sys.path.append(tmppath)
  173. env.current_module=x
  174. import config
  175. if (config.can_build(p)):
  176. config.configure(env)
  177. env.module_list.append(x)
  178. sys.path.remove(tmppath)
  179. sys.modules.pop('config')
  180. if (env['musepack']=='yes'):
  181. env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
  182. if (env['openssl']!='no'):
  183. env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
  184. if (env['openssl']=="builtin"):
  185. env.Append(CPPPATH=['#drivers/builtin_openssl2'])
  186. if (env["old_scenes"]=='yes'):
  187. env.Append(CPPFLAGS=['-DOLD_SCENE_FORMAT_ENABLED'])
  188. if (env["rfd"]=='yes'):
  189. env.Append(CPPFLAGS=['-DRFD_ENABLED'])
  190. if (env["builtin_zlib"]=='yes'):
  191. env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
  192. # to test 64 bits compiltion
  193. # env.Append(CPPFLAGS=['-m64'])
  194. if (env_base['squish']=='yes'):
  195. env.Append(CPPFLAGS=['-DSQUISH_ENABLED']);
  196. if (env['vorbis']=='yes'):
  197. env.Append(CPPFLAGS=['-DVORBIS_ENABLED']);
  198. if (env['theora']=='yes'):
  199. env.Append(CPPFLAGS=['-DTHEORA_ENABLED']);
  200. if (env['png']=='yes'):
  201. env.Append(CPPFLAGS=['-DPNG_ENABLED']);
  202. if (env['dds']=='yes'):
  203. env.Append(CPPFLAGS=['-DDDS_ENABLED']);
  204. if (env['pvr']=='yes'):
  205. env.Append(CPPFLAGS=['-DPVR_ENABLED']);
  206. if (env['jpg']=='yes'):
  207. env.Append(CPPFLAGS=['-DJPG_ENABLED']);
  208. if (env['webp']=='yes'):
  209. env.Append(CPPFLAGS=['-DWEBP_ENABLED']);
  210. if (env['speex']=='yes'):
  211. env.Append(CPPFLAGS=['-DSPEEX_ENABLED']);
  212. if (env['tools']=='yes'):
  213. env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
  214. if (env['disable_3d']=='yes'):
  215. env.Append(CPPFLAGS=['-D_3D_DISABLED'])
  216. if (env['gdscript']=='yes'):
  217. env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
  218. if (env['disable_advanced_gui']=='yes'):
  219. env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
  220. if (env['minizip'] == 'yes'):
  221. env.Append(CPPFLAGS=['-DMINIZIP_ENABLED'])
  222. if (env['xml']=='yes'):
  223. env.Append(CPPFLAGS=['-DXML_ENABLED'])
  224. if (env['default_gui_theme']=='no'):
  225. env.Append(CPPFLAGS=['-DDEFAULT_THEME_DISABLED'])
  226. if (env["python"]=='yes'):
  227. detected=False;
  228. if (env.detect_python):
  229. print("Python 3.0 Prefix:");
  230. pycfg_exec="python3-config"
  231. errorval=os.system(pycfg_exec+" --prefix")
  232. prefix=""
  233. if (not errorval):
  234. #gah, why can't it get both at the same time like pkg-config, sdl-config, etc?
  235. env.ParseConfig(pycfg_exec+" --cflags")
  236. env.ParseConfig(pycfg_exec+" --libs")
  237. detected=True
  238. if (detected):
  239. env.Append(CPPFLAGS=['-DPYTHON_ENABLED'])
  240. #remove annoying warnings
  241. if ('-Wstrict-prototypes' in env["CCFLAGS"]):
  242. env["CCFLAGS"].remove('-Wstrict-prototypes');
  243. if ('-fwrapv' in env["CCFLAGS"]):
  244. env["CCFLAGS"].remove('-fwrapv');
  245. else:
  246. print("Python 3.0 not detected ("+pycfg_exec+") support disabled.");
  247. #if env['nedmalloc'] == 'yes':
  248. # env.Append(CPPFLAGS = ['-DNEDMALLOC_ENABLED'])
  249. Export('env')
  250. #build subdirs, the build order is dependent on link order.
  251. SConscript("core/SCsub")
  252. SConscript("servers/SCsub")
  253. SConscript("scene/SCsub")
  254. SConscript("tools/SCsub")
  255. SConscript("drivers/SCsub")
  256. SConscript("bin/SCsub")
  257. if env['game']:
  258. SConscript(env['game']+'/SCsub')
  259. SConscript("modules/SCsub")
  260. SConscript("main/SCsub")
  261. SConscript("platform/"+p+"/SCsub"); # build selected platform