SCons
SCons is an Open Source, next-generation software construction tool written in Python, similar to GNU Make but using Python scripts for configuration. It provides automatic dependency analysis, support for parallel builds, and is designed for cross-platform software development. It is actively maintained with frequent releases, currently at version 4.10.1, offering new functionality, enhancements, and bug fixes.
Warnings
- breaking SCons 4.9.0 dropped support for Python 3.6. Python 3.7 or higher is now required.
- breaking The `env.Dump()` method's API changed in SCons 4.8.1. It now accepts multiple optional 'key' arguments instead of a single one. Scripts relying on the old single-key behavior may need adjustment.
- gotcha SCons construction environments (created with `Environment()`) do not automatically inherit the full external `PATH` or other environment variables from the shell that invoked `scons`. This can lead to issues where compilers or tools are not found.
- gotcha SCons typically expects an `SConstruct` file in the current working directory. If not found, it will report 'No SConstruct file found'.
- gotcha SCons 4.10.1 switched its internal test framework from `profile` to `cProfile` to avoid deprecation warnings introduced in Python 3.15. Older SCons versions might emit warnings if used with Python 3.15+.
- gotcha As of SCons 4.10.0, Nodes are treated as `PathLike` objects. This change may affect scripts that explicitly expected string paths when interacting with SCons Nodes.
Install
-
pip install scons
Imports
- Environment
env = Environment()
Quickstart
# SConstruct file
env = Environment()
env.Program('hello.c')
# hello.c file
#include <stdio.h>
int main() {
printf("Hello, SCons!\n");
return 0;
}
# To build, run in terminal:
# scons
# To clean, run in terminal:
# scons -c