Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

winsdk.py 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. env.PrependENVPath('PATH', os.path.join(vc_root, bin_dir))
  65. env.PrependENVPath('INCLUDE', os.path.join(vc_root, include_dir))
  66. env.PrependENVPath('LIB', os.path.join(vc_root, lib_dir))
  67. def get_sdk_root(env):
  68. if SCons.Util.can_read_reg:
  69. key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder'
  70. try:
  71. path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
  72. except SCons.Util.RegError:
  73. pass
  74. else:
  75. return path
  76. return None
  77. def get_sdk_paths(env):
  78. sdk_root = get_sdk_root(env)
  79. if sdk_root is None:
  80. raise SCons.Errors.InternalError, "WINSDK not found"
  81. target_cpu = env['machine']
  82. bin_dir = 'Bin'
  83. if target_cpu in ('generic', 'x86'):
  84. lib_dir = 'Lib'
  85. elif target_cpu == 'x86_64':
  86. lib_dir = r'Lib\x64'
  87. else:
  88. raise SCons.Errors.InternalError, "Unsupported target machine"
  89. include_dir = 'Include'
  90. env.PrependENVPath('PATH', os.path.join(sdk_root, bin_dir))
  91. env.PrependENVPath('INCLUDE', os.path.join(sdk_root, include_dir))
  92. env.PrependENVPath('LIB', os.path.join(sdk_root, lib_dir))
  93. def generate(env):
  94. if not env.has_key('ENV'):
  95. env['ENV'] = {}
  96. get_vs_paths(env)
  97. get_vc_paths(env)
  98. get_sdk_paths(env)
  99. msvc_sa.generate(env)
  100. mslib_sa.generate(env)
  101. mslink_sa.generate(env)
  102. def exists(env):
  103. return get_vc_root(env) is not None and get_sdk_root(env) is not None
  104. # vim:set ts=4 sw=4 et: