1 # a includes processing tool to speed up include path calculations
3 from TaskGen
import feature
, before
, after
9 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
10 def apply_incpaths(self
):
12 # TODO move the uselib processing out of here
13 for lib
in self
.to_list(self
.uselib
):
14 for path
in self
.env
['CPPPATH_' + lib
]:
17 if preproc
.go_absolute
:
18 for path
in preproc
.standard_includes
:
22 for path
in self
.to_list(self
.includes
):
24 if preproc
.go_absolute
or path
[0] != '/': #os.path.isabs(path):
27 self
.env
.prepend_value('CPPPATH', path
)
31 if path
[0] == '/': # os.path.isabs(path):
32 if preproc
.go_absolute
:
33 node
= self
.bld
.root
.find_dir(path
)
35 node
= self
.bld
.srcnode
40 kak
[path
] = node
= node
.find_dir(path
[1:])
43 node
= kak
[(self
.path
.id, path
)]
45 kak
[(self
.path
.id, path
)] = node
= self
.path
.find_dir(path
)
48 self
.env
.append_value('INC_PATHS', node
)
52 @after('apply_incpaths')
53 def apply_obj_vars_cc(self
):
54 """after apply_incpaths for INC_PATHS"""
56 app
= env
.append_unique
57 cpppath_st
= env
['CPPPATH_ST']
59 lss
= env
['_CCINCFLAGS']
63 # local flags come first
64 # set the user-defined includes paths
65 for i
in env
['INC_PATHS']:
71 cac
[i
.id] = [cpppath_st
% i
.bldpath(env
), cpppath_st
% i
.srcpath(env
)]
74 env
['_CCINCFLAGS'] = lss
75 # set the library include paths
76 for i
in env
['CPPPATH']:
77 app('_CCINCFLAGS', cpppath_st
% i
)
79 import Node
, Environment
83 Environment
.Environment
.variant
= vari
85 def variant(self
, env
):
87 elif self
.id & 3 == Node
.FILE
: return 0
88 else: return "default"
89 Node
.Node
.variant
= variant
94 def create_task(self
, name
, src
=None, tgt
=None):
95 task
= Task
.TaskBase
.classes
[name
](self
.env
, generator
=self
)
101 TaskGen
.task_gen
.create_task
= create_task
103 def hash_constraints(self
):
105 sum = hash((str(a('before', '')),
107 str(a('ext_in', '')),
108 str(a('ext_out', '')),
109 self
.__class
__.maxjobs
))
111 Task
.TaskBase
.hash_constraints
= hash_constraints
115 # from TaskGen import extension
118 # @extension(cc.EXT_CC)
119 # def c_hook(self, node):
120 # task = self.create_task('cc', node, node.change_ext('.o'))
122 # self.compiled_tasks.append(task)
123 # except AttributeError:
124 # raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
129 # except AttributeError:
132 # if task.outputs[0].id in dc:
133 # raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
135 # dc[task.outputs[0].id] = task