Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutotoolsToolchain: empty None values from self fields + Refactor #11678

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions conan/tools/gnu/autotoolstoolchain.py
Expand Up @@ -152,14 +152,19 @@ def environment(self):
+ apple_flags + extra_flags["ldflags"])
self.defines.extend([self.ndebug, self.gcc_cxx11_abi] + extra_flags["defines"])

self.cxxflags = self._filter_list_empty_fields(self.cxxflags)
lasote marked this conversation as resolved.
Show resolved Hide resolved
self.cflags = self._filter_list_empty_fields(self.cflags)
self.ldflags = self._filter_list_empty_fields(self.ldflags)
self.defines = self._filter_list_empty_fields(self.defines)

if is_msvc(self._conanfile):
env.define("CXX", "cl")
env.define("CC", "cl")

env.append("CPPFLAGS", ["-D{}".format(d) for d in self._filter_list_empty_fields(self.defines)])
env.append("CXXFLAGS", self._filter_list_empty_fields(self.cxxflags))
env.append("CFLAGS", self._filter_list_empty_fields(self.cflags))
env.append("LDFLAGS", self._filter_list_empty_fields(self.ldflags))
env.append("CPPFLAGS", ["-D{}".format(d) for d in self.defines])
env.append("CXXFLAGS", self.cxxflags)
env.append("CFLAGS", self.cflags)
env.append("LDFLAGS", self.ldflags)
env.prepend_path("PKG_CONFIG_PATH", self._conanfile.generators_folder)

return env
Expand Down
26 changes: 26 additions & 0 deletions conans/test/integration/toolchains/gnu/test_autotoolstoolchain.py
Expand Up @@ -42,3 +42,29 @@ def test_extra_flags_via_conf():
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)
tc.environment()
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 .")