1 # This file contains waf optimisations for Samba
3 # most of these optimisations are possible because of the restricted build environment
4 # that Samba has. For example, Samba doesn't attempt to cope with Win32 paths during the
5 # build, and Samba doesn't need build varients
7 # overall this makes some build tasks quite a bit faster
9 from TaskGen
import feature
, after
13 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
14 def apply_incpaths(self
):
19 except AttributeError:
20 kak
= self
.bld
.kak
= {}
22 # TODO move the uselib processing out of here
23 for lib
in self
.to_list(self
.uselib
):
24 for path
in self
.env
['CPPPATH_' + lib
]:
27 if preproc
.go_absolute
:
28 for path
in preproc
.standard_includes
:
32 for path
in self
.to_list(self
.includes
):
34 if preproc
.go_absolute
or path
[0] != '/': #os.path.isabs(path):
37 self
.env
.prepend_value('CPPPATH', path
)
41 if path
[0] == '/': # os.path.isabs(path):
42 if preproc
.go_absolute
:
43 node
= self
.bld
.root
.find_dir(path
)
45 node
= self
.bld
.srcnode
50 kak
[path
] = node
= node
.find_dir(path
[1:])
53 node
= kak
[(self
.path
.id, path
)]
55 kak
[(self
.path
.id, path
)] = node
= self
.path
.find_dir(path
)
58 self
.env
.append_value('INC_PATHS', node
)
61 @after('apply_incpaths')
62 def apply_obj_vars_cc(self
):
63 """after apply_incpaths for INC_PATHS"""
65 app
= env
.append_unique
66 cpppath_st
= env
['CPPPATH_ST']
68 lss
= env
['_CCINCFLAGS']
72 except AttributeError:
73 cac
= self
.bld
.cac
= {}
75 # local flags come first
76 # set the user-defined includes paths
77 for i
in env
['INC_PATHS']:
83 cac
[i
.id] = [cpppath_st
% i
.bldpath(env
), cpppath_st
% i
.srcpath(env
)]
86 env
['_CCINCFLAGS'] = lss
87 # set the library include paths
88 for i
in env
['CPPPATH']:
89 app('_CCINCFLAGS', cpppath_st
% i
)
91 import Node
, Environment
95 Environment
.Environment
.variant
= vari
97 def variant(self
, env
):
99 elif self
.id & 3 == Node
.FILE
: return 0
100 else: return "default"
101 Node
.Node
.variant
= variant
106 def create_task(self
, name
, src
=None, tgt
=None):
107 task
= Task
.TaskBase
.classes
[name
](self
.env
, generator
=self
)
111 task
.set_outputs(tgt
)
113 TaskGen
.task_gen
.create_task
= create_task
115 def hash_constraints(self
):
117 sum = hash((str(a('before', '')),
119 str(a('ext_in', '')),
120 str(a('ext_out', '')),
121 self
.__class
__.maxjobs
))
123 Task
.TaskBase
.hash_constraints
= hash_constraints
127 # from TaskGen import extension
130 # @extension(cc.EXT_CC)
131 # def c_hook(self, node):
132 # task = self.create_task('cc', node, node.change_ext('.o'))
134 # self.compiled_tasks.append(task)
135 # except AttributeError:
136 # raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
141 # except AttributeError:
144 # if task.outputs[0].id in dc:
145 # raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
147 # dc[task.outputs[0].id] = task
153 '''work around a problem with cc on solaris not handling module aliases
154 which have empty libs'''
155 if getattr(cls
, 'solaris_wrap', False):
157 cls
.solaris_wrap
= True
160 if self
.env
.CC_NAME
== "sun" and not self
.inputs
:
161 self
.env
= self
.env
.copy()
162 self
.env
.append_value('LINKFLAGS', '-')
165 suncc_wrap(Task
.TaskBase
.classes
['cc_link'])