detect.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import os
  2. import sys
  3. import string
  4. import methods
  5. def is_active():
  6. return True
  7. def get_name():
  8. return "WinRT"
  9. def can_build():
  10. if (os.name=="nt"):
  11. #building natively on windows!
  12. if (os.getenv("VSINSTALLDIR")):
  13. if (os.getenv("ANGLE_SRC_PATH") == None):
  14. return False
  15. return True
  16. return False
  17. def get_opts():
  18. return []
  19. def get_flags():
  20. return [
  21. ('tools', 'no'),
  22. ('openssl', 'builtin'),
  23. ]
  24. def configure(env):
  25. if(env["bits"] != "default"):
  26. print("Error: bits argument is disabled for MSVC")
  27. print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)"
  28. +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=winrt) and SCons will attempt to detect what MSVC compiler"
  29. +" will be executed and inform you.")
  30. sys.exit()
  31. arch = ""
  32. env['ENV'] = os.environ;
  33. # ANGLE
  34. angle_root = os.getenv("ANGLE_SRC_PATH")
  35. env.Append(CPPPATH=[angle_root + '/include'])
  36. jobs = str(env.GetOption("num_jobs"))
  37. angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform="
  38. if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"):
  39. env["build_angle"] = True
  40. if str(os.getenv('Platform')).lower() == "arm":
  41. print("Compiled program architecture will be an ARM executable. (forcing bits=32).")
  42. arch="arm"
  43. env["bits"]="32"
  44. env.Append(LINKFLAGS=['/MACHINE:ARM'])
  45. env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/arm'])
  46. angle_build_cmd += "ARM"
  47. env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib'])
  48. else:
  49. compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV'])
  50. if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"):
  51. env["bits"]="64"
  52. print("Compiled program architecture will be a x64 executable (forcing bits=64).")
  53. elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"):
  54. env["bits"]="32"
  55. print("Compiled program architecture will be a x86 executable. (forcing bits=32).")
  56. else:
  57. print("Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.")
  58. env["bits"]="32"
  59. if (env["bits"] == "32"):
  60. arch = "x86"
  61. angle_build_cmd += "Win32"
  62. env.Append(LINKFLAGS=['/MACHINE:X86'])
  63. env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store'])
  64. env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib'])
  65. else:
  66. arch = "x64"
  67. angle_build_cmd += "x64"
  68. env.Append(LINKFLAGS=['/MACHINE:X64'])
  69. env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64'])
  70. env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib'])
  71. env.Append(CPPPATH=['#platform/winrt','#drivers/windows'])
  72. env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"'])
  73. env.Append(CPPFLAGS=['/D', '__WRL_NO_DEFAULT_LIB__', '/D', 'WIN32', '/DPNG_ABORT=abort'])
  74. if (env["target"]=="release"):
  75. env.Append(CPPFLAGS=['/O2', '/GL'])
  76. env.Append(CPPFLAGS=['/MD'])
  77. env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG'])
  78. elif (env["target"]=="release_debug"):
  79. env.Append(CCFLAGS=['/O2','/Zi','/DDEBUG_ENABLED'])
  80. env.Append(CPPFLAGS=['/MD'])
  81. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  82. elif (env["target"]=="debug"):
  83. env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED'])
  84. env.Append(CPPFLAGS=['/MDd'])
  85. env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
  86. env.Append(LINKFLAGS=['/DEBUG'])
  87. env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'))
  88. env.Append(CXXFLAGS=string.split('/ZW /FS'))
  89. env.Append(CCFLAGS=['/AI', os.environ['VCINSTALLDIR']+'\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR']+'\\References\\CommonConfiguration\\Neutral'])
  90. env['ENV'] = os.environ
  91. env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"]
  92. env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"]
  93. env["LIBSUFFIX"] = "." + arch + env["LIBSUFFIX"]
  94. env.Append(CCFLAGS=['/DWINRT_ENABLED'])
  95. env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
  96. env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
  97. env.Append(CCFLAGS=['/DGLES2_ENABLED','/DGL_GLEXT_PROTOTYPES','/DEGL_EGLEXT_PROTOTYPES','/DANGLE_ENABLED'])
  98. LIBS = [
  99. 'xaudio2',
  100. 'WindowsApp',
  101. 'mincore',
  102. 'ws2_32',
  103. 'libANGLE',
  104. 'libEGL',
  105. 'libGLESv2',
  106. ]
  107. env.Append(LINKFLAGS=[p+".lib" for p in LIBS])
  108. # Incremental linking fix
  109. env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program']
  110. env['BUILDERS']['Program'] = methods.precious_program
  111. env.Append( BUILDERS = { 'ANGLE' : env.Builder(action = angle_build_cmd) } )
  112. env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.gen.h',src_suffix = '.glsl') } )
  113. env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.gen.h',src_suffix = '.glsl') } )
  114. env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.gen.h',src_suffix = '.hlsl') } )
  115. env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.gen.h',src_suffix = '.glsl') } )