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.

83 lines
2.8 KiB

6 years ago
  1. #
  2. # Copyright (c) 2001 - 2017 The SCons Foundation
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining
  5. # a copy of this software and associated documentation files (the
  6. # "Software"), to deal in the Software without restriction, including
  7. # without limitation the rights to use, copy, modify, merge, publish,
  8. # distribute, sublicense, and/or sell copies of the Software, and to
  9. # permit persons to whom the Software is furnished to do so, subject to
  10. # the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included
  13. # in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  16. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  17. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. __revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  23. __doc__ = """
  24. """
  25. import os
  26. import re
  27. import SCons.Util
  28. from .common import read_reg, debug
  29. # Original value recorded by dcournapeau
  30. _FRAMEWORKDIR_HKEY_ROOT = r'Software\Microsoft\.NETFramework\InstallRoot'
  31. # On SGK's system
  32. _FRAMEWORKDIR_HKEY_ROOT = r'Software\Microsoft\Microsoft SDKs\.NETFramework\v2.0\InstallationFolder'
  33. def find_framework_root():
  34. # XXX: find it from environment (FrameworkDir)
  35. try:
  36. froot = read_reg(_FRAMEWORKDIR_HKEY_ROOT)
  37. debug("Found framework install root in registry: {}".format(froot))
  38. except SCons.Util.WinError as e:
  39. debug("Could not read reg key {}".format(_FRAMEWORKDIR_HKEY_ROOT))
  40. return None
  41. if not os.path.exists(froot):
  42. debug("{} not found on fs".format(froot))
  43. return None
  44. return froot
  45. def query_versions():
  46. froot = find_framework_root()
  47. if froot:
  48. contents = os.listdir(froot)
  49. l = re.compile('v[0-9]+.*')
  50. versions = [e for e in contents if l.match(e)]
  51. def versrt(a,b):
  52. # since version numbers aren't really floats...
  53. aa = a[1:]
  54. bb = b[1:]
  55. aal = aa.split('.')
  56. bbl = bb.split('.')
  57. # sequence comparison in python is lexicographical
  58. # which is exactly what we want.
  59. # Note we sort backwards so the highest version is first.
  60. return cmp(bbl,aal)
  61. versions.sort(versrt)
  62. else:
  63. versions = []
  64. return versions
  65. # Local Variables:
  66. # tab-width:4
  67. # indent-tabs-mode:nil
  68. # End:
  69. # vim: set expandtab tabstop=4 shiftwidth=4: