conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.25k stars 980 forks source link

[bug] Autotools.install documentation does not match its behavior #13691

Open ltjax opened 1 year ago

ltjax commented 1 year ago

Environment details

Steps to reproduce

  1. Pass args=None
  2. Wonder why DESTDIR is still set by conan

The documentation for conan.tools.gnu.Autotools.install states: "By default an argument DESTDIR=unix_path(self.package_folder) is added to the call if the passed value is None." Yet DESTDIR is always added unless DESTDIR= appears in the joined args.

Logs

No response

memsharded commented 1 year ago

Thanks for your report @ltjax

The current implementation is relatively simple:

    def install(self, args=None, target="install"):
        args = args if args else []
        str_args = " ".join(args)
        if "DESTDIR=" not in str_args:
            args.insert(0, "DESTDIR={}".format(unix_path(self._conanfile, self._conanfile.package_folder)))
        self.make(target=target, args=args)

Would it be a documentation bug? or is there some gap in the behavior/code too?

ltjax commented 1 year ago

To be honest, this default really botched one of my conan 1 -> conan 2 ports, because the underlying project apparently didn't like DESTDIR be set (the final package folder was something like join(build_folder, package_folder)). It took me a long time to figure out that was the cause for the screwed-up package paths. First the documentation says it's just an "alias" of ``self.make(target="install") (It's not, it sets DESTDIR), then I read on and saw the comment on DESTDIR, where the it just doesn't do what it says. Ideally, the method would be renamed to install_with_default_destdir(), or something along those lines, making it really obvious what it does. Alternatively, I think the behavior in the docs is better, and it should just set DESTDIRwhen args is None. So: args = args if args is not None else ["DESTDIR={}".format(unix_path(self._conanfile, self._conanfile.package_folder))]

Right now, I have to pass args=["DESTDIR="] to work around this.