Merge pull request #1253 from geier1993/intel

Intel C/C++ Compiler support
pull/1286/head
Jussi Pakkanen 8 years ago committed by GitHub
commit 35633c6865
  1. 5
      mesonbuild/backend/ninjabackend.py
  2. 211
      mesonbuild/compilers.py
  3. 8
      mesonbuild/environment.py
  4. 5
      run_project_tests.py
  5. 85
      run_unittests.py
  6. 5
      test cases/common/1 trivial/meson.build
  7. 3
      test cases/common/132 dependency file generation/main .c
  8. 12
      test cases/common/132 dependency file generation/meson.build
  9. 6
      test cases/common/2 cpp/meson.build
  10. 4
      test cases/common/25 object extraction/meson.build
  11. 8
      test cases/common/94 default options/meson.build
  12. 15
      test cases/d/3 shared library/meson.build
  13. 0
      test cases/d/3 shared library/no-installed-files
  14. 15
      test cases/d/4 library versions/meson.build
  15. 0
      test cases/d/4 library versions/no-installed-files
  16. 2
      test cases/failing build/1 vala c werror/unused-var.c
  17. 2
      test cases/fortran/1 basic/meson.build
  18. 0
      test cases/fortran/1 basic/simple.f90
  19. 2
      test cases/fortran/2 modules/meson.build
  20. 0
      test cases/fortran/2 modules/prog.f90
  21. 0
      test cases/fortran/2 modules/stuff.f90
  22. 0
      test cases/fortran/5 static/main.f90
  23. 4
      test cases/fortran/5 static/meson.build
  24. 0
      test cases/fortran/5 static/static_hello.f90
  25. 0
      test cases/fortran/6 dynamic/dynamic.f90
  26. 0
      test cases/fortran/6 dynamic/main.f90
  27. 4
      test cases/fortran/6 dynamic/meson.build
  28. 8
      test cases/frameworks/11 gir subproject/gir/meson.build
  29. 7
      test cases/frameworks/7 gnome/gir/meson.build
  30. 10
      test cases/frameworks/7 gnome/meson.build
  31. 12
      test cases/windows/7 mingw dll versioning/meson.build
  32. 0
      test cases/windows/7 mingw dll versioning/no-installed-files
  33. 12
      test cases/windows/8 msvc dll versioning/meson.build
  34. 0
      test cases/windows/8 msvc dll versioning/no-installed-files

@ -1837,6 +1837,8 @@ rule FORTRAN_DEP_HACK
pchlist = []
if len(pchlist) == 0:
pch_dep = []
elif compiler.id == 'intel':
pch_dep = []
else:
arr = []
i = os.path.join(self.get_target_private_dir(target), compiler.get_pch_name(pchlist[0]))
@ -1956,6 +1958,9 @@ rule FORTRAN_DEP_HACK
src = os.path.join(self.build_to_src, target.get_source_subdir(), pch[-1])
(commands, dep, dst, objs) = self.generate_msvc_pch_command(target, compiler, pch)
extradep = os.path.join(self.build_to_src, target.get_source_subdir(), pch[0])
elif compiler.id == 'intel':
# Intel generates on target generation
continue
else:
src = os.path.join(self.build_to_src, target.get_source_subdir(), pch[0])
(commands, dep, dst, objs) = self.generate_gcc_pch_command(target, compiler, pch[0])

