Add support for limiting build resources
wmmc88 opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
When configuring and compiling in a single step(ie. mbed-tools compile), cmake gets invoked without a --parallel
option. This typically defaults to "maximum parallelism" in builds. I believe in Ninja that that means # of logical cores + 2. It would be great to have a way to change that value when using mbed-tools compile
.
Describe the solution you'd like
An argument for build parallelism for mbed-tools compile
or a way of passing arguments directly to the cmake call.
Describe alternatives you've considered
Could maybe also be pulled from an environment variable?
This can actually be done by setting the CMAKE_BUILD_PARALLEL_LEVEL
env variable before calling mbed-tools
, but i still think it'd benefit from being a command line option
This seems like an advanced use case. We'd like to keep our CMake wrapper tool to a minimum that allows folks to get up and running with Mbed quickly with a nice experience. I'll add how to do this with the Ninja build generator in our "Build with CMake" documentation.
Since mbed uses CMake now, the CMake way to specify build parallelism is by using --parallel [<jobs>], -j [<jobs>]
when calling cmake --build
or by setting the CMAKE_BUILD_PARALLEL_LEVEL
environment variable. Either of these ways are agnostic to whether cmake is using ninja or make or smth else under the hood.
The former isnt possible when you call mbed-tools compile
since theres no way to just forward flags to cmake. Personally I think that having a way to just fwd "extra arguments" to cmake doesnt impact the experience (and i could submit a pr to implement that).
I've confirmed that the latter (ie using the env variable), actually works when set before calling mbed-tools compile
, so if you're going to call out using Ninja's "-j X" in the docs, it might be better to just say to set CMAKE_BUILD_PARALLEL_LEVEL
before using mbed-tools
.