d_config.py (1415B)
1 #!/usr/bin/env python 2 # encoding: utf-8 3 # Thomas Nagy, 2016-2018 (ita) 4 5 from waflib import Utils 6 from waflib.Configure import conf 7 8 @conf 9 def d_platform_flags(self): 10 """ 11 Sets the extensions dll/so for d programs and libraries 12 """ 13 v = self.env 14 if not v.DEST_OS: 15 v.DEST_OS = Utils.unversioned_sys_platform() 16 binfmt = Utils.destos_to_binfmt(self.env.DEST_OS) 17 if binfmt == 'pe': 18 v.dprogram_PATTERN = '%s.exe' 19 v.dshlib_PATTERN = 'lib%s.dll' 20 v.dstlib_PATTERN = 'lib%s.a' 21 elif binfmt == 'mac-o': 22 v.dprogram_PATTERN = '%s' 23 v.dshlib_PATTERN = 'lib%s.dylib' 24 v.dstlib_PATTERN = 'lib%s.a' 25 else: 26 v.dprogram_PATTERN = '%s' 27 v.dshlib_PATTERN = 'lib%s.so' 28 v.dstlib_PATTERN = 'lib%s.a' 29 30 DLIB = ''' 31 version(D_Version2) { 32 import std.stdio; 33 int main() { 34 writefln("phobos2"); 35 return 0; 36 } 37 } else { 38 version(Tango) { 39 import tango.stdc.stdio; 40 int main() { 41 printf("tango"); 42 return 0; 43 } 44 } else { 45 import std.stdio; 46 int main() { 47 writefln("phobos1"); 48 return 0; 49 } 50 } 51 } 52 ''' 53 """Detection string for the D standard library""" 54 55 @conf 56 def check_dlibrary(self, execute=True): 57 """ 58 Detects the kind of standard library that comes with the compiler, 59 and sets conf.env.DLIBRARY to tango, phobos1 or phobos2 60 """ 61 ret = self.check_cc(features='d dprogram', fragment=DLIB, compile_filename='test.d', execute=execute, define_ret=True) 62 if execute: 63 self.env.DLIBRARY = ret.strip() 64