5.2. Python syntax

Because SCons configuration files are Python scripts, normal Python syntax can be used to generate or manipulate lists of targets or dependencies:

	sources = ['aaa.c', 'bbb.c', 'ccc.c']
	env.Make('bar', sources)
	

Python flow-control can be used to iterate through invocations of build rules:

	objects = ['aaa.o', 'bbb.o', 'ccc.o']
	for obj in objects:
	        src = replace(obj, '.o', '.c')
	        env.Make(obj, src)
	

or to handle more complicated conditional invocations:

	# only build 'foo' on Linux systems
	if sys.platform == 'linux1':
	        env.Make('foo', 'foo.c')
	

Because SCons configuration files are Python scripts, syntax errors will be caught by the Python parser. Target-building does not begin until after all configuration files are read, so a syntax error will not cause a build to fail half-way.