I’m using Gradle 2.4 and I’m trying to compile a native C++ application for two different platforms (desktop and embedded) using two different GCC toolchains; one toolchain for one platform and another toolchain for the other platform. However, Gradle seems to be using the one GCC toolchain for both platforms. Here’s an example:
When I run the example above, the desktop_gcc compiles both platforms. If I remove desktop_gcc, then embedded_gcc compiles both platforms.
Is this the expected behavior? I assumed that the desktop_gcc would be used to compile the desktop platform, and the embedded_gcc would be used to compile the embedded platform.
We are simply picking the first compatible toolchain we can find. We consider both equally capable of building your binary since they are both targeting the same OS and architecture. In the future we may decide to add more dimensions of compatibility. In the meantime you should be able to assign the appropriate toolchain to your binary by keying off of targetPlatform.
My only other suggestion is if the GCC executables are distinguished by different names (e.g., embedded-gcc vs desktop-gcc), you can do everything as a single tool chain:
I am trying to do something similar, albeit a little different: I need to use standard gcc and Emscripten toolchain to build C++ library to two versions of the library:
regular .dll shared library
and .js module after transpiling C++ code to JavaScript
After jumping through a few hoops and implementing a custom toolchain, I was able to build *.js library, but every time I try to register both toolchains and two target machines (one Windows:x86 and another Windows:Node_12), Gradle ends up building only the Windows:x86 version.
Is this intended behavior that Gradle picks first target machine compatible with current build machine OS? Or could I still be missing something?
P.S.: after Going through Gradle code, I see that Gradle only builds for machines that use the OS as the build host. So my custom toolchain is targeted to ‘host:Node_12’.