[Scons-users] Add `--parallel` option to automatically use all CPU threads

Hugo Locurcio hugo.locurcio at hugo.pro
Wed Apr 6 18:29:30 EDT 2022


Hello,

This is a feature request for SCons to add a `--parallel` option, which 
would be equivalent to `-j` with the number of logical CPU cores present 
on the system. CMake provides a similar option, which is convenient to 
avoid juggling with non-portable lines that rely on shell extensions 
(and therefore don't always play well with IDE configuration).

We recently encountered this issue while adding a CLion + SCons guide to 
the Godot documentation: https://github.com/godotengine/godot-docs/pull/5743
Since CLion doesn't seem to expand command executions in its command 
lines, the current build commands given in the various Compiling pages 
don't work when used under CLion.

Instead of using:

     scons -j$(nproc)        # Linux

     scons -j%NUMBER_OF_PROCESSORS%        # Windows (cmd)

     scons -j$env:NUMBER_OF_PROCESSORS        # Windows (PowerShell)

     scons -j$(sysctl -n hw.logicalcpu)        # macOS


You could just use:

     scons --parallel        # All platforms :)


This new option would cover the 90% use case (that is, using all CPU 
threads to build a program) with an easy-to-remember command. This also 
happens to be the same switch as used by CMake.



More information about the Scons-users mailing list