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

[bug] PremakeDeps not working for conan 1.62.0 #15380

Open
KingKiller100 opened this issue Jan 3, 2024 · 3 comments
Open

[bug] PremakeDeps not working for conan 1.62.0 #15380

KingKiller100 opened this issue Jan 3, 2024 · 3 comments

Comments

@KingKiller100
Copy link

KingKiller100 commented Jan 3, 2024

Environment details

  • Operating System+version: Windows 11 Pro (22H2)
  • Compiler+version: Visual Studio (I use 10 & 17 but I believe any version will see the same error)
  • Conan version: 1.62.0
  • Python version: 3.12.1

Steps to reproduce

Salutations & Happy New Year 🥳,

I have tried using the built-in premake generator for my project to help me generate build files, but I noticed the installation fails when the PremakeDeps generator tries to generate its files. I read the source code for v1.62.0 and noticed the issue occurs on this line of the code, conan\tools\premake\premakedeps.py: line 52. I thought this was a user error so I looked at docs and tests as a reference for how to use the generator but nothing helped.

I've created an example script to repro the issue so you could debug and help me with the bug I've found. Cheers in advance

  1. Create an empty directory
  2. Run the following command: conan new -m msbuild_lib pkg/1.0
  3. Update the generated conan recipe's contents to this:
import os

from conan import ConanFile
from conan.tools.microsoft import MSBuildToolchain, MSBuild, vs_layout
from conan.tools.files import copy


class Conan(ConanFile):
    name = "pkg"
    version = "1.0"
    settings = "os", "compiler", "build_type", "arch"
    generators = "PremakeDeps", "MSBuildDeps", "MSBuildToolchain"
    exports_sources = "pkg.sln", "pkg.vcxproj", "src/*", "include/*"
    short_paths = True

    default_options = {
        "fmt:header_only": True
    }

    def layout(self):
        vs_layout(self)

    def requirements(self):
        self.requires("fmt/10.2.0@")

    def generate(self):
        tc = MSBuildToolchain(self)
        tc.generate()

    def build(self):
        msbuild = MSBuild(self)
        msbuild.build("pkg.sln")

    def package(self):
        copy(self, "*.h", os.path.join(self.source_folder, "include"),
             dst=os.path.join(self.package_folder, "include"))
        copy(self, "*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"),
             keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["pkg"]
  1. Run the conan install command using this profile (any profile should be able to repro the error but use this example).
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=static
compiler.runtime_type=Debug
compiler.version=193
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_DISABLE_STRICT_MODE=1
[conf]
tools.microsoft.msbuild:verbosity=Normal

Logs

From the install command

Conan 1 is on a deprecation path, please consider migrating to Conan 2
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=static
compiler.runtime_type=Debug
compiler.version=193
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_DISABLE_STRICT_MODE=1
[conf]
tools.microsoft.msbuild:verbosity=Normal

conanfile.py (pkg/1.0): Installing package
Requirements
    fmt/10.2.0 from 'inseinc' - Cache
Packages
    fmt/10.2.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache

Installing (downloading, building) binaries...
fmt/10.2.0: Already installed!
conanfile.py (pkg/1.0): WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.py (pkg/1.0): Generator 'MSBuildToolchain' calling 'generate()'
conanfile.py (pkg/1.0): MSBuildToolchain created conantoolchain_debug_x64.props
conanfile.py (pkg/1.0): MSBuildToolchain writing conantoolchain.props
conanfile.py (pkg/1.0): Generator txt created conanbuildinfo.txt
conanfile.py (pkg/1.0): Generator 'PremakeDeps' calling 'generate()'
conanfile.py (pkg/1.0): ERROR: Traceback (most recent call last):
  File "conans\client\generators\__init__.py", line 179, in write_generators
  File "conan\tools\premake\premakedeps.py", line 45, in generate
  File "conan\tools\premake\premakedeps.py", line 80, in content
  File "conan\tools\premake\premakedeps.py", line 52, in _get_cpp_info
  File "conans\model\new_build_info.py", line 106, in __getattr__
AttributeError: '_NewComponent' object has no attribute 'copy'

ERROR: Error in generator 'PremakeDeps': '_NewComponent' object has no attribute 'copy'
@KingKiller100
Copy link
Author

I can provide more information such as conf files and such if needed

@valgur
Copy link
Contributor

valgur commented Jan 3, 2024

Here's an answer from the last time it was asked: #14482 (comment)

I don't think there have been any improvements to the PremakeDeps generator since that time.

@KingKiller100
Copy link
Author

Thank you @valgur for informing me. From that comment, I understand that the team aren't looking to support that generator at this time. As a workaround, I decided to make my own set of custom generators that allow me to use premake5 within the conan system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants