| 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 from SCons.compat._scons_optparse import OptionConflictError |
| 44 import SCons.Script |
| 45 |
| 46 |
| 47 def generate(env): |
| 48 # NOTE: SCons requires the use of this name, which fails gpylint. |
| 49 """SCons entry point for this tool.""" |
| 50 if not env.Detect('distcc'): |
| 51 return |
| 52 |
| 53 try: |
| 54 SCons.Script.AddOption( |
| 55 '--distcc', |
| 56 dest='distcc', |
| 57 action='store_true', |
| 58 help='enable distcc support') |
| 59 SCons.Script.Help(' --distcc Enable distcc suport.\n') |
| 60 |
| 61 except (OptionConflictError, optparse.OptionConflictError): |
| 62 # The distcc tool can be specified for multiple platforms, but the |
| 63 # --distcc option can only be added once. Ignore the error which |
| 64 # results from trying to add it a second time. |
| 65 pass |
| 66 |
| 67 # If distcc isn't enabled, stop now |
| 68 if not env.GetOption('distcc'): |
| 69 return |
| 70 |
| 71 # Copy DISTCC_HOSTS and HOME environment variables from system environment |
| 72 for envvar in ('DISTCC_HOSTS', 'HOME'): |
| 73 value = env.get(envvar, os.environ.get(envvar)) |
| 74 if not value: |
| 75 print 'Warning: %s not set in environment; disabling distcc.' % envvar |
| 76 return |
| 77 env['ENV'][envvar] = value |
| 78 |
| 79 # Set name of distcc tool |
| 80 env['DISTCC'] = 'distcc' |
| 81 |
| 82 # Modify compilers we support |
| 83 distcc_compilers = env.get('DISTCC_COMPILERS', ['cc', 'gcc', 'c++', 'g++']) |
| 84 for compiler_var in ('CC', 'CXX'): |
| 85 compiler = env.get(compiler_var) |
| 86 if compiler in distcc_compilers: |
| 87 env[compiler_var] = '$DISTCC ' + compiler |
| 88 |
| 89 |
| 90 def exists(env): |
| 91 """Returns true if tool exists.""" |
| 92 # NOTE: SCons requires the use of this name, which fails gpylint. |
| 93 return env.Detect('distcc') |
| OLD | NEW |