7 Try to detect if the project directory was relocated, and if it was,
8 change the node representing the project directory. Just call:
12 Note that if the project directory name changes, the signatures for the tasks using
13 files in that directory will change, causing a partial build.
17 from waflib import Build, ConfigSet, Task, Utils, Errors
18 from waflib.TaskGen import feature, after_method
20 EXTRA_LOCK = '.old_srcdir'
22 old1 = Build.BuildContext.store
25 db = os.path.join(self.variant_dir, EXTRA_LOCK)
26 env = ConfigSet.ConfigSet()
27 env.SRCDIR = self.srcnode.abspath()
29 Build.BuildContext.store = store
31 old2 = Build.BuildContext.init_dirs
34 if not (os.path.isabs(self.top_dir) and os.path.isabs(self.out_dir)):
35 raise Errors.WafError('The project was not configured: run "waf configure" first!')
38 db = os.path.join(self.variant_dir, EXTRA_LOCK)
39 env = ConfigSet.ConfigSet()
47 d = self.root.find_node(srcdir)
48 if d and srcdir != self.top_dir and getattr(d, 'children', ''):
49 srcnode = self.root.make_node(self.top_dir)
50 print("relocating the source directory %r -> %r" % (srcdir, self.top_dir))
53 for (k, v) in d.children.items():
54 srcnode.children[k] = v
60 Build.BuildContext.init_dirs = init_dirs
66 except AttributeError:
67 # this is not a real hot zone, but we want to avoid surprises here
70 up(self.__class__.__name__.encode())
71 for x in self.inputs + self.outputs:
72 up(x.path_from(x.ctx.srcnode).encode())
73 self.uid_ = m.digest()
77 @feature('c', 'cxx', 'd', 'go', 'asm', 'fc', 'includes')
78 @after_method('propagate_uselib_vars', 'process_source')
79 def apply_incpaths(self):
80 lst = self.to_incnodes(self.to_list(getattr(self, 'includes', [])) + self.env['INCLUDES'])
81 self.includes_nodes = lst
83 self.env['INCPATHS'] = [x.is_child_of(bld.srcnode) and x.path_from(bld.bldnode) or x.abspath() for x in lst]