Is there any way to insert a srcDir in a cpp sourceSet that includes the target platform name?
What I’m trying to do is something like the following:
sources {
cpp {
source {
srcDirs ["src/main/common", "src/main/${targetPlatform.name}"]
include "**/*.cpp"
}
exportedHeaders {
srcDirs ["src/main/include", "src/main/${targetPlatform.name}/include"]
include "**/*.hpp"
}
}
}
The above is obvously not correct, since I get an error trying to run it. Would it be possible to add it in the binaries.all section?
sterling
(Sterling Greene)
November 14, 2015, 3:39am
2
I would try to do something like this:
The ‘cpp’ sourceset is shared with all binaries, so if you could add the source directory with the platform name, you’d add it to all binaries.
1 Like
Thanks!
Since I have a bunch of custom defined target platforms (the name of each one being a custom board, by the way, and no OS is used since it’s on bare metal), I think I got away with doing the following:
componentName(NativeLibrarySpec) {
targetPlatform "board1"
targetPlatform "mingw32"
binaries.all {
sources {
platformCpp(CppSourceSet) {
source {
srcDir "src/main/common"
srcDir "src/main/${targetPlatform.name}"
include "**/*.cpp"
}
exportedHeaders {
srcDir "src/main/include"
srcDir "src/main/${targetPlatform.name}/include"
include "**/*.hpp"
}
}
}
}
sterling
(Sterling Greene)
November 16, 2015, 4:30pm
4
Yep, I think that would work too. Each platformCpp
is unique to the binary.
1 Like