[Scons-users] Question about scons
Guillaume Anciaux
guillaume.anciaux at epfl.ch
Thu Feb 11 06:15:40 EST 2016
Dear all,
This is a follow-up on my progression.
Before even working on the repo to place the tools (and other stuff) I
needed to do a few tests for my knowledge and be sure I go in the right
direction.
What I did is I made a tool in a site_scons/site_init.py as a start.
It aims at 'detecting' FFTW with a few options like the required version
for instance. This is what I wrote:
*******************************************************
def fftw(env):
"""A Tool to search for fftw headers and libraries"""
if env.GetOption('clean'): return
if 'FFTW_VERSION' not in env: env['FFTW_VERSION'] = "3"
env['FFTW_VERSION'] = str(env['FFTW_VERSION'])
if 'FFTW_INCLUDE_DIR' in env:
env['CXXFLAGS'].append('-I{0}'.format(env['FFTW_INCLUDE_DIR']))
env['CFLAGS'].append('-I{0}'.format(env['FFTW_INCLUDE_DIR']))
if 'FFTW_LIBRARY_WISH' not in env:
env['FFTW_LIBRARY_WISH'] = ['main']
if 'FFTW_LIBRARY_DIR' in env:
if 'LIBPATH' not in env: env['LIBPATH'] = []
env['LIBPATH'] += [env['FFTW_LIBRARY_DIR']]
version = env['FFTW_VERSION']
if version == "2":
lib_names = {'main':'fftw'}
inc_names = ['fftw.h']
else:
lib_names =
{'main':'fftw3','thread':'fftw3_threads','omp':'fftw3_omp'}
inc_names = ['fftw3.h']
conf = Configure(env)
try:
lib_names = [lib_names[i] for i in env['FFTW_LIBRARY_WISH']+['main']]
except:
print 'Incompatible wishlist {0} from version
{1}'.format(env['FFTW_WISH_LIST'],
env['FFTW_VERSION'])
Exit(1)
for l in lib_names:
if not conf.CheckLibWithHeader(l, inc_names, 'c'):
print 'Did not find FFTW, exiting!'
Exit(1)
print env['LIBS']
env['FFTW_LIBRARIES'] = lib_names
env = conf.Finish()
*******************************************************
Thus I have some questions:
- What I wrote also has a configure sequence. But I think this is not
what a tool should do. Correct ?
From what I read you can also make your own configure checks.
- I think the environment extension, which defines a few variables based
on some others, and the 'configure' stage which actually verify that
everything can be accessed are close related pieces of code: can we make
a tool that registers specific configure checks ?
- The configure stage is adding directly what he found to the $LIBS
option. However if I just want to know that everything is here and
manually add to LIBS: can I do that ?
I guess that in the end I would like to be able to write a sequence of
code like:
*********************************
env = Environment(
tools=['defatult','fftw'],
FFTW_LIBRARY_WISH = ['thread','omp']
FFTW_VERSION = ['thread','omp']
)
conf = Configure(env)
conf.CheckFFTW()
conf.Finish()
**********************************
- how to make it explicit that the FFTW tool depends on the 'default'
(since it needs a C/C++ compiler to be used) ?
Thanks for your help.
Best
Guillaume
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1513 bytes
Desc: OpenPGP digital signature
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160211/4aa33e4b/attachment.pgp>
More information about the Scons-users
mailing list