3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
7 # Carlos Rafael Giani, 2007 (dv)
8 # Thomas Nagy, 2008-2018 (ita)
11 from waflib.Tools import ar, d
12 from waflib.Configure import conf
17 Finds the program *dmd*, *dmd2*, or *ldc* and set the variable *D*
19 conf.find_program(['dmd', 'dmd2', 'ldc'], var='D')
21 # make sure that we're dealing with dmd1, dmd2, or ldc(1)
22 out = conf.cmd_and_log(conf.env.D + ['--help'])
23 if out.find("D Compiler v") == -1:
24 out = conf.cmd_and_log(conf.env.D + ['-version'])
25 if out.find("based on DMD v1.") == -1:
26 conf.fatal("detected compiler is not dmd/ldc")
29 def common_flags_ldc(conf):
31 Sets the D flags required by *ldc*
34 v.DFLAGS = ['-d-version=Posix']
36 v.DFLAGS_dshlib = ['-relocation-model=pic']
39 def common_flags_dmd(conf):
41 Set the flags required by *dmd* or *dmd2*
50 v.DLNK_TGT_F = '-of%s'
53 v.DSHLIB_MARKER = v.DSTLIB_MARKER = ''
54 v.DSTLIB_ST = v.DSHLIB_ST = '-L-l%s'
55 v.DSTLIBPATH_ST = v.DLIBPATH_ST = '-L-L%s'
57 v.LINKFLAGS_dprogram= ['-quiet']
59 v.DFLAGS_dshlib = ['-fPIC']
60 v.LINKFLAGS_dshlib = ['-L-shared']
63 v.DFLAGS_d_with_header = ['-H', '-Hf']
68 Configuration for *dmd*, *dmd2*, and *ldc*
72 if sys.platform == 'win32':
73 out = conf.cmd_and_log(conf.env.D + ['--help'])
74 if out.find('D Compiler v2.') > -1:
75 conf.fatal('dmd2 on Windows is not supported, use gdc or ldc2 instead')
79 conf.common_flags_dmd()
80 conf.d_platform_flags()
82 if str(conf.env.D).find('ldc') > -1:
83 conf.common_flags_ldc()