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

aggregate conf from build_requires earlier for declarative generators #9573

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions conans/client/generators/__init__.py
Expand Up @@ -141,6 +141,8 @@ def _new_generator(self, generator_name, output):
def write_generators(self, conanfile, old_gen_folder, new_gen_folder, output):
""" produces auxiliary files, required to build a project or a package.
"""
_receive_conf(conanfile)

for generator_name in set(conanfile.generators):
generator_class = self._new_generator(generator_name, output)
if generator_class:
Expand Down Expand Up @@ -226,8 +228,6 @@ def write_toolchain(conanfile, path, output):
"********************************************************************\n")
raise ConanException(msg)

_receive_conf(conanfile)

if hasattr(conanfile, "generate"):
output.highlight("Calling generate()")
mkdir(path)
Expand Down Expand Up @@ -270,4 +270,3 @@ def _generate_aggregated_env(conanfile):
{}
""".format(lines))
save(os.path.join(conanfile.generators_folder, "conanenv.bat"), bat_content)

42 changes: 42 additions & 0 deletions conans/test/integration/configuration/conf/test_conf_from_br.py
Expand Up @@ -70,3 +70,45 @@ def generate(self):
'-c:h=tools.android:ndk_path="MY-SYSTEM-NDK!!!"')
assert "android_ndk/1.0: NDK build: MY-NDK!!!" in client.out
assert "conanfile.py: NDK host: MY-SYSTEM-NDK!!!" in client.out


def test_declared_generators_get_conf():
# https://github.com/conan-io/conan/issues/9571
client = TestClient()
conanfile = textwrap.dedent("""
from conans import ConanFile
class Pkg(ConanFile):
def package_info(self):
self.conf_info["tools.cmake.cmaketoolchain:user_toolchain"] = "mytoolchain.cmake"
""")
client.save({"conanfile.py": conanfile})
client.run("create . mytool/1.0@")

consumer = textwrap.dedent("""
from conans import ConanFile

class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain"
build_requires = "mytool/1.0"
""")
client.save({"conanfile.py": consumer}, clean_first=True)
client.run("install . -pr:b=default")
toolchain = client.load("conan_toolchain.cmake")
assert "include(mytoolchain.cmake)" in toolchain

consumer = textwrap.dedent("""
from conans import ConanFile
from conan.tools.cmake import CMakeToolchain

class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
build_requires = "mytool/1.0"

def generate(self):
CMakeToolchain(self).generate()
""")
client.save({"conanfile.py": consumer}, clean_first=True)
client.run("install . -pr:b=default")
toolchain = client.load("conan_toolchain.cmake")
assert "include(mytoolchain.cmake)" in toolchain