OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright 2009, Google Inc. | 2 # Copyright 2009, Google Inc. |
3 # All rights reserved. | 3 # All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 action='store_true', | 58 action='store_true', |
59 help='enable distcc support') | 59 help='enable distcc support') |
60 SCons.Script.Help(' --distcc Enable distcc suport.\n') | 60 SCons.Script.Help(' --distcc Enable distcc suport.\n') |
61 | 61 |
62 except (OptionConflictError, optparse.OptionConflictError): | 62 except (OptionConflictError, optparse.OptionConflictError): |
63 # The distcc tool can be specified for multiple platforms, but the | 63 # The distcc tool can be specified for multiple platforms, but the |
64 # --distcc option can only be added once. Ignore the error which | 64 # --distcc option can only be added once. Ignore the error which |
65 # results from trying to add it a second time. | 65 # results from trying to add it a second time. |
66 pass | 66 pass |
67 | 67 |
| 68 # Modify compilers we support |
| 69 distcc_compilers = env.get('DISTCC_COMPILERS', ['cc', 'gcc', 'c++', 'g++']) |
| 70 |
| 71 if sys.platform == 'darwin': |
| 72 for compiler_var in ('CC', 'CXX'): |
| 73 compiler = env.get(compiler_var) |
| 74 if compiler in distcc_compilers: |
| 75 # On Mac, distcc requires the full path to the compiler. Even |
| 76 # if distcc is disabled, change the compiler name to the |
| 77 # full-path so that the compiler name is the same whether |
| 78 # distcc is enabled or not. This prevents unnecessary |
| 79 # recompilation when distcc is turned on/off. If we can't find |
| 80 # the compiler, leave the non-absolute pathname as a tip-off |
| 81 # that there's a problem and avoid the string concatenation |
| 82 # with the none type. |
| 83 compiler_path = env.WhereIs(compiler) |
| 84 if compiler_path is not None: |
| 85 env[compiler_var] = compiler_path |
| 86 |
68 # If distcc isn't enabled, stop now | 87 # If distcc isn't enabled, stop now |
69 if not env.GetOption('distcc'): | 88 if not env.GetOption('distcc'): |
70 return | 89 return |
71 | 90 |
72 # Copy DISTCC_HOSTS and HOME environment variables from system environment | 91 # Copy DISTCC_HOSTS and HOME environment variables from system environment |
73 for envvar in ('DISTCC_HOSTS', 'HOME'): | 92 for envvar in ('DISTCC_HOSTS', 'HOME'): |
74 value = env.get(envvar, os.environ.get(envvar)) | 93 value = env.get(envvar, os.environ.get(envvar)) |
75 if not value: | 94 if not value: |
76 print 'Warning: %s not set in environment; disabling distcc.' % envvar | 95 print 'Warning: %s not set in environment; disabling distcc.' % envvar |
77 return | 96 return |
78 env['ENV'][envvar] = value | 97 env['ENV'][envvar] = value |
79 | 98 |
| 99 # For distcc pump mode, copy the following variable only if they exist. |
| 100 for envvar in ('INCLUDE_SERVER_PID', 'INCLUDE_SERVER_DIR', |
| 101 'INCLUDE_SERVER_PORT'): |
| 102 value = env.get(envvar, os.environ.get(envvar)) |
| 103 if value: |
| 104 env['ENV'][envvar] = value |
| 105 |
80 # Set name of distcc tool | 106 # Set name of distcc tool |
81 env['DISTCC'] = 'distcc' | 107 env['DISTCC'] = 'distcc' |
82 | 108 |
83 # Modify compilers we support | 109 # Change distcc_compilers to absolute paths for darwin systems since |
84 distcc_compilers = env.get('DISTCC_COMPILERS', ['cc', 'gcc', 'c++', 'g++']) | 110 # we changed the compiler variables in the environment to full-paths |
| 111 # earlier. |
| 112 if sys.platform == 'darwin': |
| 113 for i in range(len(distcc_compilers)): |
| 114 full_path = env.WhereIs(distcc_compilers[i]) |
| 115 if full_path is not None: |
| 116 distcc_compilers[i] = full_path |
| 117 |
85 for compiler_var in ('CC', 'CXX'): | 118 for compiler_var in ('CC', 'CXX'): |
86 compiler = env.get(compiler_var) | 119 compiler = env.get(compiler_var) |
87 if compiler in distcc_compilers: | 120 if compiler in distcc_compilers: |
88 if sys.platform == 'darwin': | 121 # Surround DISTCC command with "ignore" tags to avoid |
89 # On Mac, distcc requires the full path to the compiler | 122 # recompiling unnecessarily when distcc is turned on/off |
90 compiler = env.WhereIs(compiler) | 123 env[compiler_var] = '$( $DISTCC $) ' + compiler |
91 env[compiler_var] = '$DISTCC ' + compiler | |
OLD | NEW |