1 | # This file contains waf optimisations for Samba
|
---|
2 |
|
---|
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
|
---|
6 |
|
---|
7 | # overall this makes some build tasks quite a bit faster
|
---|
8 |
|
---|
9 | from TaskGen import feature, after
|
---|
10 | import preproc, Task
|
---|
11 |
|
---|
12 | @feature('cc', 'cxx')
|
---|
13 | @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
|
---|
14 | def apply_incpaths(self):
|
---|
15 | lst = []
|
---|
16 |
|
---|
17 | try:
|
---|
18 | kak = self.bld.kak
|
---|
19 | except AttributeError:
|
---|
20 | kak = self.bld.kak = {}
|
---|
21 |
|
---|
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]:
|
---|
25 | if not path in lst:
|
---|
26 | lst.append(path)
|
---|
27 | if preproc.go_absolute:
|
---|
28 | for path in preproc.standard_includes:
|
---|
29 | if not path in lst:
|
---|
30 | lst.append(path)
|
---|
31 |
|
---|
32 | for path in self.to_list(self.includes):
|
---|
33 | if not path in lst:
|
---|
34 | if preproc.go_absolute or path[0] != '/': #os.path.isabs(path):
|
---|
35 | lst.append(path)
|
---|
36 | else:
|
---|
37 | self.env.prepend_value('CPPPATH', path)
|
---|
38 |
|
---|
39 | for path in lst:
|
---|
40 | node = None
|
---|
41 | if path[0] == '/': # os.path.isabs(path):
|
---|
42 | if preproc.go_absolute:
|
---|
43 | node = self.bld.root.find_dir(path)
|
---|
44 | elif path[0] == '#':
|
---|
45 | node = self.bld.srcnode
|
---|
46 | if len(path) > 1:
|
---|
47 | try:
|
---|
48 | node = kak[path]
|
---|
49 | except KeyError:
|
---|
50 | kak[path] = node = node.find_dir(path[1:])
|
---|
51 | else:
|
---|
52 | try:
|
---|
53 | node = kak[(self.path.id, path)]
|
---|
54 | except KeyError:
|
---|
55 | kak[(self.path.id, path)] = node = self.path.find_dir(path)
|
---|
56 |
|
---|
57 | if node:
|
---|
58 | self.env.append_value('INC_PATHS', node)
|
---|
59 |
|
---|
60 | @feature('cc')
|
---|
61 | @after('apply_incpaths')
|
---|
62 | def apply_obj_vars_cc(self):
|
---|
63 | """after apply_incpaths for INC_PATHS"""
|
---|
64 | env = self.env
|
---|
65 | app = env.append_unique
|
---|
66 | cpppath_st = env['CPPPATH_ST']
|
---|
67 |
|
---|
68 | lss = env['_CCINCFLAGS']
|
---|
69 |
|
---|
70 | try:
|
---|
71 | cac = self.bld.cac
|
---|
72 | except AttributeError:
|
---|
73 | cac = self.bld.cac = {}
|
---|
74 |
|
---|
75 | # local flags come first
|
---|
76 | # set the user-defined includes paths
|
---|
77 | for i in env['INC_PATHS']:
|
---|
78 |
|
---|
79 | try:
|
---|
80 | lss.extend(cac[i.id])
|
---|
81 | except KeyError:
|
---|
82 |
|
---|
83 | cac[i.id] = [cpppath_st % i.bldpath(env), cpppath_st % i.srcpath(env)]
|
---|
84 | lss.extend(cac[i.id])
|
---|
85 |
|
---|
86 | env['_CCINCFLAGS'] = lss
|
---|
87 | # set the library include paths
|
---|
88 | for i in env['CPPPATH']:
|
---|
89 | app('_CCINCFLAGS', cpppath_st % i)
|
---|
90 |
|
---|
91 | import Node, Environment
|
---|
92 |
|
---|
93 | def vari(self):
|
---|
94 | return "default"
|
---|
95 | Environment.Environment.variant = vari
|
---|
96 |
|
---|
97 | def variant(self, env):
|
---|
98 | if not env: return 0
|
---|
99 | elif self.id & 3 == Node.FILE: return 0
|
---|
100 | else: return "default"
|
---|
101 | Node.Node.variant = variant
|
---|
102 |
|
---|
103 |
|
---|
104 | import TaskGen, Task
|
---|
105 |
|
---|
106 | def create_task(self, name, src=None, tgt=None):
|
---|
107 | task = Task.TaskBase.classes[name](self.env, generator=self)
|
---|
108 | if src:
|
---|
109 | task.set_inputs(src)
|
---|
110 | if tgt:
|
---|
111 | task.set_outputs(tgt)
|
---|
112 | return task
|
---|
113 | TaskGen.task_gen.create_task = create_task
|
---|
114 |
|
---|
115 | def hash_constraints(self):
|
---|
116 | a = self.attr
|
---|
117 | sum = hash((str(a('before', '')),
|
---|
118 | str(a('after', '')),
|
---|
119 | str(a('ext_in', '')),
|
---|
120 | str(a('ext_out', '')),
|
---|
121 | self.__class__.maxjobs))
|
---|
122 | return sum
|
---|
123 | Task.TaskBase.hash_constraints = hash_constraints
|
---|
124 |
|
---|
125 |
|
---|
126 | # import cc
|
---|
127 | # from TaskGen import extension
|
---|
128 | # import Utils
|
---|
129 |
|
---|
130 | # @extension(cc.EXT_CC)
|
---|
131 | # def c_hook(self, node):
|
---|
132 | # task = self.create_task('cc', node, node.change_ext('.o'))
|
---|
133 | # try:
|
---|
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))
|
---|
137 |
|
---|
138 | # bld = self.bld
|
---|
139 | # try:
|
---|
140 | # dc = bld.dc
|
---|
141 | # except AttributeError:
|
---|
142 | # dc = bld.dc = {}
|
---|
143 |
|
---|
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))
|
---|
146 | # else:
|
---|
147 | # dc[task.outputs[0].id] = task
|
---|
148 |
|
---|
149 | # return task
|
---|
150 |
|
---|
151 |
|
---|
152 | def suncc_wrap(cls):
|
---|
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):
|
---|
156 | return
|
---|
157 | cls.solaris_wrap = True
|
---|
158 | oldrun = cls.run
|
---|
159 | def run(self):
|
---|
160 | if self.env.CC_NAME == "sun" and not self.inputs:
|
---|
161 | self.env = self.env.copy()
|
---|
162 | self.env.append_value('LINKFLAGS', '-')
|
---|
163 | return oldrun(self)
|
---|
164 | cls.run = run
|
---|
165 | suncc_wrap(Task.TaskBase.classes['cc_link'])
|
---|