waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

dmd.py (1880B)


      1 #!/usr/bin/env python
      2 # encoding: utf-8
      3 # Carlos Rafael Giani, 2007 (dv)
      4 # Thomas Nagy, 2008-2018 (ita)
      5 
      6 import sys
      7 from waflib.Tools import ar, d
      8 from waflib.Configure import conf
      9 
     10 @conf
     11 def find_dmd(conf):
     12 	"""
     13 	Finds the program *dmd*, *dmd2*, or *ldc* and set the variable *D*
     14 	"""
     15 	conf.find_program(['dmd', 'dmd2', 'ldc'], var='D')
     16 
     17 	# make sure that we're dealing with dmd1, dmd2, or ldc(1)
     18 	out = conf.cmd_and_log(conf.env.D + ['--help'])
     19 	if out.find("D Compiler v") == -1:
     20 		out = conf.cmd_and_log(conf.env.D + ['-version'])
     21 		if out.find("based on DMD v1.") == -1:
     22 			conf.fatal("detected compiler is not dmd/ldc")
     23 
     24 @conf
     25 def common_flags_ldc(conf):
     26 	"""
     27 	Sets the D flags required by *ldc*
     28 	"""
     29 	v = conf.env
     30 	v.DFLAGS        = ['-d-version=Posix']
     31 	v.LINKFLAGS     = []
     32 	v.DFLAGS_dshlib = ['-relocation-model=pic']
     33 
     34 @conf
     35 def common_flags_dmd(conf):
     36 	"""
     37 	Set the flags required by *dmd* or *dmd2*
     38 	"""
     39 	v = conf.env
     40 
     41 	v.D_SRC_F           = ['-c']
     42 	v.D_TGT_F           = '-of%s'
     43 
     44 	v.D_LINKER          = v.D
     45 	v.DLNK_SRC_F        = ''
     46 	v.DLNK_TGT_F        = '-of%s'
     47 	v.DINC_ST           = '-I%s'
     48 
     49 	v.DSHLIB_MARKER = v.DSTLIB_MARKER = ''
     50 	v.DSTLIB_ST = v.DSHLIB_ST         = '-L-l%s'
     51 	v.DSTLIBPATH_ST = v.DLIBPATH_ST   = '-L-L%s'
     52 
     53 	v.LINKFLAGS_dprogram= ['-quiet']
     54 
     55 	v.DFLAGS_dshlib     = ['-fPIC']
     56 	v.LINKFLAGS_dshlib  = ['-L-shared']
     57 
     58 	v.DHEADER_ext       = '.di'
     59 	v.DFLAGS_d_with_header = ['-H', '-Hf']
     60 	v.D_HDR_F           = '%s'
     61 
     62 def configure(conf):
     63 	"""
     64 	Configuration for *dmd*, *dmd2*, and *ldc*
     65 	"""
     66 	conf.find_dmd()
     67 
     68 	if sys.platform == 'win32':
     69 		out = conf.cmd_and_log(conf.env.D + ['--help'])
     70 		if out.find('D Compiler v2.') > -1:
     71 			conf.fatal('dmd2 on Windows is not supported, use gdc or ldc2 instead')
     72 
     73 	conf.load('ar')
     74 	conf.load('d')
     75 	conf.common_flags_dmd()
     76 	conf.d_platform_flags()
     77 
     78 	if str(conf.env.D).find('ldc') > -1:
     79 		conf.common_flags_ldc()
     80