3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
7 # Carlos Rafael Giani, 2007 (dv)
8 # Thomas Nagy, 2007-2016 (ita)
10 from waflib import Utils, Task, Errors
11 from waflib.TaskGen import taskgen_method, feature, extension
12 from waflib.Tools import d_scan, d_config
13 from waflib.Tools.ccroot import link_task, stlink_task
16 "Compile a d file into an object file"
18 run_str = '${D} ${DFLAGS} ${DINC_ST:INCPATHS} ${D_SRC_F:SRC} ${D_TGT_F:TGT}'
21 class d_with_header(d):
22 "Compile a d file and generate a header"
23 run_str = '${D} ${DFLAGS} ${DINC_ST:INCPATHS} ${D_HDR_F:tgt.outputs[1].bldpath()} ${D_SRC_F:SRC} ${D_TGT_F:tgt.outputs[0].bldpath()}'
25 class d_header(Task.Task):
28 run_str = '${D} ${D_HEADER} ${SRC}'
30 class dprogram(link_task):
31 "Link object files into a d program"
32 run_str = '${D_LINKER} ${LINKFLAGS} ${DLNK_SRC_F}${SRC} ${DLNK_TGT_F:TGT} ${RPATH_ST:RPATH} ${DSTLIB_MARKER} ${DSTLIBPATH_ST:STLIBPATH} ${DSTLIB_ST:STLIB} ${DSHLIB_MARKER} ${DLIBPATH_ST:LIBPATH} ${DSHLIB_ST:LIB}'
35 class dshlib(dprogram):
36 "Link object files into a d shared library"
39 class dstlib(stlink_task):
40 "Link object files into a d static library"
43 @extension('.d', '.di', '.D')
44 def d_hook(self, node):
46 Compile *D* files. To get .di files as well as .o files, set the following::
49 bld.program(source='foo.d', target='app', generate_headers=True)
52 ext = Utils.destos_to_binfmt(self.env.DEST_OS) == 'pe' and 'obj' or 'o'
53 out = '%s.%d.%s' % (node.name, self.idx, ext)
54 def create_compiled_task(self, name, node):
55 task = self.create_task(name, node, node.parent.find_or_declare(out))
57 self.compiled_tasks.append(task)
58 except AttributeError:
59 self.compiled_tasks = [task]
62 if getattr(self, 'generate_headers', None):
63 tsk = create_compiled_task(self, 'd_with_header', node)
64 tsk.outputs.append(node.change_ext(self.env.DHEADER_ext))
66 tsk = create_compiled_task(self, 'd', node)
70 def generate_header(self, filename):
72 See feature request #104::
75 tg = bld.program(source='foo.d', target='app')
76 tg.generate_header('blah.d')
78 #tg = bld.program(source='foo.d', target='app', header_lst='blah.d')
80 :param filename: header to create
81 :type filename: string
84 self.header_lst.append([filename, self.install_path])
85 except AttributeError:
86 self.header_lst = [[filename, self.install_path]]
89 def process_header(self):
91 Process the attribute 'header_lst' to create the d header compilation tasks::
94 bld.program(source='foo.d', target='app', header_lst='blah.d')
96 for i in getattr(self, 'header_lst', []):
97 node = self.path.find_resource(i[0])
99 raise Errors.WafError('file %r not found on d obj' % i[0])
100 self.create_task('d_header', node, node.change_ext('.di'))