Working with the SCons builder
SCons
is also a multiplatform build system written in Python, with its configuration files also written in the same language. It also includes support for Microsoft Visual Studio, among other features.
Getting ready
SCons parses SConstruct
files, and by default it does not propagate the environment into the build system. This is to avoid build issues caused by environment differences. This is a complication for Yocto, as it configures the environment with cross-compilation toolchain settings. SCons does not define a standard way to support cross-compilation, so every project will implement it differently. For a simple example as the helloworld
program, we can just initialize the CC, LINKFLAGS
and PATH
variables in our SConstruct
file from the external environment as follows:
import os env = Environment(CC = os.environ['CC'], LINKFLAGS = os.environ['LDFLAGS'], ENV = {'PATH': os.environ['PATH...