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
, before
, after
15 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
16 def apply_incpaths(self
):
18 # TODO move the uselib processing out of here
19 for lib
in self
.to_list(self
.uselib
):
20 for path
in self
.env
['CPPPATH_' + lib
]:
23 if preproc
.go_absolute
:
24 for path
in preproc
.standard_includes
:
28 for path
in self
.to_list(self
.includes
):
30 if preproc
.go_absolute
or path
[0] != '/': #os.path.isabs(path):
33 self
.env
.prepend_value('CPPPATH', path
)
37 if path
[0] == '/': # os.path.isabs(path):
38 if preproc
.go_absolute
:
39 node
= self
.bld
.root
.find_dir(path
)
41 node
= self
.bld
.srcnode
46 kak
[path
] = node
= node
.find_dir(path
[1:])
49 node
= kak
[(self
.path
.id, path
)]
51 kak
[(self
.path
.id, path
)] = node
= self
.path
.find_dir(path
)
54 self
.env
.append_value('INC_PATHS', node
)
58 @after('apply_incpaths')
59 def apply_obj_vars_cc(self
):
60 """after apply_incpaths for INC_PATHS"""
62 app
= env
.append_unique
63 cpppath_st
= env
['CPPPATH_ST']
65 lss
= env
['_CCINCFLAGS']
69 # local flags come first
70 # set the user-defined includes paths
71 for i
in env
['INC_PATHS']:
77 cac
[i
.id] = [cpppath_st
% i
.bldpath(env
), cpppath_st
% i
.srcpath(env
)]
80 env
['_CCINCFLAGS'] = lss
81 # set the library include paths
82 for i
in env
['CPPPATH']:
83 app('_CCINCFLAGS', cpppath_st
% i
)
85 import Node
, Environment
89 Environment
.Environment
.variant
= vari
91 def variant(self
, env
):
93 elif self
.id & 3 == Node
.FILE
: return 0
94 else: return "default"
95 Node
.Node
.variant
= variant
100 def create_task(self
, name
, src
=None, tgt
=None):
101 task
= Task
.TaskBase
.classes
[name
](self
.env
, generator
=self
)
105 task
.set_outputs(tgt
)
107 TaskGen
.task_gen
.create_task
= create_task
109 def hash_constraints(self
):
111 sum = hash((str(a('before', '')),
113 str(a('ext_in', '')),
114 str(a('ext_out', '')),
115 self
.__class
__.maxjobs
))
117 Task
.TaskBase
.hash_constraints
= hash_constraints
121 # from TaskGen import extension
124 # @extension(cc.EXT_CC)
125 # def c_hook(self, node):
126 # task = self.create_task('cc', node, node.change_ext('.o'))
128 # self.compiled_tasks.append(task)
129 # except AttributeError:
130 # raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
135 # except AttributeError:
138 # if task.outputs[0].id in dc:
139 # raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
141 # dc[task.outputs[0].id] = task