|
|
@ -40,7 +40,7 @@ from mesonbuild.environment import Environment |
|
|
|
from mesonbuild.dependencies import DependencyException |
|
|
|
from mesonbuild.dependencies import DependencyException |
|
|
|
from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram |
|
|
|
from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram |
|
|
|
|
|
|
|
|
|
|
|
from run_tests import exe_suffix, get_fake_options, FakeEnvironment |
|
|
|
from run_tests import exe_suffix, get_fake_options |
|
|
|
from run_tests import get_builddir_target_args, get_backend_commands, Backend |
|
|
|
from run_tests import get_builddir_target_args, get_backend_commands, Backend |
|
|
|
from run_tests import ensure_backend_detects_changes, run_configure, meson_exe |
|
|
|
from run_tests import ensure_backend_detects_changes, run_configure, meson_exe |
|
|
|
from run_tests import should_run_linux_cross_tests |
|
|
|
from run_tests import should_run_linux_cross_tests |
|
|
@ -1061,16 +1061,17 @@ class AllPlatformTests(BasePlatformTests): |
|
|
|
evalue = os.environ.pop(evar) |
|
|
|
evalue = os.environ.pop(evar) |
|
|
|
# Very rough/strict heuristics. Would never work for actual |
|
|
|
# Very rough/strict heuristics. Would never work for actual |
|
|
|
# compiler detection, but should be ok for the tests. |
|
|
|
# compiler detection, but should be ok for the tests. |
|
|
|
if os.path.basename(evalue).startswith('g'): |
|
|
|
ebase = os.path.basename(evalue) |
|
|
|
|
|
|
|
if ebase.startswith('g') or ebase.endswith(('-gcc', '-g++')): |
|
|
|
self.assertIsInstance(ecc, gnu) |
|
|
|
self.assertIsInstance(ecc, gnu) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
elif 'clang' in os.path.basename(evalue): |
|
|
|
elif 'clang' in ebase: |
|
|
|
self.assertIsInstance(ecc, clang) |
|
|
|
self.assertIsInstance(ecc, clang) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
elif os.path.basename(evalue).startswith('ic'): |
|
|
|
elif ebase.startswith('ic'): |
|
|
|
self.assertIsInstance(ecc, intel) |
|
|
|
self.assertIsInstance(ecc, intel) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
self.assertIsInstance(elinker, ar) |
|
|
|
elif os.path.basename(evalue).startswith('cl'): |
|
|
|
elif ebase.startswith('cl'): |
|
|
|
self.assertIsInstance(ecc, msvc) |
|
|
|
self.assertIsInstance(ecc, msvc) |
|
|
|
self.assertIsInstance(elinker, lib) |
|
|
|
self.assertIsInstance(elinker, lib) |
|
|
|
else: |
|
|
|
else: |
|
|
@ -1398,6 +1399,7 @@ int main(int argc, char **argv) { |
|
|
|
env = Environment('', self.builddir, self.meson_command, |
|
|
|
env = Environment('', self.builddir, self.meson_command, |
|
|
|
get_fake_options(self.prefix), []) |
|
|
|
get_fake_options(self.prefix), []) |
|
|
|
cc = env.detect_c_compiler(False) |
|
|
|
cc = env.detect_c_compiler(False) |
|
|
|
|
|
|
|
stlinker = env.detect_static_linker(cc) |
|
|
|
if mesonbuild.mesonlib.is_windows(): |
|
|
|
if mesonbuild.mesonlib.is_windows(): |
|
|
|
object_suffix = 'obj' |
|
|
|
object_suffix = 'obj' |
|
|
|
shared_suffix = 'dll' |
|
|
|
shared_suffix = 'dll' |
|
|
@ -1410,7 +1412,7 @@ int main(int argc, char **argv) { |
|
|
|
else: |
|
|
|
else: |
|
|
|
object_suffix = 'o' |
|
|
|
object_suffix = 'o' |
|
|
|
shared_suffix = 'so' |
|
|
|
shared_suffix = 'so' |
|
|
|
return (cc, object_suffix, shared_suffix) |
|
|
|
return (cc, stlinker, object_suffix, shared_suffix) |
|
|
|
|
|
|
|
|
|
|
|
def pbcompile(self, compiler, source, objectfile, extra_args=[]): |
|
|
|
def pbcompile(self, compiler, source, objectfile, extra_args=[]): |
|
|
|
cmd = compiler.get_exelist() |
|
|
|
cmd = compiler.get_exelist() |
|
|
@ -1422,7 +1424,7 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_prebuilt_object(self): |
|
|
|
def test_prebuilt_object(self): |
|
|
|
(compiler, object_suffix, _) = self.detect_prebuild_env() |
|
|
|
(compiler, _, object_suffix, _) = self.detect_prebuild_env() |
|
|
|
tdir = os.path.join(self.unit_test_dir, '14 prebuilt object') |
|
|
|
tdir = os.path.join(self.unit_test_dir, '14 prebuilt object') |
|
|
|
source = os.path.join(tdir, 'source.c') |
|
|
|
source = os.path.join(tdir, 'source.c') |
|
|
|
objectfile = os.path.join(tdir, 'prebuilt.' + object_suffix) |
|
|
|
objectfile = os.path.join(tdir, 'prebuilt.' + object_suffix) |
|
|
@ -1434,13 +1436,18 @@ int main(int argc, char **argv) { |
|
|
|
finally: |
|
|
|
finally: |
|
|
|
os.unlink(objectfile) |
|
|
|
os.unlink(objectfile) |
|
|
|
|
|
|
|
|
|
|
|
def build_static_lib(self, compiler, source, objectfile, outfile, extra_args=None): |
|
|
|
def build_static_lib(self, compiler, linker, source, objectfile, outfile, extra_args=None): |
|
|
|
if extra_args is None: |
|
|
|
if extra_args is None: |
|
|
|
extra_args = [] |
|
|
|
extra_args = [] |
|
|
|
if compiler.id == 'msvc': |
|
|
|
if compiler.id == 'msvc': |
|
|
|
link_cmd = ['lib', '/NOLOGO', '/OUT:' + outfile, objectfile] |
|
|
|
link_cmd = ['lib', '/NOLOGO', '/OUT:' + outfile, objectfile] |
|
|
|
else: |
|
|
|
else: |
|
|
|
link_cmd = ['ar', 'csr', outfile, objectfile] |
|
|
|
link_cmd = ['ar', 'csr', outfile, objectfile] |
|
|
|
|
|
|
|
link_cmd = linker.get_exelist() |
|
|
|
|
|
|
|
link_cmd += linker.get_always_args() |
|
|
|
|
|
|
|
link_cmd += linker.get_std_link_args() |
|
|
|
|
|
|
|
link_cmd += linker.get_output_args(outfile) |
|
|
|
|
|
|
|
link_cmd += [objectfile] |
|
|
|
self.pbcompile(compiler, source, objectfile, extra_args=extra_args) |
|
|
|
self.pbcompile(compiler, source, objectfile, extra_args=extra_args) |
|
|
|
try: |
|
|
|
try: |
|
|
|
subprocess.check_call(link_cmd) |
|
|
|
subprocess.check_call(link_cmd) |
|
|
@ -1448,12 +1455,12 @@ int main(int argc, char **argv) { |
|
|
|
os.unlink(objectfile) |
|
|
|
os.unlink(objectfile) |
|
|
|
|
|
|
|
|
|
|
|
def test_prebuilt_static_lib(self): |
|
|
|
def test_prebuilt_static_lib(self): |
|
|
|
(cc, object_suffix, _) = self.detect_prebuild_env() |
|
|
|
(cc, stlinker, object_suffix, _) = self.detect_prebuild_env() |
|
|
|
tdir = os.path.join(self.unit_test_dir, '15 prebuilt static') |
|
|
|
tdir = os.path.join(self.unit_test_dir, '15 prebuilt static') |
|
|
|
source = os.path.join(tdir, 'libdir/best.c') |
|
|
|
source = os.path.join(tdir, 'libdir/best.c') |
|
|
|
objectfile = os.path.join(tdir, 'libdir/best.' + object_suffix) |
|
|
|
objectfile = os.path.join(tdir, 'libdir/best.' + object_suffix) |
|
|
|
stlibfile = os.path.join(tdir, 'libdir/libbest.a') |
|
|
|
stlibfile = os.path.join(tdir, 'libdir/libbest.a') |
|
|
|
self.build_static_lib(cc, source, objectfile, stlibfile) |
|
|
|
self.build_static_lib(cc, stlinker, source, objectfile, stlibfile) |
|
|
|
# Run the test |
|
|
|
# Run the test |
|
|
|
try: |
|
|
|
try: |
|
|
|
self.init(tdir) |
|
|
|
self.init(tdir) |
|
|
@ -1480,7 +1487,7 @@ int main(int argc, char **argv) { |
|
|
|
os.unlink(objectfile) |
|
|
|
os.unlink(objectfile) |
|
|
|
|
|
|
|
|
|
|
|
def test_prebuilt_shared_lib(self): |
|
|
|
def test_prebuilt_shared_lib(self): |
|
|
|
(cc, object_suffix, shared_suffix) = self.detect_prebuild_env() |
|
|
|
(cc, _, object_suffix, shared_suffix) = self.detect_prebuild_env() |
|
|
|
tdir = os.path.join(self.unit_test_dir, '16 prebuilt shared') |
|
|
|
tdir = os.path.join(self.unit_test_dir, '16 prebuilt shared') |
|
|
|
source = os.path.join(tdir, 'alexandria.c') |
|
|
|
source = os.path.join(tdir, 'alexandria.c') |
|
|
|
objectfile = os.path.join(tdir, 'alexandria.' + object_suffix) |
|
|
|
objectfile = os.path.join(tdir, 'alexandria.' + object_suffix) |
|
|
@ -1514,7 +1521,7 @@ int main(int argc, char **argv) { |
|
|
|
''' |
|
|
|
''' |
|
|
|
if not shutil.which('pkg-config'): |
|
|
|
if not shutil.which('pkg-config'): |
|
|
|
raise unittest.SkipTest('pkg-config not found') |
|
|
|
raise unittest.SkipTest('pkg-config not found') |
|
|
|
(cc, objext, shext) = self.detect_prebuild_env() |
|
|
|
(cc, stlinker, objext, shext) = self.detect_prebuild_env() |
|
|
|
testdir = os.path.join(self.unit_test_dir, '17 pkgconfig static') |
|
|
|
testdir = os.path.join(self.unit_test_dir, '17 pkgconfig static') |
|
|
|
source = os.path.join(testdir, 'foo.c') |
|
|
|
source = os.path.join(testdir, 'foo.c') |
|
|
|
objectfile = os.path.join(testdir, 'foo.' + objext) |
|
|
|
objectfile = os.path.join(testdir, 'foo.' + objext) |
|
|
@ -1527,7 +1534,7 @@ int main(int argc, char **argv) { |
|
|
|
else: |
|
|
|
else: |
|
|
|
shlibfile = os.path.join(testdir, 'libfoo.' + shext) |
|
|
|
shlibfile = os.path.join(testdir, 'libfoo.' + shext) |
|
|
|
# Build libs |
|
|
|
# Build libs |
|
|
|
self.build_static_lib(cc, source, objectfile, stlibfile, extra_args=['-DFOO_STATIC']) |
|
|
|
self.build_static_lib(cc, stlinker, source, objectfile, stlibfile, extra_args=['-DFOO_STATIC']) |
|
|
|
self.build_shared_lib(cc, source, objectfile, shlibfile, impfile) |
|
|
|
self.build_shared_lib(cc, source, objectfile, shlibfile, impfile) |
|
|
|
# Run test |
|
|
|
# Run test |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.builddir |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.builddir |
|
|
@ -1555,7 +1562,8 @@ int main(int argc, char **argv) { |
|
|
|
'--libdir=' + libdir]) |
|
|
|
'--libdir=' + libdir]) |
|
|
|
# Find foo dependency |
|
|
|
# Find foo dependency |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir |
|
|
|
env = FakeEnvironment() |
|
|
|
env = Environment(testdir, self.builddir, self.meson_command, |
|
|
|
|
|
|
|
get_fake_options(self.prefix), []) |
|
|
|
kwargs = {'required': True, 'silent': True} |
|
|
|
kwargs = {'required': True, 'silent': True} |
|
|
|
foo_dep = PkgConfigDependency('libfoo', env, kwargs) |
|
|
|
foo_dep = PkgConfigDependency('libfoo', env, kwargs) |
|
|
|
# Ensure link_args are properly quoted |
|
|
|
# Ensure link_args are properly quoted |
|
|
@ -1875,7 +1883,8 @@ class LinuxlikeTests(BasePlatformTests): |
|
|
|
''' |
|
|
|
''' |
|
|
|
testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen') |
|
|
|
testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen') |
|
|
|
self.init(testdir) |
|
|
|
self.init(testdir) |
|
|
|
env = FakeEnvironment() |
|
|
|
env = Environment(testdir, self.builddir, self.meson_command, |
|
|
|
|
|
|
|
get_fake_options(self.prefix), []) |
|
|
|
kwargs = {'required': True, 'silent': True} |
|
|
|
kwargs = {'required': True, 'silent': True} |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir |
|
|
|
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir |
|
|
|
foo_dep = PkgConfigDependency('libfoo', env, kwargs) |
|
|
|
foo_dep = PkgConfigDependency('libfoo', env, kwargs) |
|
|
@ -2259,8 +2268,9 @@ class LinuxlikeTests(BasePlatformTests): |
|
|
|
raise unittest.SkipTest('gcovr not found') |
|
|
|
raise unittest.SkipTest('gcovr not found') |
|
|
|
if not shutil.which('genhtml'): |
|
|
|
if not shutil.which('genhtml'): |
|
|
|
raise unittest.SkipTest('genhtml not found') |
|
|
|
raise unittest.SkipTest('genhtml not found') |
|
|
|
if 'clang' in os.environ.get('CC', '') and os.environ.get('TRAVIS_OS_NAME', '') == 'linux': |
|
|
|
if 'clang' in os.environ.get('CC', ''): |
|
|
|
raise unittest.SkipTest('Gcovr has a bug and does not work with Clang in the CI environment.') |
|
|
|
# We need to use llvm-cov instead of gcovr with clang |
|
|
|
|
|
|
|
raise unittest.SkipTest('Coverage does not work with clang right now, help wanted!') |
|
|
|
testdir = os.path.join(self.common_test_dir, '1 trivial') |
|
|
|
testdir = os.path.join(self.common_test_dir, '1 trivial') |
|
|
|
self.init(testdir, ['-Db_coverage=true']) |
|
|
|
self.init(testdir, ['-Db_coverage=true']) |
|
|
|
self.build() |
|
|
|
self.build() |
|
|
|