Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get_gnu_deps_flags. Added functional test
- Loading branch information
1 parent
b7a8198
commit 5916833
Showing
3 changed files
with
130 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from conan.tools.gnu.autotools import Autotools | ||
from conan.tools.gnu.autotoolstoolchain import AutotoolsToolchain | ||
from conan.tools.gnu.autotoolsdeps import AutotoolsDeps | ||
from conan.tools.gnu.autotoolsdeps import AutotoolsDeps, get_gnu_deps_flags | ||
from conan.tools.gnu.pkgconfig import PkgConfig | ||
from conan.tools.gnu.pkgconfigdeps import PkgConfigDeps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
conans/test/functional/toolchains/meson/test_meson_and_gnu_deps_flags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |