/
test_autotoolstoolchain.py
69 lines (56 loc) · 2.35 KB
/
test_autotoolstoolchain.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
66
67
68
import platform
import textwrap
from conans.test.assets.genconanfile import GenConanfile
from conans.test.utils.tools import TestClient
def test_extra_flags_via_conf():
os_ = platform.system()
os_ = "Macos" if os_ == "Darwin" else os_
profile = textwrap.dedent("""
[settings]
os=%s
compiler=gcc
compiler.version=6
compiler.libcxx=libstdc++11
arch=armv8
build_type=Release
[conf]
tools.build:cxxflags=["--flag1", "--flag2"]
tools.build:cflags+=["--flag3", "--flag4"]
tools.build:sharedlinkflags+=["--flag5"]
tools.build:exelinkflags+=["--flag6"]
tools.build:defines+=["DEF1", "DEF2"]
""" % os_)
client = TestClient()
conanfile = GenConanfile().with_settings("os", "arch", "compiler", "build_type")\
.with_generator("AutotoolsToolchain")
client.save({"conanfile.py": conanfile,
"profile": profile})
client.run("install . --profile:build=profile --profile:host=profile")
toolchain = client.load("conanautotoolstoolchain{}".format('.bat' if os_ == "Windows" else '.sh'))
if os_ == "Windows":
assert 'set "CPPFLAGS=%CPPFLAGS% -DNDEBUG -DDEF1 -DDEF2"' in toolchain
assert 'set "CXXFLAGS=%CXXFLAGS% -O3 -s --flag1 --flag2"' in toolchain
assert 'set "CFLAGS=%CFLAGS% -O3 -s --flag3 --flag4"' in toolchain
assert 'set "LDFLAGS=%LDFLAGS% --flag5 --flag6"' in toolchain
else:
assert 'export CPPFLAGS="$CPPFLAGS -DNDEBUG -DDEF1 -DDEF2"' in toolchain
assert 'export CXXFLAGS="$CXXFLAGS -O3 -s --flag1 --flag2"' in toolchain
assert 'export CFLAGS="$CFLAGS -O3 -s --flag3 --flag4"' in toolchain
assert 'export LDFLAGS="$LDFLAGS --flag5 --flag6"' in toolchain
def test_not_none_values():
conanfile = textwrap.dedent("""
from conan import ConanFile
from conan.tools.gnu import AutotoolsToolchain
class Foo(ConanFile):
name = "foo"
version = "1.0"
def generate(self):
tc = AutotoolsToolchain(self)
assert None not in tc.defines
assert None not in tc.cxxflags
assert None not in tc.cflags
assert None not in tc.ldflags
""")
client = TestClient()
client.save({"conanfile.py": conanfile})
client.run("install .")