I use -j
flag to speed up ndk compile time like this:
defaultConfig {
...
externalNativeBuild {
ndkBuild {
arguments "-j8"
}
}
}
Building works fine, but clean produces this error:
rm: fts_read: No such file or directory
This is documented in Google's ndk-build docs, and the reason for this is parallel execution (-j
flag) on Mac, so I need to either remove this flag or change it to -j1
for clean task. How can I do this?
This is how I did it:
def getProcessesCountArg() {
def procCount = Runtime.runtime.availableProcessors()
Gradle gradle = getGradle()
def isClean = gradle.getStartParameter().getTaskNames().find { it ==~ /.*clean.*/ }
if (isClean) {
procCount = 1
}
return "-j" + procCount
}
Wish there was a better way.