2
0

detect.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import os
  2. import sys
  3. def is_active():
  4. return True
  5. def get_name():
  6. return "Windows"
  7. def can_build():
  8. if (os.name=="nt"):
  9. #building natively on windows!
  10. if (os.getenv("VSINSTALLDIR")):
  11. return True
  12. else:
  13. print("MSVC Not detected, attempting mingw.")
  14. return True
  15. if (os.name=="posix"):
  16. if os.system("i586-mingw32msvc-gcc --version") == 0:
  17. return True
  18. return False
  19. def get_opts():
  20. mwp=""
  21. mwp64=""
  22. if (os.name!="nt"):
  23. mwp="i586-mingw32msvc-"
  24. mwp64="x86_64-w64-mingw32-"
  25. return [
  26. ('force_64_bits','Force 64 bits binary','no'),
  27. ('force_32_bits','Force 32 bits binary','no'),
  28. ('mingw_prefix','Mingw Prefix',mwp),
  29. ('mingw_prefix_64','Mingw Prefix 64 bits',mwp64),
  30. ]
  31. def get_flags():
  32. return [
  33. ('freetype','builtin'), #use builtin freetype
  34. ('openssl','builtin'), #use builtin openssl
  35. ]
  36. def configure(env):
  37. if os.name == "posix":
  38. env['OBJSUFFIX'] = ".win"+env['OBJSUFFIX']
  39. env['LIBSUFFIX'] = ".win"+env['LIBSUFFIX']
  40. env.Append(CPPPATH=['#platform/windows'])
  41. if (env["tools"]=="no"):
  42. #no tools suffix
  43. env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
  44. #env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
  45. env['platform_libsuffix'] = ".nt"+env['LIBSUFFIX']
  46. if (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None):
  47. #build using visual studio
  48. env['ENV']['TMP'] = os.environ['TMP']
  49. env.Append(CPPPATH=['#platform/windows/include'])
  50. env.Append(LIBPATH=['#platform/windows/lib'])
  51. if (env["freetype"]!="no"):
  52. env.Append(CCFLAGS=['/DFREETYPE_ENABLED'])
  53. env.Append(CPPPATH=['#tools/freetype'])
  54. env.Append(CPPPATH=['#tools/freetype/freetype/include'])
  55. if (env["target"]=="release"):
  56. env.Append(CCFLAGS=['/O2'])
  57. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
  58. env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
  59. elif (env["target"]=="test"):
  60. env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO'])
  61. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  62. elif (env["target"]=="debug"):
  63. env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO','/O1'])
  64. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  65. env.Append(LINKFLAGS=['/DEBUG'])
  66. elif (env["target"]=="profile"):
  67. env.Append(CCFLAGS=['-g','-pg'])
  68. env.Append(LINKFLAGS=['-pg'])
  69. env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo'])
  70. env.Append(CXXFLAGS=['/TP'])
  71. env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
  72. env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"])
  73. env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
  74. env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
  75. env.Append(CCFLAGS=['/DWIN32'])
  76. env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
  77. env.Append(CCFLAGS=['/DGLES2_ENABLED'])
  78. env.Append(CCFLAGS=['/DGLES1_ENABLED'])
  79. env.Append(CCFLAGS=['/DGLEW_ENABLED'])
  80. env.Append(LIBS=['winmm','opengl32','dsound','kernel32','ole32','user32','gdi32', 'IPHLPAPI', 'wsock32', 'shell32','advapi32'])
  81. env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"])
  82. if (os.getenv("DXSDK_DIR")):
  83. DIRECTX_PATH=os.getenv("DXSDK_DIR")
  84. else:
  85. DIRECTX_PATH="C:/Program Files/Microsoft DirectX SDK (March 2009)"
  86. if (os.getenv("VCINSTALLDIR")):
  87. VC_PATH=os.getenv("VCINSTALLDIR")
  88. else:
  89. VC_PATH=""
  90. env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
  91. env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
  92. env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"])
  93. env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"])
  94. env['ENV'] = os.environ;
  95. else:
  96. #build using mingw
  97. if (os.name=="nt"):
  98. env['ENV']['TMP'] = os.environ['TMP'] #way to go scons, you can be so stupid sometimes
  99. mingw_prefix=""
  100. if (env["force_32_bits"]!="no"):
  101. env['OBJSUFFIX'] = ".32"+env['OBJSUFFIX']
  102. env['LIBSUFFIX'] = ".32"+env['LIBSUFFIX']
  103. env.Append(CCFLAGS=['-m32'])
  104. env.Append(LINKFLAGS=['-m32'])
  105. env.Append(LINKFLAGS=['-static-libgcc'])
  106. env.Append(LINKFLAGS=['-static-libstdc++'])
  107. if (env["force_64_bits"]!="no"):
  108. mingw_prefix=env["mingw_prefix_64"];
  109. env['OBJSUFFIX'] = ".64"+env['OBJSUFFIX']
  110. env['LIBSUFFIX'] = ".64"+env['LIBSUFFIX']
  111. env.Append(LINKFLAGS=['-static'])
  112. else:
  113. mingw_prefix=env["mingw_prefix"];
  114. if (env["target"]=="release"):
  115. env.Append(CCFLAGS=['-O3','-ffast-math','-fomit-frame-pointer','-msse2'])
  116. env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
  117. env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
  118. elif (env["target"]=="release_debug"):
  119. env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
  120. env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
  121. env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
  122. elif (env["target"]=="debug"):
  123. env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED'])
  124. elif (env["target"]=="release_tools"):
  125. env.Append(CCFLAGS=['-O2','-Wall','-DDEBUG_ENABLED'])
  126. if (env["freetype"]!="no"):
  127. env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
  128. env.Append(CPPPATH=['#tools/freetype'])
  129. env.Append(CPPPATH=['#tools/freetype/freetype/include'])
  130. env["CC"]=mingw_prefix+"gcc"
  131. env['AS']=mingw_prefix+"as"
  132. env['CXX'] = mingw_prefix+"g++"
  133. env['AR'] = mingw_prefix+"ar"
  134. env['RANLIB'] = mingw_prefix+"ranlib"
  135. env['LD'] = mingw_prefix+"g++"
  136. #env['CC'] = "winegcc"
  137. #env['CXX'] = "wineg++"
  138. env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows'])
  139. env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED'])
  140. env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLEW_ENABLED'])
  141. env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','wsock32','kernel32'])
  142. #'d3dx9d'
  143. env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
  144. env.Append(LINKFLAGS=['-g'])
  145. import methods
  146. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  147. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
  148. env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
  149. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )