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
14 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
15 def apply_incpaths(self):
17 # TODO move the uselib processing out of here
18 for lib in self.to_list(self.uselib):
19 for path in self.env['CPPPATH_' + lib]:
22 if preproc.go_absolute:
23 for path in preproc.standard_includes:
27 for path in self.to_list(self.includes):
29 if preproc.go_absolute or path[0] != '/': #os.path.isabs(path):
32 self.env.prepend_value('CPPPATH', path)
36 if path[0] == '/': # os.path.isabs(path):
37 if preproc.go_absolute:
38 node = self.bld.root.find_dir(path)
40 node = self.bld.srcnode
45 kak[path] = node = node.find_dir(path[1:])
48 node = kak[(self.path.id, path)]
50 kak[(self.path.id, path)] = node = self.path.find_dir(path)
53 self.env.append_value('INC_PATHS', node)
57 @after('apply_incpaths')
58 def apply_obj_vars_cc(self):
59 """after apply_incpaths for INC_PATHS"""
61 app = env.append_unique
62 cpppath_st = env['CPPPATH_ST']
64 lss = env['_CCINCFLAGS']
68 # local flags come first
69 # set the user-defined includes paths
70 for i in env['INC_PATHS']:
76 cac[i.id] = [cpppath_st % i.bldpath(env), cpppath_st % i.srcpath(env)]
79 env['_CCINCFLAGS'] = lss
80 # set the library include paths
81 for i in env['CPPPATH']:
82 app('_CCINCFLAGS', cpppath_st % i)
84 import Node, Environment
88 Environment.Environment.variant = vari
90 def variant(self, env):
92 elif self.id & 3 == Node.FILE: return 0
93 else: return "default"
94 Node.Node.variant = variant
99 def create_task(self, name, src=None, tgt=None):
100 task = Task.TaskBase.classes[name](self.env, generator=self)
104 task.set_outputs(tgt)
106 TaskGen.task_gen.create_task = create_task
108 def hash_constraints(self):
110 sum = hash((str(a('before', '')),
112 str(a('ext_in', '')),
113 str(a('ext_out', '')),
114 self.__class__.maxjobs))
116 Task.TaskBase.hash_constraints = hash_constraints
120 # from TaskGen import extension
123 # @extension(cc.EXT_CC)
124 # def c_hook(self, node):
125 # task = self.create_task('cc', node, node.change_ext('.o'))
127 # self.compiled_tasks.append(task)
128 # except AttributeError:
129 # raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
134 # except AttributeError:
137 # if task.outputs[0].id in dc:
138 # raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
140 # dc[task.outputs[0].id] = task