-
Notifications
You must be signed in to change notification settings - Fork 949
/
test_meson_and_gnu_deps_flags.py
65 lines (50 loc) · 2.19 KB
/
test_meson_and_gnu_deps_flags.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import textwrap
import platform
import pytest
from conans.test.assets.sources import gen_function_cpp
from conans.test.functional.toolchains.meson._base import TestMesonBase
from conans.test.utils.tools import TestClient
class TestMesonToolchainAndGnuFlags(TestMesonBase):
@pytest.mark.skipif(platform.system() == "Windows", reason="Unix only")
def test_mesontoolchain_using_gnu_deps_flags(self):
client = TestClient(path_with_spaces=False)
client.run("new hello/0.1 -s")
client.run("create . hello/0.1@ %s" % self._settings_str)
app = gen_function_cpp(name="main", includes=["hello"], calls=["hello"])
conanfile_py = textwrap.dedent("""
from conan import ConanFile
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.gnu import get_gnu_deps_flags
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
requires = "hello/0.1"
def layout(self):
self.folders.build = "build"
def generate(self):
# Get GNU flags from all the dependencies
cflags, cxxflags, cpp_flags, libs, ldflags = get_gnu_deps_flags(self)
tc = MesonToolchain(self)
# Extend flags to MesonToolchain
tc.c_args.extend(cpp_flags)
tc.cpp_args.extend(cpp_flags)
tc.c_link_args.extend(ldflags)
tc.cpp_link_args.extend(ldflags)
tc.generate()
def build(self):
meson = Meson(self)
meson.configure()
meson.build()
""")
meson_build = textwrap.dedent("""
project('tutorial', 'cpp')
cxx = meson.get_compiler('cpp')
hello = cxx.find_library('hello', required: true)
executable('demo', 'main.cpp', dependencies: hello)
""")
client.save({"conanfile.py": conanfile_py,
"meson.build": meson_build,
"main.cpp": app},
clean_first=True)
client.run("install . %s" % self._settings_str)
client.run("build .")
assert "[2/2] Linking target demo" in client.out