@ -33,7 +33,9 @@ lib_suffixes = ('a', 'lib', 'dll', 'dylib', 'so')
lang_suffixes = {
'c': ('c',),
'cpp': ('cpp', 'cc', 'cxx', 'c++', 'hh', 'hpp', 'ipp', 'hxx'),
'fortran': ('f', 'f90', 'f95'),
# f90, f95, f03, f08 are for free-form fortran ('f90' recommended)
# f, for, ftn, fpp are for fixed-form fortran ('f' or 'for' recommended)
'fortran': ('f90', 'f95', 'f03', 'f08', 'f', 'for', 'ftn', 'fpp'),
'd': ('d', 'di'),
'objc': ('m',),
'objcpp': ('mm',),
@ -1683,9 +1685,10 @@ class GnuDCompiler(DCompiler):
def __init__(self, exelist, version, is_cross):
DCompiler.__init__(self, exelist, version, is_cross)
self.id = 'gcc'
self.warn_args = {'1': ['-Wall', '-Wdeprecated'],
'2': ['-Wall', '-Wextra', '-Wdeprecated'],
'3': ['-Wall', '-Wextra', '-Wdeprecated', '-Wpedantic']}
default_warn_args = ['-Wall', '-Wdeprecated']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
self.base_options = ['b_colorout', 'b_sanitize', 'b_staticpic']
def get_colorout_args(self, colortype):
@ -1923,7 +1926,7 @@ class VisualStudioCCompiler(CCompiler):
def gen_pch_args(self, header, source, pchname):
objname = os.path.splitext(pchname)[0] + '.obj'
return (objname, ['/Yc' + header, '/Fp' + pchname, '/Fo' + objname ])
return (objname, ['/Yc' + header, '/Fp' + pchname, '/Fo' + objname])
def gen_import_library_args(self, implibname):
"The name of the outputted import library"
@ -2064,6 +2067,10 @@ CLANG_OSX = 1
CLANG_WIN = 2
# Possibly clang-cl?
ICC_STANDARD = 0
ICC_OSX = 1
ICC_WIN = 2
def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module):
if soversion is None:
sostr = ''
@ -2148,9 +2155,10 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
GnuCompiler.__init__(self, gcc_type, defines)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']}
default_warn_args = ['-Wall', '-Winvalid-pch']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
opts = {'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
@ -2184,9 +2192,10 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap, defines):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
GnuCompiler.__init__(self, gcc_type, defines)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
opts = {'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
@ -2223,6 +2232,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
# too strict without this and always fails.
return self.get_no_optimization_args() + ['-fpermissive']
class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, defines=None):
@ -2230,9 +2240,10 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler):
# Not really correct, but GNU objc is only used on non-OSX non-win. File a bug
# if this breaks your use case.
GnuCompiler.__init__(self, GCC_STANDARD, defines)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']}
default_warn_args = ['-Wall', '-Winvalid-pch']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
@ -2241,9 +2252,10 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
# Not really correct, but GNU objc is only used on non-OSX non-win. File a bug
# if this breaks your use case.
GnuCompiler.__init__(self, GCC_STANDARD, defines)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_compiler_check_args(self):
# -fpermissive allows non-conforming code to compile which is necessary
@ -2283,7 +2295,7 @@ class ClangCompiler():
# Workaround for Clang bug http://llvm.org/bugs/show_bug.cgi?id=15136
# This flag is internal to Clang (or at least not documented on the man page)
# so it might change semantics at any time.
return ['-include-pch', os.path.join (pch_dir, self.get_pch_name (header))]
return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))]
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion, is_shared_module):
if self.clang_type == CLANG_STANDARD:
@ -2321,9 +2333,10 @@ class ClangCCompiler(ClangCompiler, CCompiler):
def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
ClangCompiler.__init__(self, clang_type)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']}
default_warn_args = ['-Wall', '-Winvalid-pch']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
return {'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
@ -2346,14 +2359,15 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
ClangCompiler.__init__(self, cltype)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
return {'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none', 'c++03', 'c++11', 'c++14', 'c++1z',
'gnu++03', 'gnu++11', 'gnu++14', 'gnu++1z'],
'gnu++11', 'gnu++14', 'gnu++1z'],
'none')}
def get_option_compile_args(self, options):
@ -2378,6 +2392,140 @@ class ClangObjCPPCompiler(ClangCompiler, GnuObjCPPCompiler):
ClangCompiler.__init__(self, cltype)
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1
class IntelCompiler:
def __init__(self, icc_type):
self.id = 'intel'
self.icc_type = icc_type
self.lang_header = 'none'
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
'b_colorout', 'b_ndebug', 'b_staticpic', 'b_lundef', 'b_asneeded']
# Assembly
self.can_compile_suffixes.add('s')
def get_pic_args(self):
return ['-fPIC']
def get_buildtype_args(self, buildtype):
return gnulike_buildtype_args[buildtype]
def get_buildtype_linker_args(self, buildtype):
return gnulike_buildtype_linker_args[buildtype]
def get_pch_suffix(self):
return 'pchi'
def get_pch_use_args(self, pch_dir, header):
return ['-pch', '-pch_dir', os.path.join(pch_dir), '-x',
self.lang_header, '-include', header, '-x', 'none']
def get_pch_name(self, header_name):
return os.path.split(header_name)[-1] + '.' + self.get_pch_suffix()
def split_shlib_to_parts(self, fname):
return (os.path.split(fname)[0], fname)
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion, is_shared_module):
if self.icc_type == ICC_STANDARD:
gcc_type = GCC_STANDARD
elif self.icc_type == ICC_OSX:
gcc_type = GCC_OSX
elif self.icc_type == ICC_WIN:
gcc_type = GCC_MINGW
else:
raise MesonException('Unreachable code when converting icc type to gcc type.')
return get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, is_shared_module)
def get_std_shared_lib_link_args(self):
# FIXME: Don't know how icc works on OSX
# if self.icc_type == ICC_OSX:
# return ['-bundle']
return ['-shared']
class IntelCCompiler(IntelCompiler, CCompiler):
def __init__(self, exelist, version, icc_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
IntelCompiler.__init__(self, icc_type)
self.lang_header = 'c-header'
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', '-Wpch-messages']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
c_stds = ['c89', 'c99']
g_stds = ['gnu89', 'gnu99']
if mesonlib.version_compare(self.version, '>=16.0.0'):
c_stds += ['c11']
opts = {'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
['none'] + c_stds + g_stds,
'none')}
return opts
def get_option_compile_args(self, options):
args = []
std = options['c_std']
if std.value != 'none':
args.append('-std=' + std.value)
return args
def get_std_shared_lib_link_args(self):
return ['-shared']
def has_multi_arguments(self, args, env):
return super(IntelCCompiler, self).has_multi_arguments(args + ['-diag-error', '10006'], env)
class IntelCPPCompiler(IntelCompiler, CPPCompiler):
def __init__(self, exelist, version, icc_type, is_cross, exe_wrap):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
IntelCompiler.__init__(self, icc_type)
self.lang_header = 'c++-header'
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark',
'-Wpch-messages', '-Wnon-virtual-dtor']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
'3': default_warn_args + ['-Wextra', '-Wpedantic']}
def get_options(self):
c_stds = []
g_stds = ['gnu++98']
if mesonlib.version_compare(self.version, '>=15.0.0'):
c_stds += ['c++11', 'c++14']
g_stds += ['gnu++11']
if mesonlib.version_compare(self.version, '>=16.0.0'):
c_stds += ['c++17']
if mesonlib.version_compare(self.version, '>=17.0.0'):
g_stds += ['gnu++14']
opts = {'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
['none'] + c_stds + g_stds,
'none'),
'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
'STL debug mode',
False)}
return opts
def get_option_compile_args(self, options):
args = []
std = options['cpp_std']
if std.value != 'none':
args.append('-std=' + std.value)
if options['cpp_debugstl'].value:
args.append('-D_GLIBCXX_DEBUG=1')
return args
def get_option_link_args(self, options):
return []
def get_compiler_check_args(self):
return self.get_no_optimization_args()
def has_multi_arguments(self, args, env):
return super(IntelCPPCompiler, self).has_multi_arguments(args + ['-diag-error', '10006'], env)
class FortranCompiler(Compiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
self.language = 'fortran'
@ -2558,12 +2706,15 @@ class SunFortranCompiler(FortranCompiler):
def get_module_outdir_args(self, path):
return ['-moddir=' + path]
class IntelFortranCompiler(FortranCompiler):
class IntelFortranCompiler(IntelCompiler, FortranCompiler):
std_warn_args = ['-warn', 'all']
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
self.file_suffixes = ('f', 'f90')
super().__init__(exelist, version, is_cross, exe_wrapper=None)
self.file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp')
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
# FIXME: Add support for OS X and Windows in detect_fortran_compiler so
# we are sent the type of compiler
IntelCompiler.__init__(self, ICC_STANDARD)
self.id = 'intel'
def get_module_outdir_args(self, path):
@ -2625,15 +2776,13 @@ class NAGFortranCompiler(FortranCompiler):
def get_module_outdir_args(self, path):
return ['-mdir', path]
def get_always_args(self):
return []
def get_warn_args(self, level):
return NAGFortranCompiler.std_warn_args
class VisualStudioLinker():
always_args = ['/NOLOGO']
def __init__(self, exelist):
self.exelist = exelist

@ -396,6 +396,10 @@ class Environment():
# everything else to stdout. Why? Lord only knows.
version = search_version(err)
return VisualStudioCCompiler([compiler], version, is_cross, exe_wrap)
if '(ICC)' in out:
# TODO: add microsoft add check OSX
inteltype = ICC_STANDARD
return IntelCCompiler(ccache + [compiler], version, inteltype, is_cross, exe_wrap)
errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"'
if popen_exceptions:
errmsg += '\nThe follow exceptions were encountered:'
@ -525,6 +529,10 @@ class Environment():
if 'Microsoft' in out or 'Microsoft' in err:
version = search_version(err)
return VisualStudioCPPCompiler([compiler], version, is_cross, exe_wrap)
if '(ICC)' in out:
# TODO: add microsoft add check OSX
inteltype = ICC_STANDARD
return IntelCPPCompiler(ccache + [compiler], version, inteltype, is_cross, exe_wrap)
errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"'
if popen_exceptions:
errmsg += '\nThe follow exceptions were encountered:'

@ -58,6 +58,11 @@ class AutoDeletedDir():
try:
shutil.rmtree(self.dir)
return
# Sometimes we get: ValueError: I/O operation on closed file.
except ValueError:
return
# Deleting can raise OSError or PermissionError on Windows
# (most likely because of anti-virus locking the file)
except (OSError, PermissionError):
if i == retries - 1:
mlog.warning('Could not delete temporary directory.')

@ -19,7 +19,7 @@ import re, json
import tempfile
from glob import glob
import mesonbuild.environment
from mesonbuild.environment import detect_ninja
from mesonbuild.environment import detect_ninja, Environment
from mesonbuild.dependencies import PkgConfigDependency
def get_soname(fname):
@ -33,6 +33,12 @@ def get_soname(fname):
return m.group(1)
raise RuntimeError('Could not determine soname:\n\n' + raw_out)
def get_fake_options():
import argparse
opts = argparse.Namespace()
opts.cross_file = None
return opts
class FakeEnvironment(object):
def __init__(self):
self.cross_info = None
@ -81,11 +87,13 @@ class LinuxlikeTests(unittest.TestCase):
def _run(self, command):
self.output += subprocess.check_output(command, env=os.environ.copy())
def init(self, srcdir):
def init(self, srcdir, extra_args=None):
if extra_args is None:
extra_args = []
args = [srcdir, self.builddir,
'--prefix', self.prefix,
'--libdir', self.libdir]
self._run(self.meson_command + args)
self._run(self.meson_command + args + extra_args)
self.privatedir = os.path.join(self.builddir, 'meson-private')
def build(self):
@ -170,7 +178,7 @@ class LinuxlikeTests(unittest.TestCase):
testdir = os.path.join(self.common_test_dir, '3 static')
self.init(testdir)
compdb = self.get_compdb()
self.assertTrue('-fPIC' in compdb[0]['command'])
self.assertIn('-fPIC', compdb[0]['command'])
# This is needed to increase the difference between build.ninja's
# timestamp and coredata.dat's timestamp due to a Ninja bug.
# https://github.com/ninja-build/ninja/issues/371
@ -179,7 +187,7 @@ class LinuxlikeTests(unittest.TestCase):
# Regenerate build
self.build()
compdb = self.get_compdb()
self.assertTrue('-fPIC' not in compdb[0]['command'])
self.assertNotIn('-fPIC', compdb[0]['command'])
def test_pkgconfig_gen(self):
'''
@ -196,7 +204,7 @@ class LinuxlikeTests(unittest.TestCase):
simple_dep = PkgConfigDependency('libfoo', env, kwargs)
self.assertTrue(simple_dep.found())
self.assertEqual(simple_dep.get_version(), '1.0')
self.assertTrue('-lfoo' in simple_dep.get_link_args())
self.assertIn('-lfoo', simple_dep.get_link_args())
def test_vala_c_warnings(self):
'''
@ -221,15 +229,15 @@ class LinuxlikeTests(unittest.TestCase):
self.assertIsNotNone(vala_command)
self.assertIsNotNone(c_command)
# -w suppresses all warnings, should be there in Vala but not in C
self.assertTrue('-w' in vala_command)
self.assertFalse('-w' in c_command)
self.assertIn("'-w'", vala_command)
self.assertNotIn("'-w'", c_command)
# -Wall enables all warnings, should be there in C but not in Vala
self.assertFalse('-Wall' in vala_command)
self.assertTrue('-Wall' in c_command)
self.assertNotIn("'-Wall'", vala_command)
self.assertIn("'-Wall'", c_command)
# -Werror converts warnings to errors, should always be there since it's
# injected by an unrelated piece of code and the project has werror=true
self.assertTrue('-Werror' in vala_command)
self.assertTrue('-Werror' in c_command)
self.assertIn("'-Werror'", vala_command)
self.assertIn("'-Werror'", c_command)
def test_static_compile_order(self):
'''
@ -410,6 +418,59 @@ class LinuxlikeTests(unittest.TestCase):
self.assertTrue('TEST_ENV is set' in vg_log)
self.assertTrue('Memcheck' in vg_log)
def _test_stds_impl(self, testdir, compiler, p):
lang_std = p + '_std'
# Check that all the listed -std=xxx options for this compiler work
# just fine when used
for v in compiler.get_options()[lang_std].choices:
std_opt = '{}={}'.format(lang_std, v)
self.init(testdir, ['-D' + std_opt])
cmd = self.get_compdb()[0]['command']
if v != 'none':
cmd_std = "'-std={}'".format(v)
self.assertIn(cmd_std, cmd)
try:
self.build()
except:
print('{} was {!r}'.format(lang_std, v))
raise
self.wipe()
# Check that an invalid std option in CFLAGS/CPPFLAGS fails
# Needed because by default ICC ignores invalid options
cmd_std = '-std=FAIL'
env_flags = p.upper() + 'FLAGS'
os.environ[env_flags] = cmd_std
self.init(testdir)
cmd = self.get_compdb()[0]['command']
qcmd_std = "'{}'".format(cmd_std)
self.assertIn(qcmd_std, cmd)
with self.assertRaises(subprocess.CalledProcessError,
msg='{} should have failed'.format(qcmd_std)):
self.build()
def test_compiler_c_stds(self):
'''
Test that C stds specified for this compiler can all be used. Can't be
an ordinary test because it requires passing options to meson.
'''
testdir = os.path.join(self.common_test_dir, '1 trivial')
env = Environment(testdir, self.builddir, self.meson_command,
get_fake_options(), [])
cc = env.detect_c_compiler(False)
self._test_stds_impl(testdir, cc, 'c')
def test_compiler_cpp_stds(self):
'''
Test that C++ stds specified for this compiler can all be used. Can't
be an ordinary test because it requires passing options to meson.
'''
testdir = os.path.join(self.common_test_dir, '2 cpp')
env = Environment(testdir, self.builddir, self.meson_command,
get_fake_options(), [])
cpp = env.detect_cpp_compiler(False)
self._test_stds_impl(testdir, cpp, 'cpp')
class RewriterTests(unittest.TestCase):
def setUp(self):

@ -6,6 +6,11 @@ project('trivial test',
#this is a comment
sources = 'trivial.c'
if meson.get_compiler('c').get_id() == 'intel'
# Error out if the -std=xxx option is incorrect
add_project_arguments('-diag-error', '10159', language : 'c')
endif
exe = executable('trivialprog', sources : sources)
test('runtest', exe) # This is a comment

@ -0,0 +1,3 @@
int main(int argc, char *argv[]) {
return 0;
}

@ -0,0 +1,12 @@
project('dep file gen', 'c')
cc_id = meson.get_compiler('c').get_id()
if cc_id == 'intel'
# ICC does not escape spaces in paths in the dependency file, so Ninja
# (correctly) thinks that the rule has multiple outputs and errors out:
# 'depfile has multiple output paths'
error('MESON_SKIP_TEST: Skipping test with Intel compiler because it generates broken dependency files')
endif
e = executable('main file', 'main .c')
test('test it', e)

@ -1,3 +1,9 @@
project('c++ test', 'cpp')
if meson.get_compiler('cpp').get_id() == 'intel'
# Error out if the -std=xxx option is incorrect
add_project_arguments('-diag-error', '10159', language : 'cpp')
endif
exe = executable('trivialprog', 'trivial.cc', extra_files : 'something.txt')
test('runtest', exe)

@ -9,8 +9,8 @@ else
obj1 = lib1.extract_objects('src/lib.c')
obj2 = lib2.extract_objects(['lib.c'])
e1 = executable('main 1', 'main.c', objects : obj1)
e2 = executable('main 2', 'main.c', objects : obj2)
e1 = executable('main1', 'main.c', objects : obj1)
e2 = executable('main2', 'main.c', objects : obj2)
test('extraction test 1', e1)
test('extraction test 2', e2)

@ -1,20 +1,20 @@
project('default options', 'cpp', 'c', default_options : [
'buildtype=debugoptimized',
'cpp_std=c++03',
'cpp_std=c++11',
'cpp_eh=none',
'warning_level=3',
])
cpp = meson.get_compiler('cpp')
cpp_id = meson.get_compiler('cpp').get_id()
assert(get_option('buildtype') == 'debugoptimized', 'Build type default value wrong.')
if cpp.get_id() == 'msvc'
if cpp_id == 'msvc'
cpp_eh = get_option('cpp_eh')
assert(cpp_eh == 'none', 'MSVC eh value is "' + cpp_eh + '" instead of "none"')
else
cpp_std = get_option('cpp_std')
assert(cpp_std == 'c++03', 'C++ std value is "' + cpp_std + '" instead of c++03.')
assert(cpp_std == 'c++11', 'C++ std value is "' + cpp_std + '" instead of c++11.')
endif
w_level = get_option('warning_level')

@ -1,12 +1,9 @@
project('D Shared Library', 'd')
if meson.get_compiler('d').get_id() != 'gcc'
ldyn = shared_library('stuff', 'libstuff.d', install : true)
ed = executable('app_d', 'app.d', link_with : ldyn, install : true)
test('linktest_dyn', ed)
else
message('GDC can not build shared libraries. Test skipped.')
install_data('no-installed-files', install_dir : '')
if meson.get_compiler('d').get_id() == 'gcc'
error('MESON_SKIP_TEST: GDC can not build shared libraries')
endif
ldyn = shared_library('stuff', 'libstuff.d', install : true)
ed = executable('app_d', 'app.d', link_with : ldyn, install : true)
test('linktest_dyn', ed)

@ -1,25 +1,22 @@
project('D library versions', 'd')
if meson.get_compiler('d').get_id() == 'gcc'
message('GDC can not build shared libraries. Test skipped.')
install_data('no-installed-files', install_dir : '')
else
error('MESON_SKIP_TEST: GDC can not build shared libraries')
endif
shared_library('some', 'lib.d',
shared_library('some', 'lib.d',
version : '1.2.3',
soversion : '0',
install : true)
shared_library('noversion', 'lib.d',
shared_library('noversion', 'lib.d',
install : true)
shared_library('onlyversion', 'lib.d',
shared_library('onlyversion', 'lib.d',
version : '1.4.5',
install : true)
shared_library('onlysoversion', 'lib.d',
shared_library('onlysoversion', 'lib.d',
# Also test that int soversion is acceptable
soversion : 5,
install : true)
endif

@ -1,3 +1,5 @@
#warning "something"
int
somelib(void)
{

@ -2,6 +2,6 @@ project('simple fortran', 'fortran')
add_global_arguments('-fbounds-check', language : 'fortran')
e = executable('simple', 'simple.f95',
e = executable('simple', 'simple.f90',
fortran_args : '-ffree-form')
test('Simple Fortran', e)

@ -1,4 +1,4 @@
project('modules', 'fortran')
e = executable('modprog', 'stuff.f95', 'prog.f95')
e = executable('modprog', 'stuff.f90', 'prog.f90')
test('moduletest', e)

@ -1,5 +1,5 @@
project('try-static-library', 'fortran')
static_hello = static_library('static_hello', 'static_hello.f95')
static_hello = static_library('static_hello', 'static_hello.f90')
executable('test_exe', 'main.f95', link_with : static_hello)
executable('test_exe', 'main.f90', link_with : static_hello)

@ -1,4 +1,4 @@
project('dynamic_fortran', 'fortran')
dynamic = shared_library('dynamic', 'dynamic.f95')
executable('test_exe', 'main.f95', link_with : dynamic)
dynamic = shared_library('dynamic', 'dynamic.f90')
executable('test_exe', 'main.f90', link_with : dynamic)

@ -28,8 +28,10 @@ gnome.generate_gir(
message('TEST: ' + girsubproject.outdir())
envdata = environment()
envdata.append('GI_TYPELIB_PATH', girsubproject.outdir(), 'subprojects/mesongir', separator : ':')
envdata.append('LD_LIBRARY_PATH', girsubproject.outdir(), 'subprojects/mesongir')
test('gobject introspection/subproject/c', girexe)
test('gobject introspection/subproject/py', find_program('prog.py'),
env : ['GI_TYPELIB_PATH=' + girsubproject.outdir() + ':subprojects/mesongir',
'LD_LIBRARY_PATH=' + girsubproject.outdir() + ':subprojects/mesongir',
])
env : envdata)

@ -33,7 +33,8 @@ gnome.generate_gir(
test('gobject introspection/c', girexe)
gir_paths = ':'.join([girlib.outdir(), dep1lib.outdir(), dep2lib.outdir()])
envdata = environment()
envdata.append('GI_TYPELIB_PATH', gir_paths, separator : ':')
envdata.append('LD_LIBRARY_PATH', gir_paths)
test('gobject introspection/py', find_program('prog.py'),
env : ['GI_TYPELIB_PATH=' + gir_paths,
'LD_LIBRARY_PATH=' + gir_paths,
])
env : envdata)

@ -1,5 +1,14 @@
project('gobject-introspection', 'c')
cc = meson.get_compiler('c')
add_global_arguments('-DMESON_TEST', language : 'c')
if cc.get_id() == 'intel'
# Ignore invalid GCC pragma warnings from glib
# https://bugzilla.gnome.org/show_bug.cgi?id=776562
add_global_arguments('-wd2282', language : 'c')
endif
gnome = import('gnome')
gio = dependency('gio-2.0')
giounix = dependency('gio-unix-2.0')
@ -7,7 +16,6 @@ glib = dependency('glib-2.0')
gobj = dependency('gobject-2.0')
gir = dependency('gobject-introspection-1.0')
gmod = dependency('gmodule-2.0')
add_global_arguments('-DMESON_TEST', language : 'c')
subdir('resources-data')
subdir('resources')

@ -2,16 +2,16 @@ project('mingw dll versioning', 'c')
cc = meson.get_compiler('c')
if cc.get_id() == 'msvc'
error('MESON_SKIP_TEST: test is only for MinGW')
endif
# Test that MinGW/GCC creates correctly-named dll files and dll.a files,
# and also installs them in the right place
if cc.get_id() != 'msvc'
shared_library('some', 'lib.c',
shared_library('some', 'lib.c',
version : '1.2.3',
soversion : '0',
install : true)
shared_library('noversion', 'lib.c',
shared_library('noversion', 'lib.c',
install : true)
else
install_data('no-installed-files', install_dir : '')
endif

@ -2,15 +2,15 @@ project('msvc dll versioning', 'c')
cc = meson.get_compiler('c')
if cc.get_id() != 'msvc'
error('MESON_SKIP_TEST: test is only for msvc')
endif
# Test that MSVC creates foo-0.dll and bar.dll
if cc.get_id() == 'msvc'
shared_library('some', 'lib.c',
shared_library('some', 'lib.c',
version : '1.2.3',
soversion : '0',
install : true)
shared_library('noversion', 'lib.c',
shared_library('noversion', 'lib.c',
install : true)
else
install_data('no-installed-files', install_dir : '')
endif

Loading…
Cancel
Save