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

[feature] get_executable(...) helper function #17602

Open
1 task done
valgur opened this issue Jan 21, 2025 · 2 comments
Open
1 task done

[feature] get_executable(...) helper function #17602

valgur opened this issue Jan 21, 2025 · 2 comments

Comments

@valgur
Copy link
Contributor

valgur commented Jan 21, 2025

What is your suggestion?

Quite a few recipes on CCI need to find either CC, CXX, CC_FOR_BUILD, or one of the binutils utilities like strip to support legacy build systems:
https://github.com/search?q=repo%3Avalgur%2Fconan-center-index+%28%2F%28%3F-i%29%5C%5B%22CC%5B%22_%5D%2F+OR+%2F%28%3F-i%29get%5C%28%22CC%2F+OR+compiler_executables%29+language%3APython&type=code

To do this correctly and reliably, the recipes will have to consider:

  1. tools.build:compiler_executables
  2. VirtualBuildEnv(self).vars().get(...)
  3. either guess or search for a corresponding executable based on the profile, e.g. compiler=gcc compiler.version=13 -> g++-13

See the Boost recipe for an existing example of this: https://github.com/conan-io/conan-center-index/blob/adc93693dcf0e6c66a3d0ebf5a76503f2670ba16/recipes/boost/all/conanfile.py#L1501-L1515

While GnuToolchain has encapsulated some of this complexity (a bit better than AutotoolsToolchain), it is still in incubation and not as flexible as it could be. It would be great if it could handle less common compiler_executables and environment variable pairs, e.g. ranlib, nm, etc. A consistent API for host/build/target context would also be very useful for cross-compilation (target-context compiler info would be useful for recipes like rust without resorting to workarounds).

Perhaps a helper function along the lines of this could be added?

conan.tools.build.get_executable(name, default=None, scope="build"/"run"/"target", env=None)

where compiler_executables is queried first, followed by VirtualBuildEnv env vars for env or name.upper() and finally cc/cxx would resort to fallback logic to search the correct paths for the expected compiler executable.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@valgur
Copy link
Contributor Author

valgur commented Jan 21, 2025

cc @franramirez688 since somewhat related to your recent work on GnuToolchain

@valgur
Copy link
Contributor Author

valgur commented Jan 24, 2025

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

1 participant