3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
11 Try to detect if the project directory was relocated, and if it was,
12 change the node representing the project directory. Just call:
16 Note that if the project directory name changes, the signatures for the tasks using
17 files in that directory will change, causing a partial build.
21 from waflib import Build, ConfigSet, Task, Utils, Errors
22 from waflib.TaskGen import feature, after_method
24 EXTRA_LOCK = '.old_srcdir'
26 old1 = Build.BuildContext.store
29 db = os.path.join(self.variant_dir, EXTRA_LOCK)
30 env = ConfigSet.ConfigSet()
31 env.SRCDIR = self.srcnode.abspath()
33 Build.BuildContext.store = store
35 old2 = Build.BuildContext.init_dirs
38 if not (os.path.isabs(self.top_dir) and os.path.isabs(self.out_dir)):
39 raise Errors.WafError('The project was not configured: run "waf configure" first!')
42 db = os.path.join(self.variant_dir, EXTRA_LOCK)
43 env = ConfigSet.ConfigSet()
51 d = self.root.find_node(srcdir)
52 if d and srcdir != self.top_dir and getattr(d, 'children', ''):
53 srcnode = self.root.make_node(self.top_dir)
54 print("relocating the source directory %r -> %r" % (srcdir, self.top_dir))
57 for (k, v) in d.children.items():
58 srcnode.children[k] = v
64 Build.BuildContext.init_dirs = init_dirs
70 except AttributeError:
71 # this is not a real hot zone, but we want to avoid surprises here
74 up(self.__class__.__name__.encode())
75 for x in self.inputs + self.outputs:
76 up(x.path_from(x.ctx.srcnode).encode())
77 self.uid_ = m.digest()
81 @feature('c', 'cxx', 'd', 'go', 'asm', 'fc', 'includes')
82 @after_method('propagate_uselib_vars', 'process_source')
83 def apply_incpaths(self):
84 lst = self.to_incnodes(self.to_list(getattr(self, 'includes', [])) + self.env['INCLUDES'])
85 self.includes_nodes = lst
87 self.env['INCPATHS'] = [x.is_child_of(bld.srcnode) and x.path_from(bld.bldnode) or x.abspath() for x in lst]