I’m new to Gradle, but successfully used it in no time for Java/Groovy projects.
Now, I’m trying to write a Gradle native build script for a multiplatform C/C++ project which has common sources, and specific ones for each “platform”. I couldn’t find in the documentation how to configure this situation.
Is there a way to specify sources conditionally (for example, using something like toolChain in VisualCpp) or by other means?
If not, I guess I can use different components for each “platform”. In this scenario, is there a way to share sources between components?
Thanks in advance. I would appreciate any thoughts/directions on this.
Then for each platform I add a source set. But the global exclude seems to prevent the specific sources from being included. Is there a way to avoid this? Or can I somehow define each different source set a with a different name?
You need to create new source sets for the OS-specific sets of sources. cpp is the source set that’s provided by the cpp plugin by default. You can create new ones like:
// in a binaries block
if (targetPlatform.operatingSystem.windows) {
sources {
mySourceSet(CppSourceSet) {
// configure it
}
}
}
RIght now you’re configuring cpp to exclude and include the platform specific sources.
That’s it! I was missing the source {}. Thank you very much for your time.
I know it made a silly mistake and I missed it in the DSL documentation, but maybe IMHO the error message could be more informative. Is there a way I can “report” it?
There’s a lot of active development in that area (the error message from the latest nightly is very different, still not very useful), but I’ll let the guys know.
@erdi this is probably the sort of thing that’ll happen frequently.