When using the CLI or Workbench to build projects, I noticed that there is no way to pass in a --jobs
argument to make. If I try, for example: make -s -f $PARTICLE_MAKEFILE clean-user compile-user flash-user -j 4
, it gives the warning:
make[1]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
I noticed that the CLI and Workbench tooling call the Makefile found at ~/.particle/toolchains/buildscripts/x.y.z/Makefile. For large application builds (such as the Edge Impulse C++ SDK that ships with their deployment), you have to re-build this library every time you compile, which can take 5-10 min. In lieu of caching the build objects, it would be incredibly helpful if you could pass in a jobs
argument to speed everything up.
My workaround for this right now is to open the Particle Makefile and manually change the following targets:
# Run Device OS makefile to make the user part
make-main:
@echo "hello"
cd "$(DEVICE_OS_PATH)/main" && make all -j 4
# Run Device OS makefile to make system and user parts
make-modules:
cd "$(DEVICE_OS_PATH)/modules" && make all -j 4
This significantly increases the build speed on multicore systems.
Additionally, I highly recommend using $(MAKE)
instead of make
inside your Makefiles. See this thread for more information: Makefile: why always use `$(MAKE)` instead of `make`? - Stack Overflow