mirror of https://gitlab.com/ita1024/waf.git
Fix defining the xxx_compiler variables in configure().
Due to recent changes, setting xxx_compiler in configure() had no effect. This commit fixes the problem and changes the examples to show setting the xxx_compiler variables at the top level of the wscript, so that the default compilers are correctly reported in the help output.
This commit is contained in:
parent
a71edf58e7
commit
f88bf4f554
|
@ -15,11 +15,12 @@ Try to detect a C compiler from the list of supported compilers (gcc, msvc, etc)
|
||||||
The compilers are associated to platforms in :py:attr:`waflib.Tools.compiler_c.c_compiler`. To register
|
The compilers are associated to platforms in :py:attr:`waflib.Tools.compiler_c.c_compiler`. To register
|
||||||
a new C compiler named *cfoo* (assuming the tool ``waflib/extras/cfoo.py`` exists), use::
|
a new C compiler named *cfoo* (assuming the tool ``waflib/extras/cfoo.py`` exists), use::
|
||||||
|
|
||||||
|
from waflib.Tools.compiler_c import c_compiler
|
||||||
|
c_compiler['win32'] = ['cfoo', 'msvc', 'gcc']
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load('compiler_c')
|
opt.load('compiler_c')
|
||||||
def configure(cnf):
|
def configure(cnf):
|
||||||
from waflib.Tools.compiler_c import c_compiler
|
|
||||||
c_compiler['win32'] = ['cfoo', 'msvc', 'gcc']
|
|
||||||
cnf.load('compiler_c')
|
cnf.load('compiler_c')
|
||||||
def build(bld):
|
def build(bld):
|
||||||
bld.program(source='main.c', target='app')
|
bld.program(source='main.c', target='app')
|
||||||
|
@ -54,11 +55,16 @@ Dict mapping the platform names to Waf tools finding specific C compilers::
|
||||||
c_compiler['linux'] = ['gcc', 'icc', 'suncc']
|
c_compiler['linux'] = ['gcc', 'icc', 'suncc']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def default_compilers():
|
||||||
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
|
possible_compiler_list = c_compiler.get(build_platform, c_compiler['default'])
|
||||||
|
return ' '.join(possible_compiler_list)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
"""
|
"""
|
||||||
Try to find a suitable C compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
Try to find a suitable C compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
||||||
"""
|
"""
|
||||||
try: test_for_compiler = conf.options.check_c_compiler
|
try: test_for_compiler = conf.options.check_c_compiler or default_compilers()
|
||||||
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 re.split('[ ,]+', test_for_compiler):
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
|
@ -85,15 +91,13 @@ def options(opt):
|
||||||
|
|
||||||
$ waf configure --check-c-compiler=gcc
|
$ waf configure --check-c-compiler=gcc
|
||||||
"""
|
"""
|
||||||
|
test_for_compiler = default_compilers()
|
||||||
opt.load_special_tools('c_*.py', ban=['c_dumbpreproc.py'])
|
opt.load_special_tools('c_*.py', ban=['c_dumbpreproc.py'])
|
||||||
global c_compiler
|
|
||||||
build_platform = Utils.unversioned_sys_platform()
|
|
||||||
possible_compiler_list = c_compiler.get(build_platform, c_compiler['default'])
|
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
|
||||||
cc_compiler_opts = opt.add_option_group('Configuration options')
|
cc_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
cc_compiler_opts.add_option('--check-c-compiler', default=test_for_compiler,
|
cc_compiler_opts.add_option('--check-c-compiler', default=None,
|
||||||
help='list of C compilers to try [%s]' % 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)
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,12 @@ Try to detect a C++ compiler from the list of supported compilers (g++, msvc, et
|
||||||
The compilers are associated to platforms in :py:attr:`waflib.Tools.compiler_cxx.cxx_compiler`. To register
|
The compilers are associated to platforms in :py:attr:`waflib.Tools.compiler_cxx.cxx_compiler`. To register
|
||||||
a new C++ compiler named *cfoo* (assuming the tool ``waflib/extras/cfoo.py`` exists), use::
|
a new C++ compiler named *cfoo* (assuming the tool ``waflib/extras/cfoo.py`` exists), use::
|
||||||
|
|
||||||
|
from waflib.Tools.compiler_cxx import cxx_compiler
|
||||||
|
cxx_compiler['win32'] = ['cfoo', 'msvc', 'gcc']
|
||||||
|
|
||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load('compiler_cxx')
|
opt.load('compiler_cxx')
|
||||||
def configure(cnf):
|
def configure(cnf):
|
||||||
from waflib.Tools.compiler_cxx import cxx_compiler
|
|
||||||
cxx_compiler['win32'] = ['cfoo', 'msvc', 'gcc']
|
|
||||||
cnf.load('compiler_cxx')
|
cnf.load('compiler_cxx')
|
||||||
def build(bld):
|
def build(bld):
|
||||||
bld.program(source='main.c', target='app')
|
bld.program(source='main.c', target='app')
|
||||||
|
@ -55,12 +56,16 @@ Dict mapping the platform names to Waf tools finding specific C++ compilers::
|
||||||
cxx_compiler['linux'] = ['gxx', 'icpc', 'suncxx']
|
cxx_compiler['linux'] = ['gxx', 'icpc', 'suncxx']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def default_compilers():
|
||||||
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
|
possible_compiler_list = cxx_compiler.get(build_platform, cxx_compiler['default'])
|
||||||
|
return ' '.join(possible_compiler_list)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
"""
|
"""
|
||||||
Try to find a suitable C++ compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
Try to find a suitable C++ compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
||||||
"""
|
"""
|
||||||
try: test_for_compiler = conf.options.check_cxx_compiler
|
try: test_for_compiler = conf.options.check_cxx_compiler or default_compilers()
|
||||||
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 re.split('[ ,]+', test_for_compiler):
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
|
@ -87,13 +92,10 @@ def options(opt):
|
||||||
|
|
||||||
$ waf configure --check-cxx-compiler=gxx
|
$ waf configure --check-cxx-compiler=gxx
|
||||||
"""
|
"""
|
||||||
|
test_for_compiler = default_compilers()
|
||||||
opt.load_special_tools('cxx_*.py')
|
opt.load_special_tools('cxx_*.py')
|
||||||
global cxx_compiler
|
|
||||||
build_platform = Utils.unversioned_sys_platform()
|
|
||||||
possible_compiler_list = cxx_compiler.get(build_platform, cxx_compiler['default'])
|
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
|
||||||
cxx_compiler_opts = opt.add_option_group('Configuration options')
|
cxx_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
cxx_compiler_opts.add_option('--check-cxx-compiler', default=test_for_compiler,
|
cxx_compiler_opts.add_option('--check-cxx-compiler', default=None,
|
||||||
help='list of C++ compilers to try [%s]' % test_for_compiler,
|
help='list of C++ compilers to try [%s]' % test_for_compiler,
|
||||||
dest="check_cxx_compiler")
|
dest="check_cxx_compiler")
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,19 @@ Dict mapping the platform names to lists of names of D compilers to try, in orde
|
||||||
d_compiler['default'] = ['gdc', 'dmd', 'ldc2']
|
d_compiler['default'] = ['gdc', 'dmd', 'ldc2']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def default_compilers():
|
||||||
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
|
possible_compiler_list = d_compiler.get(build_platform, d_compiler['default'])
|
||||||
|
return ' '.join(possible_compiler_list)
|
||||||
|
|
||||||
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 re.split('[ ,]+', conf.options.dcheck):
|
try: test_for_compiler = conf.options.check_d_compiler or default_compilers()
|
||||||
|
except AttributeError: conf.fatal("Add options(opt): opt.load('compiler_d')")
|
||||||
|
|
||||||
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
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:
|
||||||
|
@ -61,12 +69,11 @@ def options(opt):
|
||||||
|
|
||||||
$ waf configure --check-d-compiler=dmd
|
$ waf configure --check-d-compiler=dmd
|
||||||
"""
|
"""
|
||||||
build_platform = Utils.unversioned_sys_platform()
|
test_for_compiler = default_compilers()
|
||||||
possible_compiler_list = d_compiler.get(build_platform, d_compiler['default'])
|
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
|
||||||
d_compiler_opts = opt.add_option_group('Configuration options')
|
d_compiler_opts = opt.add_option_group('Configuration options')
|
||||||
d_compiler_opts.add_option('--check-d-compiler', default=test_for_compiler, action='store',
|
d_compiler_opts.add_option('--check-d-compiler', default=None,
|
||||||
help='list of D compilers to try [%s]' % test_for_compiler, dest='dcheck')
|
help='list of D compilers to try [%s]' % test_for_compiler, dest='check_d_compiler')
|
||||||
for d_compiler in ('gdc', 'dmd', 'ldc2'):
|
|
||||||
opt.load('%s' % d_compiler)
|
for x in test_for_compiler.split():
|
||||||
|
opt.load('%s' % x)
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,16 @@ Dict mapping the platform names to lists of names of Fortran compilers to try, i
|
||||||
c_compiler['linux'] = ['gfortran', 'g95', 'ifort']
|
c_compiler['linux'] = ['gfortran', 'g95', 'ifort']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def default_compilers():
|
||||||
|
build_platform = Utils.unversioned_sys_platform()
|
||||||
|
possible_compiler_list = fc_compiler.get(build_platform, fc_compiler['default'])
|
||||||
|
return ' '.join(possible_compiler_list)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
"""
|
"""
|
||||||
Try to find a suitable Fortran compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
Try to find a suitable Fortran compiler or raise a :py:class:`waflib.Errors.ConfigurationError`.
|
||||||
"""
|
"""
|
||||||
try: test_for_compiler = conf.options.check_fc
|
try: test_for_compiler = conf.options.check_fortran_compiler or default_compilers()
|
||||||
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 re.split('[ ,]+', test_for_compiler):
|
for compiler in re.split('[ ,]+', test_for_compiler):
|
||||||
conf.env.stash()
|
conf.env.stash()
|
||||||
|
@ -50,16 +55,13 @@ def options(opt):
|
||||||
|
|
||||||
$ waf configure --check-fortran-compiler=ifort
|
$ waf configure --check-fortran-compiler=ifort
|
||||||
"""
|
"""
|
||||||
|
test_for_compiler = default_compilers()
|
||||||
opt.load_special_tools('fc_*.py')
|
opt.load_special_tools('fc_*.py')
|
||||||
build_platform = Utils.unversioned_sys_platform()
|
|
||||||
possible_compiler_list = fc_compiler.get(build_platform, fc_compiler['default'])
|
|
||||||
test_for_compiler = ' '.join(possible_compiler_list)
|
|
||||||
fortran_compiler_opts = opt.add_option_group('Configuration 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=None,
|
||||||
default=test_for_compiler,
|
|
||||||
help='list of Fortran compiler to try [%s]' % test_for_compiler,
|
help='list of Fortran compiler to try [%s]' % test_for_compiler,
|
||||||
dest="check_fc")
|
dest="check_fortran_compiler")
|
||||||
|
|
||||||
for compiler in test_for_compiler.split():
|
for x in test_for_compiler.split():
|
||||||
opt.load('%s' % compiler)
|
opt.load('%s' % x)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue