3 # Carlos Rafael Giani, 2007 (dv)
4 # Thomas Nagy, 2016-2018 (ita)
7 Try to detect a D compiler from the list of supported compilers::
10 opt.load('compiler_d')
12 cnf.load('compiler_d')
14 bld.program(source='main.d', target='app')
16 Only three D compilers are really present at the moment:
19 * dmd, the ldc compiler having a very similar command-line interface
24 from waflib import Utils, Logs
27 'default' : ['gdc', 'dmd', 'ldc2']
30 Dict mapping the platform names to lists of names of D compilers to try, in order of preference::
32 from waflib.Tools.compiler_d import d_compiler
33 d_compiler['default'] = ['gdc', 'dmd', 'ldc2']
36 def default_compilers():
37 build_platform = Utils.unversioned_sys_platform()
38 possible_compiler_list = d_compiler.get(build_platform, d_compiler['default'])
39 return ' '.join(possible_compiler_list)
43 Detects a suitable D compiler
45 :raises: :py:class:`waflib.Errors.ConfigurationError` when no suitable compiler is found
48 test_for_compiler = conf.options.check_d_compiler or default_compilers()
49 except AttributeError:
50 conf.fatal("Add options(opt): opt.load('compiler_d')")
52 for compiler in re.split('[ ,]+', test_for_compiler):
54 conf.start_msg('Checking for %r (D compiler)' % compiler)
57 except conf.errors.ConfigurationError as e:
60 Logs.debug('compiler_d: %r', e)
63 conf.end_msg(conf.env.get_flat('D'))
64 conf.env.COMPILER_D = compiler
70 conf.fatal('could not configure a D compiler!')
74 This is how to provide compiler preferences on the command-line::
76 $ waf configure --check-d-compiler=dmd
78 test_for_compiler = default_compilers()
79 d_compiler_opts = opt.add_option_group('Configuration options')
80 d_compiler_opts.add_option('--check-d-compiler', default=None,
81 help='list of D compilers to try [%s]' % test_for_compiler, dest='check_d_compiler')
83 for x in test_for_compiler.split():