Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. """winsdk
  2. Tool-specific initialization for Microsoft Windows SDK.
  3. """
  4. #
  5. # Copyright (c) 2001-2007 The SCons Foundation
  6. # Copyright (c) 2008 Tungsten Graphics, Inc.
  7. # Copyright (c) 2009 VMware, Inc.
  8. #
  9. # Permission is hereby granted, free of charge, to any person obtaining
  10. # a copy of this software and associated documentation files (the
  11. # "Software"), to deal in the Software without restriction, including
  12. # without limitation the rights to use, copy, modify, merge, publish,
  13. # distribute, sublicense, and/or sell copies of the Software, and to
  14. # permit persons to whom the Software is furnished to do so, subject to
  15. # the following conditions:
  16. #
  17. # The above copyright notice and this permission notice shall be included
  18. # in all copies or substantial portions of the Software.
  19. #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  21. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  22. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. #
  28. import os.path
  29. import platform
  30. import SCons.Errors
  31. import SCons.Util
  32. import msvc_sa
  33. import mslib_sa
  34. import mslink_sa
  35. def get_vs_root(env):
  36. # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7
  37. path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0')
  38. return path
  39. def get_vs_paths(env):
  40. vs_root = get_vs_root(env)
  41. if vs_root is None:
  42. raise SCons.Errors.InternalError, "WINSDK compiler not found"
  43. tool_path = os.path.join(vs_root, 'Common7', 'IDE')
  44. env.PrependENVPath('PATH', tool_path)
  45. def get_vc_root(env):
  46. # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7
  47. path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0', 'VC')
  48. return path
  49. def get_vc_paths(env):
  50. vc_root = get_vc_root(env)
  51. if vc_root is None:
  52. raise SCons.Errors.InternalError, "WINSDK compiler not found"
  53. target_cpu = env['machine']
  54. if target_cpu in ('generic', 'x86'):
  55. bin_dir = 'bin'
  56. lib_dir = 'lib'
  57. elif target_cpu == 'x86_64':
  58. # TODO: take in consideration the host cpu
  59. bin_dir = r'bin\x86_amd64'
  60. lib_dir = r'lib\amd64'
  61. else:
  62. raise SCons.Errors.InternalError, "Unsupported target machine"
  63. include_dir = 'include'
  64. exe_path = os.path.join(vc_root, bin_dir)
  65. include_path = os.path.join(vc_root, include_dir)
  66. lib_path = os.path.join(vc_root, lib_dir)
  67. env.PrependENVPath('INCLUDE', include_path)
  68. env.PrependENVPath('LIB', lib_path)
  69. env.PrependENVPath('PATH', exe_path)
  70. def get_sdk_root(env):
  71. if SCons.Util.can_read_reg:
  72. key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder'
  73. try:
  74. path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
  75. except SCons.Util.RegError:
  76. pass
  77. else:
  78. return path
  79. return None
  80. def get_sdk_paths(env):
  81. sdk_root = get_sdk_root(env)
  82. if sdk_root is None:
  83. raise SCons.Errors.InternalError, "WINSDK not found"
  84. target_cpu = env['machine']
  85. bin_dir = 'Bin'
  86. if target_cpu in ('generic', 'x86'):
  87. lib_dir = 'Lib'
  88. elif target_cpu == 'x86_64':
  89. lib_dir = 'Lib/x64'
  90. else:
  91. raise SCons.Errors.InternalError, "Unsupported target machine"
  92. include_dir = 'Include'
  93. exe_path = os.path.join(sdk_root, bin_dir)
  94. include_path = os.path.join(sdk_root, include_dir)
  95. lib_path = os.path.join(sdk_root, lib_dir)
  96. env.PrependENVPath('INCLUDE', include_path)
  97. env.PrependENVPath('LIB', lib_path)
  98. env.PrependENVPath('PATH', exe_path)
  99. def generate(env):
  100. if not env.has_key('ENV'):
  101. env['ENV'] = {}
  102. get_vs_paths(env)
  103. get_vc_paths(env)
  104. get_sdk_paths(env)
  105. msvc_sa.generate(env)
  106. mslib_sa.generate(env)
  107. mslink_sa.generate(env)
  108. def exists(env):
  109. return get_vc_root(env) is not None and get_sdk_root(env) is not None
  110. # vim:set ts=4 sw=4 et: