I need to pass -j
argument to ninja while building Android app with gradle.
(on Windows)
Why do I need this? - We have huge unified c++ files that require lots of memory to compile. Currently I have no enough memory (~10GB free) to compile them in parallel on 8 cores. Thus clang fails when memory runs out.
I see that gradle runs cmake
with --build
key so I've tried to add my -j1
arg there. But seems arguments
field is used only for cmake generation, because it doesn't affect command line passed to cmake in build stage.
externalNativeBuild {
cmake {
cFlags "..."
cppFlags "..."
arguments "... -- -j1"
}
}
The only way I see now it to replace ninja
with some wrapper to pass -j
from there. But this is the last options I would like to use.
Appreciate any ideas about how to achieve this valid way.
If the task you want to pass parameters to is of type JavaExec and you are using Gradle 5, for example the application plugin's run task, then you can pass your parameters through the --args=... command line option. For example gradle run --args="foo --bar=true" .
Differences between Make and Ninja For incremental builds, Make is significantly slow. Ninja is faster and helps developers spend less time on building software. This becomes a driving force for large projects such as Google Chrome. In general, performance of Ninja is much better than Make.
ninja in the current directory and builds all out-of-date targets. You can specify which targets (files) to build as command line arguments. There is also a special syntax target^ for specifying a target as the first output of some rule containing the source you put in the command line, if one exists.
cmake is a build system; you define how your project should be put together. It can create ninja. build files for you. Ninja will do the building. cmake --build just calls the builder for you.
You should set CMAKE_BUILD_PARALLEL_LEVEL
environment variable to number of concurrent processes you want to use for the build.
It's available since cmake 3.12.4.
https://cmake.org/cmake/help/v3.12/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With