Difference between revisions of "SCons"

From Madagascar
Jump to navigation Jump to search
Line 45: Line 45:
 
</python>
 
</python>
 
Note that <tt>SConstruct</tt> by itself does not do any job other than setting rules for building different targets. The targets get built when one executes <tt>scons</tt> on the command line. Running <tt>scons</tt> produces
 
Note that <tt>SConstruct</tt> by itself does not do any job other than setting rules for building different targets. The targets get built when one executes <tt>scons</tt> on the command line. Running <tt>scons</tt> produces
<bash>
+
<pre>
 +
bash$ scons
 
scons: Reading SConscript files ...
 
scons: Reading SConscript files ...
 
scons: done reading SConscript files.
 
scons: done reading SConscript files.
 
scons: Building targets ...
 
scons: Building targets ...
 
retrieve(["wz.35.H"], [])
 
retrieve(["wz.35.H"], [])
< wz.35.H /home/fomels/RSFROOT/bin/sfdd form=native | /home/fomels/RSFROOT/bin/sfwindow n1=400 j1=2 | /home/fomels/RSFROOT/bin/sfsmooth rect1=3 > wind.rsf
+
< wz.35.H /RSF/bin/sfdd form=native | /RSF/bin/sfwindow n1=400 j1=2 | /RSF/bin/sfsmooth rect1=3 > wind.rsf
< wind.rsf /home/fomels/RSFROOT/bin/sfpow pow1=2 | /home/fomels/RSFROOT/bin/sfgrey > wind.vpl
+
< wind.rsf /RSF/bin/sfpow pow1=2 | /RSF/bin/sfgrey > wind.vpl
< wind.rsf /home/fomels/RSFROOT/bin/sfmutter v0=0.31 half=n > mute.rsf
+
< wind.rsf /RSF/bin/sfmutter v0=0.31 half=n > mute.rsf
< mute.rsf /home/fomels/RSFROOT/bin/sfpow pow1=2 | /home/fomels/RSFROOT/bin/sfgrey > mute.vpl
+
< mute.rsf /RSF/bin/sfpow pow1=2 | /RSF/bin/sfgrey > mute.vpl
/home/fomels/RSFROOT/bin/vppen yscale=2 vpstyle=n gridnum=2,1 wind.vpl mute.vpl > Fig/denmark.vpl
+
/RSF/bin/vppen yscale=2 vpstyle=n gridnum=2,1 wind.vpl mute.vpl > Fig/denmark.vpl
 
scons: done building targets.
 
scons: done building targets.
</bash>
+
</pre>
  
 
Changing parameters...
 
Changing parameters...

Revision as of 15:46, 11 August 2010

Scons-logo-transparent.png

SCons (from Software Construction) is a superior alternative to the classic make utility.

SCons is implemented as a Python script, its "configuration files" (SConstruct files) are also Python scripts. Madagascar uses SCons to compile software, to manage data processing flowing, and to assemble reproducible documents.

Useful SCons options

scons -h (help) displays a help message.

scons -Q (quiet) suppresses progress messages.

scons -n (no exec) outputs the commands required for building the specified target (or the default targets if no target is specified) without actually executing them. It can be used to generate a shell script out of SConstruct script, as follows: <bash> scons -nQ [target] > script.sh </bash>

Compilation

SCons was designed primarily for compiling software code. An SConstruct file for compilation may look like <python> env = Environment() env.Append(CPPFLAGS=['-Wall','-g']) env.Program('hello',['hello.c', 'main.c']) </python>

Data processing flows with rsf.proj

The rsf.proj module provides SCons rules for Madagascar data processing workflows. An example SConstruct file is shown below and can be found in bei/sg/denmark <python> from rsf.proj import *

Fetch('wz.35.H','wz')

Flow('wind','wz.35.H','dd form=native | window n1=400 j1=2 | smooth rect1=3') Plot('wind','pow pow1=2 | grey')

Flow('mute','wind','mutter v0=0.31 half=n') Plot('mute','pow pow1=2 | grey')

Result('denmark','wind mute','SideBySideAniso')

End() </python> Note that SConstruct by itself does not do any job other than setting rules for building different targets. The targets get built when one executes scons on the command line. Running scons produces

bash$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
retrieve(["wz.35.H"], [])
< wz.35.H /RSF/bin/sfdd form=native | /RSF/bin/sfwindow n1=400 j1=2 | /RSF/bin/sfsmooth rect1=3 > wind.rsf
< wind.rsf /RSF/bin/sfpow pow1=2 | /RSF/bin/sfgrey > wind.vpl
< wind.rsf /RSF/bin/sfmutter v0=0.31 half=n > mute.rsf
< mute.rsf /RSF/bin/sfpow pow1=2 | /RSF/bin/sfgrey > mute.vpl
/RSF/bin/vppen yscale=2 vpstyle=n gridnum=2,1 wind.vpl mute.vpl > Fig/denmark.vpl
scons: done building targets.

Changing parameters...

SCons commands

Fetch
Flow
Plot
Result
End

Default targets

Command-line options

Command-line options
Name Meaning
TIMER Whether to time execution
CHECKPAR Whether to check parameters
ENVIRON Additional environment settings
CLUSTER Nodes available on a cluster
MPIRUN mpirun command

Seismic Unix data processing flows with rsf.suproj

Document creation with rsf.tex

Default targets

Book and report creation with rsf.book