Lumiera  0.pre.03
»edit your freedom«
ToolDistCC.py
1 # -*- python -*-
2 
5 
6 # Copyright (C) Lumiera.org and FreeOrion.org
7 # 2008, Hermann Vosseler <Ichthyostega@web.de>
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 
23 
24 # This SCons builder was extracted from http://www.freeorion.org/
25 # FreeOrion is an open-source platform-independent galactic conquest game
26 #
27 # history: 12/2008 adapted for Lumiera build system
28 
29 
30 import os
31 from Buildhelper import *
32 
33 
34 def generate(env):
35  """ Modify the environment such as to redirect any
36  C/C++ compiler invocations through DistCC. Additionally
37  pull in the environment config variables used by DistCC
38  """
39  if not exists(env): return
40 
41  assert env['DISTCC']
42  if not env['DISTCC'] in env['CC']:
43  env['CC'] = env.subst('$DISTCC $CC')
44  if not env['DISTCC'] in env['CXX']:
45  env['CXX'] = env.subst('$DISTCC $CXX')
46  print env.subst("* Build using $DISTCC")
47  for i in ['HOME'
48  ,'DISTCC_HOSTS'
49  ,'DISTCC_VERBOSE'
50  ,'DISTCC_FALLBACK'
51  ,'DISTCC_LOG'
52  ,'DISTCC_MMAP'
53  ,'DISTCC_SAVE_TEMPS'
54  ,'DISTCC_TCP_CORK'
55  ,'DISTCC_SSH'
56  ]:
57  if os.environ.has_key(i) and not env.has_key(i):
58  env['ENV'][i] = os.environ[i]
59 
60 
61 def exists(env):
62  """ Ensure DistCC exists.
63  """
64  return checkCommandOption(env, 'DISTCC', cmdName='distcc')
65