How to link compiled objects from two `sub-projects` in a Native Gradle build system?


(Ganesh) #1

I am Gradle newbie trying to figure out how to build my C project. I use Gradle version 3.0.

I have a project layout as shown in the figure:


build.gradle files within sub-sub-projectA.1 and sub-sub-projectA.2 contain C source files which will be compiled and partially linked to generate executables. I would like to then further partially link these two executables and generate an object file and this I want it generated on the sub-projectA level.

How do I convey this information to Gradle? What information should I put in the build.gradle file under sub-projectA to get this done?

On a higher perspective, is there already a mechanism in Gradle which handles requirements of these sorts by default? To be specific, is there a possibility to call build from a top level directory (there are subprojects present), which will iterate through all the build.gradle files of the subprojects, compile and partially link these objects, finally do another linking of all the generated partially linked objects of the different subprojects?