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.

207 lines
6.9 KiB

6 years ago
  1. #! /usr/bin/env python
  2. #
  3. # SCons - a Software Constructor
  4. #
  5. # Copyright (c) 2001 - 2017 The SCons Foundation
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining
  8. # a copy of this software and associated documentation files (the
  9. # "Software"), to deal in the Software without restriction, including
  10. # without limitation the rights to use, copy, modify, merge, publish,
  11. # distribute, sublicense, and/or sell copies of the Software, and to
  12. # permit persons to whom the Software is furnished to do so, subject to
  13. # the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included
  16. # in all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  19. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  20. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  22. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. from __future__ import print_function
  26. __revision__ = "src/script/scons.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  27. __version__ = "3.0.0"
  28. __build__ = "rel_3.0.0:4395:8972f6a2f699"
  29. __buildsys__ = "ubuntu-16"
  30. __date__ = "2017/09/18 12:59:24"
  31. __developer__ = "bdbaddog"
  32. import os
  33. import sys
  34. ##############################################################################
  35. # BEGIN STANDARD SCons SCRIPT HEADER
  36. #
  37. # This is the cut-and-paste logic so that a self-contained script can
  38. # interoperate correctly with different SCons versions and installation
  39. # locations for the engine. If you modify anything in this section, you
  40. # should also change other scripts that use this same header.
  41. ##############################################################################
  42. # Strip the script directory from sys.path() so on case-insensitive
  43. # (WIN32) systems Python doesn't think that the "scons" script is the
  44. # "SCons" package. Replace it with our own library directories
  45. # (version-specific first, in case they installed by hand there,
  46. # followed by generic) so we pick up the right version of the build
  47. # engine modules if they're in either directory.
  48. if (3,0,0) < sys.version_info < (3,5,0) or sys.version_info < (2,7,0):
  49. msg = "scons: *** SCons version %s does not run under Python version %s.\n\
  50. Python < 3.5 is not yet supported.\n"
  51. sys.stderr.write(msg % (__version__, sys.version.split()[0]))
  52. sys.exit(1)
  53. script_dir = sys.path[0]
  54. if script_dir in sys.path:
  55. sys.path.remove(script_dir)
  56. libs = []
  57. if "SCONS_LIB_DIR" in os.environ:
  58. libs.append(os.environ["SCONS_LIB_DIR"])
  59. # - running from source takes priority (since 2.3.2), excluding SCONS_LIB_DIR settings
  60. script_path = os.path.abspath(os.path.dirname(__file__))
  61. source_path = os.path.join(script_path, '..', 'engine')
  62. libs.append(source_path)
  63. local_version = 'scons-local-' + __version__
  64. local = 'scons-local'
  65. if script_dir:
  66. local_version = os.path.join(script_dir, local_version)
  67. local = os.path.join(script_dir, local)
  68. libs.append(os.path.abspath(local_version))
  69. libs.append(os.path.abspath(local))
  70. scons_version = 'scons-%s' % __version__
  71. # preferred order of scons lookup paths
  72. prefs = []
  73. # - running from egg check
  74. try:
  75. import pkg_resources
  76. except ImportError:
  77. pass
  78. else:
  79. # when running from an egg add the egg's directory
  80. try:
  81. d = pkg_resources.get_distribution('scons')
  82. except pkg_resources.DistributionNotFound:
  83. pass
  84. else:
  85. prefs.append(d.location)
  86. if sys.platform == 'win32':
  87. # sys.prefix is (likely) C:\Python*;
  88. # check only C:\Python*.
  89. prefs.append(sys.prefix)
  90. prefs.append(os.path.join(sys.prefix, 'Lib', 'site-packages'))
  91. else:
  92. # On other (POSIX) platforms, things are more complicated due to
  93. # the variety of path names and library locations. Try to be smart
  94. # about it.
  95. if script_dir == 'bin':
  96. # script_dir is `pwd`/bin;
  97. # check `pwd`/lib/scons*.
  98. prefs.append(os.getcwd())
  99. else:
  100. if script_dir == '.' or script_dir == '':
  101. script_dir = os.getcwd()
  102. head, tail = os.path.split(script_dir)
  103. if tail == "bin":
  104. # script_dir is /foo/bin;
  105. # check /foo/lib/scons*.
  106. prefs.append(head)
  107. head, tail = os.path.split(sys.prefix)
  108. if tail == "usr":
  109. # sys.prefix is /foo/usr;
  110. # check /foo/usr/lib/scons* first,
  111. # then /foo/usr/local/lib/scons*.
  112. prefs.append(sys.prefix)
  113. prefs.append(os.path.join(sys.prefix, "local"))
  114. elif tail == "local":
  115. h, t = os.path.split(head)
  116. if t == "usr":
  117. # sys.prefix is /foo/usr/local;
  118. # check /foo/usr/local/lib/scons* first,
  119. # then /foo/usr/lib/scons*.
  120. prefs.append(sys.prefix)
  121. prefs.append(head)
  122. else:
  123. # sys.prefix is /foo/local;
  124. # check only /foo/local/lib/scons*.
  125. prefs.append(sys.prefix)
  126. else:
  127. # sys.prefix is /foo (ends in neither /usr or /local);
  128. # check only /foo/lib/scons*.
  129. prefs.append(sys.prefix)
  130. temp = [os.path.join(x, 'lib') for x in prefs]
  131. temp.extend([os.path.join(x,
  132. 'lib',
  133. 'python' + sys.version[:3],
  134. 'site-packages') for x in prefs])
  135. prefs = temp
  136. # Add the parent directory of the current python's library to the
  137. # preferences. On SuSE-91/AMD64, for example, this is /usr/lib64,
  138. # not /usr/lib.
  139. try:
  140. libpath = os.__file__
  141. except AttributeError:
  142. pass
  143. else:
  144. # Split /usr/libfoo/python*/os.py to /usr/libfoo/python*.
  145. libpath, tail = os.path.split(libpath)
  146. # Split /usr/libfoo/python* to /usr/libfoo
  147. libpath, tail = os.path.split(libpath)
  148. # Check /usr/libfoo/scons*.
  149. prefs.append(libpath)
  150. # Look first for 'scons-__version__' in all of our preference libs,
  151. # then for 'scons'.
  152. libs.extend([os.path.join(x, scons_version) for x in prefs])
  153. libs.extend([os.path.join(x, 'scons') for x in prefs])
  154. sys.path = libs + sys.path
  155. ##############################################################################
  156. # END STANDARD SCons SCRIPT HEADER
  157. ##############################################################################
  158. if __name__ == "__main__":
  159. try:
  160. import SCons.Script
  161. except ImportError:
  162. print("SCons import failed. Unable to find engine files in:")
  163. for path in libs:
  164. print(" {}".format(path))
  165. raise
  166. # this does all the work, and calls sys.exit
  167. # with the proper exit status when done.
  168. SCons.Script.main()
  169. # Local Variables:
  170. # tab-width:4
  171. # indent-tabs-mode:nil
  172. # End:
  173. # vim: set expandtab tabstop=4 shiftwidth=4: