mirror of
https://gitlab.com/ita1024/waf.git
synced 2025-01-07 08:55:31 +01:00
Modify the generic compiler tools to use the "Configuration options" group.
Add a mechanism to set the compiler precedence for D, for consistency.
This commit is contained in:
parent
cffbb89cb4
commit
ca60d62bed
@ -48,7 +48,7 @@ c_compiler = {
|
|||||||
'default':['gcc'],
|
'default':['gcc'],
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Dict mapping the platform names to waf tools finding specific compilers::
|
Dict mapping the platform names to Waf tools finding specific C compilers::
|
||||||
|
|
||||||
from waflib.Tools.compiler_c import c_compiler
|
from waflib.Tools.compiler_c import c_compiler
|
||||||
c_compiler['linux'] = ['gcc', 'icc', 'suncc']
|
c_compiler['linux'] = ['gcc', 'icc', 'suncc']
|
||||||
@ -60,9 +60,10 @@ def configure(conf):
|
|||||||
"""
|
"""
|
||||||
try: test_for_compiler = conf.options.check_c_compiler
|
try: test_for_compiler = conf.options.check_c_compiler
|
||||||
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_c')")
|
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_c')")
|
||||||
for compiler in test_for_compiler.split():
|
|
||||||
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
conf.env.stash()
|
conf.env.stash()
|
||||||
conf.start_msg('Checking for %r (c compiler)' % compiler)
|
conf.start_msg('Checking for %r (C compiler)' % compiler)
|
||||||
try:
|
try:
|
||||||
conf.load(compiler)
|
conf.load(compiler)
|
||||||
except conf.errors.ConfigurationError as e:
|
except conf.errors.ConfigurationError as e:
|
||||||
@ -76,7 +77,7 @@ def configure(conf):
|
|||||||
break
|
break
|
||||||
conf.end_msg(False)
|
conf.end_msg(False)
|
||||||
else:
|
else:
|
||||||
conf.fatal('could not configure a c compiler!')
|
conf.fatal('could not configure a C compiler!')
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
"""
|
"""
|
||||||
@ -89,9 +90,9 @@ def options(opt):
|
|||||||
build_platform = Utils.unversioned_sys_platform()
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
possible_compiler_list = c_compiler[build_platform in c_compiler and build_platform or 'default']
|
possible_compiler_list = c_compiler[build_platform in c_compiler and build_platform or 'default']
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
test_for_compiler = ' '.join(possible_compiler_list)
|
||||||
cc_compiler_opts = opt.add_option_group("C Compiler Options")
|
cc_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
cc_compiler_opts.add_option('--check-c-compiler', default="%s" % test_for_compiler,
|
cc_compiler_opts.add_option('--check-c-compiler', default=test_for_compiler,
|
||||||
help='On this platform (%s) the following C-Compiler will be checked by default: "%s"' % (build_platform, test_for_compiler),
|
help='list of C compilers to try [%s]' % test_for_compiler,
|
||||||
dest="check_c_compiler")
|
dest="check_c_compiler")
|
||||||
for x in test_for_compiler.split():
|
for x in test_for_compiler.split():
|
||||||
opt.load('%s' % x)
|
opt.load('%s' % x)
|
||||||
|
@ -30,7 +30,7 @@ Not all compilers need to have a specific tool. For example, the clang compilers
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import os, sys, imp, types
|
import os, sys, imp, types, re
|
||||||
from waflib.Tools import ccroot
|
from waflib.Tools import ccroot
|
||||||
from waflib import Utils, Configure
|
from waflib import Utils, Configure
|
||||||
from waflib.Logs import debug
|
from waflib.Logs import debug
|
||||||
@ -49,7 +49,7 @@ cxx_compiler = {
|
|||||||
'default': ['g++']
|
'default': ['g++']
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Dict mapping the platform names to waf tools finding specific compilers::
|
Dict mapping the platform names to Waf tools finding specific C++ compilers::
|
||||||
|
|
||||||
from waflib.Tools.compiler_cxx import cxx_compiler
|
from waflib.Tools.compiler_cxx import cxx_compiler
|
||||||
cxx_compiler['linux'] = ['gxx', 'icpc', 'suncxx']
|
cxx_compiler['linux'] = ['gxx', 'icpc', 'suncxx']
|
||||||
@ -63,9 +63,9 @@ def configure(conf):
|
|||||||
try: test_for_compiler = conf.options.check_cxx_compiler
|
try: test_for_compiler = conf.options.check_cxx_compiler
|
||||||
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_cxx')")
|
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_cxx')")
|
||||||
|
|
||||||
for compiler in test_for_compiler.split():
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
conf.env.stash()
|
conf.env.stash()
|
||||||
conf.start_msg('Checking for %r (c++ compiler)' % compiler)
|
conf.start_msg('Checking for %r (C++ compiler)' % compiler)
|
||||||
try:
|
try:
|
||||||
conf.load(compiler)
|
conf.load(compiler)
|
||||||
except conf.errors.ConfigurationError as e:
|
except conf.errors.ConfigurationError as e:
|
||||||
@ -79,7 +79,7 @@ def configure(conf):
|
|||||||
break
|
break
|
||||||
conf.end_msg(False)
|
conf.end_msg(False)
|
||||||
else:
|
else:
|
||||||
conf.fatal('could not configure a c++ compiler!')
|
conf.fatal('could not configure a C++ compiler!')
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
"""
|
"""
|
||||||
@ -92,9 +92,9 @@ def options(opt):
|
|||||||
build_platform = Utils.unversioned_sys_platform()
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
possible_compiler_list = cxx_compiler[build_platform in cxx_compiler and build_platform or 'default']
|
possible_compiler_list = cxx_compiler[build_platform in cxx_compiler and build_platform or 'default']
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
test_for_compiler = ' '.join(possible_compiler_list)
|
||||||
cxx_compiler_opts = opt.add_option_group('C++ Compiler Options')
|
cxx_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
cxx_compiler_opts.add_option('--check-cxx-compiler', default="%s" % test_for_compiler,
|
cxx_compiler_opts.add_option('--check-cxx-compiler', default=test_for_compiler,
|
||||||
help='On this platform (%s) the following C++ Compiler will be checked by default: "%s"' % (build_platform, test_for_compiler),
|
help='list of C++ compilers to try [%s]' % test_for_compiler,
|
||||||
dest="check_cxx_compiler")
|
dest="check_cxx_compiler")
|
||||||
|
|
||||||
for x in test_for_compiler.split():
|
for x in test_for_compiler.split():
|
||||||
|
@ -20,16 +20,26 @@ Only three D compilers are really present at the moment:
|
|||||||
* ldc2
|
* ldc2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, sys, imp, types
|
import os, sys, imp, types, re
|
||||||
from waflib import Utils, Configure, Options, Logs
|
from waflib import Utils, Configure, Options, Logs
|
||||||
|
|
||||||
|
d_compiler = {
|
||||||
|
'default' : ['gdc', 'dmd', 'ldc2']
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
Dict mapping the platform names to lists of names of D compilers to try, in order of preference::
|
||||||
|
|
||||||
|
from waflib.Tools.compiler_d import d_compiler
|
||||||
|
d_compiler['default'] = ['gdc', 'dmd', 'ldc2']
|
||||||
|
"""
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
"""
|
"""
|
||||||
Try to find a suitable D compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
Try to find a suitable D compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
||||||
"""
|
"""
|
||||||
for compiler in conf.options.dcheck.split(','):
|
for compiler in re.split('[ ,]+', conf.options.dcheck):
|
||||||
conf.env.stash()
|
conf.env.stash()
|
||||||
conf.start_msg('Checking for %r (d compiler)' % compiler)
|
conf.start_msg('Checking for %r (D compiler)' % compiler)
|
||||||
try:
|
try:
|
||||||
conf.load(compiler)
|
conf.load(compiler)
|
||||||
except conf.errors.ConfigurationError as e:
|
except conf.errors.ConfigurationError as e:
|
||||||
@ -51,9 +61,12 @@ def options(opt):
|
|||||||
|
|
||||||
$ waf configure --check-d-compiler=dmd
|
$ waf configure --check-d-compiler=dmd
|
||||||
"""
|
"""
|
||||||
d_compiler_opts = opt.add_option_group('D Compiler Options')
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
d_compiler_opts.add_option('--check-d-compiler', default='gdc,dmd,ldc2', action='store',
|
possible_compiler_list = d_compiler[build_platform in cxx_compiler and build_platform or 'default']
|
||||||
help='check for the compiler [Default:gdc,dmd,ldc2]', dest='dcheck')
|
test_for_compiler = ' '.join(possible_compiler_list)
|
||||||
|
d_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
|
d_compiler_opts.add_option('--check-d-compiler', default=test_for_compiler, action='store',
|
||||||
|
help='list of D compilers to try [%s]' % test_for_compiler, dest='dcheck')
|
||||||
for d_compiler in ('gdc', 'dmd', 'ldc2'):
|
for d_compiler in ('gdc', 'dmd', 'ldc2'):
|
||||||
opt.load('%s' % d_compiler)
|
opt.load('%s' % d_compiler)
|
||||||
|
|
||||||
|
@ -13,6 +13,12 @@ fc_compiler = {
|
|||||||
'default': ['gfortran'],
|
'default': ['gfortran'],
|
||||||
'aix' : ['gfortran']
|
'aix' : ['gfortran']
|
||||||
}
|
}
|
||||||
|
"""
|
||||||
|
Dict mapping the platform names to lists of names of Fortran compilers to try, in order of preference::
|
||||||
|
|
||||||
|
from waflib.Tools.compiler_c import c_compiler
|
||||||
|
c_compiler['linux'] = ['gfortran', 'g95', 'ifort']
|
||||||
|
"""
|
||||||
|
|
||||||
def __list_possible_compiler(platform):
|
def __list_possible_compiler(platform):
|
||||||
try:
|
try:
|
||||||
@ -26,9 +32,9 @@ def configure(conf):
|
|||||||
"""
|
"""
|
||||||
try: test_for_compiler = conf.options.check_fc
|
try: test_for_compiler = conf.options.check_fc
|
||||||
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_fc')")
|
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_fc')")
|
||||||
for compiler in test_for_compiler.split():
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
conf.env.stash()
|
conf.env.stash()
|
||||||
conf.start_msg('Checking for %r (fortran compiler)' % compiler)
|
conf.start_msg('Checking for %r (Fortran compiler)' % compiler)
|
||||||
try:
|
try:
|
||||||
conf.load(compiler)
|
conf.load(compiler)
|
||||||
except conf.errors.ConfigurationError as e:
|
except conf.errors.ConfigurationError as e:
|
||||||
@ -52,13 +58,12 @@ def options(opt):
|
|||||||
"""
|
"""
|
||||||
opt.load_special_tools('fc_*.py')
|
opt.load_special_tools('fc_*.py')
|
||||||
build_platform = Utils.unversioned_sys_platform()
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
detected_platform = Options.platform
|
possible_compiler_list = fc_compiler[build_platform in cxx_compiler and build_platform or 'default']
|
||||||
possible_compiler_list = __list_possible_compiler(detected_platform)
|
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
test_for_compiler = ' '.join(possible_compiler_list)
|
||||||
fortran_compiler_opts = opt.add_option_group("Fortran Compiler Options")
|
fortran_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
fortran_compiler_opts.add_option('--check-fortran-compiler',
|
fortran_compiler_opts.add_option('--check-fortran-compiler',
|
||||||
default="%s" % test_for_compiler,
|
default=test_for_compiler,
|
||||||
help='On this platform (%s) the following Fortran Compiler will be checked by default: "%s"' % (detected_platform, test_for_compiler),
|
help='list of Fortran compiler to try [%s]' % test_for_compiler,
|
||||||
dest="check_fc")
|
dest="check_fc")
|
||||||
|
|
||||||
for compiler in test_for_compiler.split():
|
for compiler in test_for_compiler.split():
|
||||||
|
Loading…
Reference in New Issue
Block a user