| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python2.4 | |
| 2 # Copyright 2008, Google Inc. | |
| 3 # All rights reserved. | |
| 4 # | |
| 5 # Redistribution and use in source and binary forms, with or without | |
| 6 # modification, are permitted provided that the following conditions are | |
| 7 # met: | |
| 8 # | |
| 9 # * Redistributions of source code must retain the above copyright | |
| 10 # notice, this list of conditions and the following disclaimer. | |
| 11 # * Redistributions in binary form must reproduce the above | |
| 12 # copyright notice, this list of conditions and the following disclaimer | |
| 13 # in the documentation and/or other materials provided with the | |
| 14 # distribution. | |
| 15 # * Neither the name of Google Inc. nor the names of its | |
| 16 # contributors may be used to endorse or promote products derived from | |
| 17 # this software without specific prior written permission. | |
| 18 # | |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 30 | |
| 31 """Distcc support for SCons. | |
| 32 | |
| 33 Since this modifies the C compiler strings, it must be specified after the | |
| 34 compiler tool in the tool list. | |
| 35 | |
| 36 Distcc support can be enabled by specifying --distcc on the SCons command | |
| 37 line. | |
| 38 """ | |
| 39 | |
| 40 | |
| 41 import optparse | |
| 42 import os | |
| 43 import sys | |
| 44 from SCons.compat._scons_optparse import OptionConflictError | |
| 45 import SCons.Script | |
| 46 | |
| 47 | |
| 48 def generate(env): | |
| 49 # NOTE: SCons requires the use of this name, which fails gpylint. | |
| 50 """SCons entry point for this tool.""" | |
| 51 if not env.Detect('distcc'): | |
| 52 return | |
| 53 | |
| 54 try: | |
| 55 SCons.Script.AddOption( | |
| 56 '--distcc', | |
| 57 dest='distcc', | |
| 58 action='store_true', | |
| 59 help='enable distcc support') | |
| 60 SCons.Script.Help(' --distcc Enable distcc suport.\n') | |
| 61 | |
| 62 except (OptionConflictError, optparse.OptionConflictError): | |
| 63 # The distcc tool can be specified for multiple platforms, but the | |
| 64 # --distcc option can only be added once. Ignore the error which | |
| 65 # results from trying to add it a second time. | |
| 66 pass | |
| 67 | |
| 68 # If distcc isn't enabled, stop now | |
| 69 if not env.GetOption('distcc'): | |
| 70 return | |
| 71 | |
| 72 # Copy DISTCC_HOSTS and HOME environment variables from system environment | |
| 73 for envvar in ('DISTCC_HOSTS', 'HOME'): | |
| 74 value = env.get(envvar, os.environ.get(envvar)) | |
| 75 if not value: | |
| 76 print 'Warning: %s not set in environment; disabling distcc.' % envvar | |
| 77 return | |
| 78 env['ENV'][envvar] = value | |
| 79 | |
| 80 # Set name of distcc tool | |
| 81 env['DISTCC'] = 'distcc' | |
| 82 | |
| 83 # Modify compilers we support | |
| 84 distcc_compilers = env.get('DISTCC_COMPILERS', ['cc', 'gcc', 'c++', 'g++']) | |
| 85 for compiler_var in ('CC', 'CXX'): | |
| 86 compiler = env.get(compiler_var) | |
| 87 if compiler in distcc_compilers: | |
| 88 if sys.platform == 'darwin': | |
| 89 # On Mac, distcc requires the full path to the compiler | |
| 90 compiler = env.WhereIs(compiler) | |
| 91 env[compiler_var] = '$DISTCC ' + compiler | |
| 92 | |
| 93 | |
| 94 def exists(env): | |
| 95 """Returns true if tool exists.""" | |
| 96 # NOTE: SCons requires the use of this name, which fails gpylint. | |
| 97 return env.Detect('distcc') | |
| OLD | NEW |