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.

winddk.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. """winddk
  2. Tool-specific initialization for Microsoft Windows DDK.
  3. """
  4. #
  5. # Copyright (c) 2001-2007 The SCons Foundation
  6. # Copyright (c) 2008 Tungsten Graphics, Inc.
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining
  9. # a copy of this software and associated documentation files (the
  10. # "Software"), to deal in the Software without restriction, including
  11. # without limitation the rights to use, copy, modify, merge, publish,
  12. # distribute, sublicense, and/or sell copies of the Software, and to
  13. # permit persons to whom the Software is furnished to do so, subject to
  14. # the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included
  17. # in all copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  20. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  21. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. #
  27. import os.path
  28. import re
  29. import string
  30. import SCons.Action
  31. import SCons.Builder
  32. import SCons.Errors
  33. import SCons.Platform.win32
  34. import SCons.Tool
  35. import SCons.Util
  36. import SCons.Warnings
  37. import msvc_sa
  38. import mslib_sa
  39. import mslink_sa
  40. versions = [
  41. '6001.18002',
  42. '3790.1830',
  43. ]
  44. def cpu_bin(target_cpu):
  45. if target_cpu == 'i386':
  46. return 'x86'
  47. else:
  48. return target_cpu
  49. def get_winddk_root(env, version):
  50. default_path = os.path.join(r'C:\WINDDK', version)
  51. if os.path.exists(default_path):
  52. return default_path
  53. return None
  54. def get_winddk_paths(env, version, root):
  55. version_major, version_minor = map(int, version.split('.'))
  56. if version_major >= 6000:
  57. target_os = 'wlh'
  58. else:
  59. target_os = 'wxp'
  60. if env['machine'] in ('generic', 'x86'):
  61. target_cpu = 'i386'
  62. elif env['machine'] == 'x86_64':
  63. target_cpu = 'amd64'
  64. else:
  65. raise SCons.Errors.InternalError, "Unsupported target machine"
  66. if version_major >= 6000:
  67. # TODO: take in consideration the host cpu
  68. bin_dir = os.path.join(root, 'bin', 'x86', cpu_bin(target_cpu))
  69. else:
  70. if target_cpu == 'i386':
  71. bin_dir = os.path.join(root, 'bin', 'x86')
  72. else:
  73. # TODO: take in consideration the host cpu
  74. bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
  75. env.PrependENVPath('PATH', [bin_dir])
  76. crt_inc_dir = os.path.join(root, 'inc', 'crt')
  77. if version_major >= 6000:
  78. sdk_inc_dir = os.path.join(root, 'inc', 'api')
  79. ddk_inc_dir = os.path.join(root, 'inc', 'ddk')
  80. wdm_inc_dir = os.path.join(root, 'inc', 'ddk')
  81. else:
  82. ddk_inc_dir = os.path.join(root, 'inc', 'ddk', target_os)
  83. sdk_inc_dir = os.path.join(root, 'inc', target_os)
  84. wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
  85. env.PrependENVPath('INCLUDE', [
  86. wdm_inc_dir,
  87. ddk_inc_dir,
  88. crt_inc_dir,
  89. sdk_inc_dir,
  90. ])
  91. env.PrependENVPath('LIB', [
  92. os.path.join(root, 'lib', 'crt', target_cpu),
  93. os.path.join(root, 'lib', target_os, target_cpu),
  94. ])
  95. def generate(env):
  96. if not env.has_key('ENV'):
  97. env['ENV'] = {}
  98. for version in versions:
  99. root = get_winddk_root(env, version)
  100. if root is not None:
  101. get_winddk_paths(env, version, root)
  102. break
  103. msvc_sa.generate(env)
  104. mslib_sa.generate(env)
  105. mslink_sa.generate(env)
  106. def exists(env):
  107. for version in versions:
  108. if get_winddk_root(env, version) is not None:
  109. return True
  110. return False
  111. # vim:set ts=4 sw=4 et: