Trouble with Defining Custom Platform and TargetMachines for C/C++ Applications


I’m having an issue with using the Native Build infrastructure (as provided by the ‘cpp-application’ and ‘cpp-library’) to cross compile to non-standard HW targets. So for example I am looking to build images for the xtensa-lx6 architecture (aka ESP32), and ARM Cortex architectures. In addition, I want to have working dependency resolution through Maven/Artifactory.

Before I go any further, I know that this Gradle infrastructure is still evolving and what I’m looking to do may not yet be possible. Which is fine. I just want to know for sure it’s not possible, so I can go do other things while I wait :slight_smile:

So what I have working (quite well) at this point in time is… basically everything. I can use the the custom toolchain to build both libraries and applications. I can publish artifacts to artifactory. And I can make use of the versioned artifacts across various projects.

Now what doesn’t work.

The issue I’m having is the .module metadata up in Maven is setting the “operating system” field to the build host OS (in this case “macos”). The result is that any build host not running OSX fails dependency resolution because Gradle is by default trying to use the build host OS.

Along with setting up the custom toolchain, I have setup some custom platforms (each with their own OS and Arch properties). Once this is done, I go ahead and set the “targetMachines” property in the application build.gradle.

And this is pretty much where everything kind of goes wrong.

I would expect (and this is a just a guess, but seems reasonable) that the custom platforms would be searched for an entry that has a matching OS+Arch set with the entry in the targetMachines list (I just have 1 entry atm, I really only care about the single HW ESP32 arch). And then the associated toolchain would be used. Instead I simple get a bunch of resolution errors because Gradle is still trying to use my host OS as the platform.

I’m not sure whats really going on at this point, but I figure its safe to say that either a) custom platform resolution is not working, or b) Im just doing something silly and wrong.

I also tried to get hacky and I set the lone target machines entry to OSX and just overwrote all the toolchain configurations with the custom toolchain config, hoping to trick the system. This actually looked like worked… until I found that all my assembleDebug and assembleRelease tasks were completely gone! Lol.

Anyway, if anyone can provide some pointers/guidance it would be appreciated. I can provide some more information upon request, but I figure a general problem description is best to start.