\section senfutil_overview Building Projects using SENF
When building projects using senf, SENFSCons has a very simple helper module \ref senfutil to
- make the building of libraries utilizing senf simpler:
- \code
- import sys
- sys.path.extend(('senf/site_scons','/usr/lib/senf/site_scons'))
- import glob, senfutil
-
- env = Environment()
- senfutil.SetupForSENF(env)
- senfutil.DefaultOptions(env)
-
- env.Append( LOGLEVELS_debug = [ 'senf::log::Debug||VERBOSE' ] )
-
- env.Default(
- env.Program( target = 'udpforward', source = glob.glob('*.cc') )
- )
- \endcode
-
- This example builds a simple binary from a number of source files (all '.cc' files). It links
- against the SENF library and automatically sets all the correct compiler options using
- <tt>senfutil.SetupForSENF( env )</tt>.
-
- This script automatically uses a SENF installation either symlinked or imported into the current
- project in directory 'senf' or, if this directory does not exist, a globally installed SENF.
+ make the building of libraries utilizing senf simpler.
\see \ref senf_senfutil
*/
-/** \page senf_senfutil SENF SCons build utility
+/** \page senf_senfutil SENF SCons build utility (senfutil.py)
+
+ \autotoc
The \c senfutil utility for SCons helps setting up a project to compile against SENF:
)
\endcode
+ This example builds a simple binary from a number of source files (all '.cc' files). It links
+ against the SENF library and automatically sets all the correct compiler options using
+ <tt>senfutil.SetupForSENF( env )</tt>.
+
+ This script automatically uses a SENF installation either symlinked or imported into the current
+ project in directory 'senf' or, if this directory does not exist, a globally installed SENF.
+
\section senf_senfutil_options Build options
\c senfutil supports the <tt>debug=1</tt> or <tt>final=1</tt> build options. These parameters
LINKFLAGS_normal = [ '-Wl,-S' ],
)
\endcode
+
+ Thus above example can be simplified to
+ \code
+ import sys
+ sys.path.extend(('senf/site_scons','/usr/lib/senf/site_scons'))
+ import glob, senfutil
+
+ env = Environment()
+ senfutil.SetupForSENF(env)
+ senfutil.DefaultOptions(env)
+
+ env.Append( LOGLEVELS_debug = [ 'senf::log::Debug||VERBOSE' ] )
+
+ env.Default(
+ env.Program( target = 'udpforward', source = glob.glob('*.cc') )
+ )
+ \endcode
+
+ \section senf_senfutil_arguments 'scons' Command line arguments
+
+ \c senfutil automatically parses SCons command line arguments into the SCons build
+ environment. This allows specifying any parameter on the command line:
+ <pre>
+ $ scons CXXCOM=mygcc CXXFLAGS+=-mtune=geode
+ </pre>
+ You may either set variables unconditionally using '=' or append values to the end of a list
+ using '+='.
*/
/** \page senf_usage Using the SENF framework
linklint Check links of doxygen documentation with 'linklint'
fixlinks Fix broken links in doxygen documentation
valgrind Run all tests under valgrind/memcheck
-
-Build parameters:
-
-final=1 Build optimized library without debug symbols
-debug=1 Link all binaries with debug symbols (slow!)
-syslayout=1 Install into system layout directories ($$PREFIX/lib, $$PREFIX/include etc)
-
-additionally, any construction environment variable may be set from the scons
-command line (see SConstruct file and SCons documentation for a list of variables).
""")
env.Replace(
LINKFLAGS_ = senfutil.BuildTypeOptions('LINKFLAGS'),
LINKFLAGS_final = [ ],
LINKFLAGS_normal = [ '-Wl,-S' ],
- LINKFLAGS_debug = [ ],
+ LINKFLAGS_debug = [ '-g' ],
)
env.SetDefault(
LIBSENF = "senf",
- final = 0,
- debug = 0,
- syslayout = 0
+ final = False,
+ debug = False,
+ syslayout = False
)
# Set variables from command line
-env.Replace(**ARGUMENTS)
+senfutil.parseArguments(
+ env,
+ BoolVariable('final', 'Build final (optimized) build', False),
+ BoolVariable('debug', 'Link in debug symbols', False),
+ BoolVariable('syslayout', 'Install in to system layout directories (lib/, include/ etc)', False),
+)
Export('env')
type = env['final'] and "final" or env['debug'] and "debug" or "normal"
return env[self._var + "_" + type]
+def parseArguments(env, *defs):
+ vars = Variables(args=ARGUMENTS)
+ vars.AddVariables(*defs)
+ vars.Update(env)
+ env.Help("""
+Any construction environment variable may be set from the scons
+command line (see SConstruct file and SCons documentation for a list
+of variables) using
+
+ VARNAME=value Assign new value
+ VARNAME+=value Append value at end
+
+Special command line parameters:
+""")
+ env.Help(vars.GenerateHelpText(env))
+ for k,v in vars.UnknownVariables().iteritems():
+ if k.endswith('+'):
+ env.Append(**{k[:-1]: v})
+ else:
+ env.Replace(**{k: v})
+
+
###########################################################################
# This looks much more complicated than it is: We do three things here:
# a) switch between final or debug options
)
# Interpret command line options
- opts = Variables(args=ARGUMENTS)
- opts.Add( 'LOGLEVELS', 'Special log levels. Syntax: <stream>|[<area>]|<level> ...',
- '${"$LOGLEVELS_"+(final and "final" or "debug")}' )
- opts.Add( BoolVariable('final', 'Build final (optimized) build', False) )
- opts.Add( BoolVariable('debug', 'Link in debug symbols', False) )
- opts.Update(env)
- env.Replace(**dict(opts.UnknownVariables()))
- env.Help(opts.GenerateHelpText(env))
+ parseArguments(
+ env,
+ BoolVariable('final', 'Build final (optimized) build', False),
+ BoolVariable('debug', 'Link in debug symbols', False),
+ )
# If we have a symbolic link (or directory) 'senf', we use it as our
# senf repository
CXXFLAGS_debug = [ '$CXXFLAGS_normal' ],
LINKFLAGS_normal = [ '-Wl,-S' ],
+ LINKFLAGS_debug = [ '-g' ],
)