gradle-native icon indicating copy to clipboard operation
gradle-native copied to clipboard

Add way to get toolChain path from the public toolchain API's

Open ThadHouse opened this issue 6 years ago • 4 comments

I'm working on some plugins, and one of the things that would really be helpful would be to have a way to get the toolChain path from having a Gcc, Clang or VisualCpp object. I noticed that there was a potential way to get them internally added in Gradle 4.7, but it would be really helpful to have a public function to get that. Would a PR to add that be considered?

ThadHouse avatar Apr 09 '18 03:04 ThadHouse

Actually, turns out the API I thought would give me the information in 4.7 doesn't. So I have resorted to reflection currently.

I can think of a few ways to get that information without reflection. The easiest way I can see is to add a getGccPlatformToolChain to GccCompatibleToolChain. GccPlatformToolChain has everything needed to get that information. And the classes that back GccCompatibleToolChain have access to a GccPlatformToolChain, so it would be a simple addition. @oehme if you think thats ok, I will start work on a PR to add that.

The other way is to make the eachPlatform callbacks runnable multiple times, but that seems more difficult.

ThadHouse avatar Apr 09 '18 18:04 ThadHouse

@ThadHouse could you describe what you're using the path for?

big-guy avatar Apr 09 '18 19:04 big-guy

I'm calling nm in order to get a list of symbols to check our jni generation. However, we use both the native compilers and cross compilers, and the cross compilers have a prefix, and might be an absolute path rather then a relative path the resolves in the system path. If I can get the gcc or clang executable name, I can figure out that prefix and path.

We also have some tasks that use objcopy too, so the prefix is used for that as well.

ThadHouse avatar Apr 09 '18 19:04 ThadHouse

I also need the visual studio path in order to find dumpbin, which is also held entirely in private variables as well. In addition, all of these private variables changed in 4.7, so even reflection doesn't work for MSVC unlike GCC and Clang

ThadHouse avatar Apr 09 '18 20:04 ThadHouse