Functions
generic Namespace Reference

Functions

def _options (opt, name)
 
def _configure (ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True)
 

Detailed Description

This is NOT a waf tool but generic functions to be called from a waf
tool, in particular by wcb.py.

There's probably a wafier way to do this.

The interpretation of options are very specific so don't change them
unless you really know all the use cases.  The rules are:

If package is optional:

- omitting all --with-NAME* options will omit use the package

- explicitly using --with-NAME=false (or "no" or "off") will omit
  use of the package.

If package is mandatory:

- omitting all --with-NAME* options will use pkg-config to find
  the package.

- explicitly using --with-NAME=false (or "no" or "off") will
  assert.

In either case:

- explicitly using --with-NAME=true (or "yes" or "on") will use
  pkg-config to find the package.

- using --with-NAME* with a path will attempt to locate the
  package without using pkg-config

Note, actually, pgk-config fails often to do its job.  Best to always
use explicit --with-NAME=[<bool>|<dir>].

Function Documentation

def generic._configure (   ctx,
  name,
  incs = (),
  libs = (),
  bins = (),
  pcname = None,
  mandatory = True 
)
private

Definition at line 50 of file generic.py.

50 def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True):
51  lower = name.lower()
52  UPPER = name.upper()
53  if pcname is None:
54  pcname = lower
55 
56  instdir = getattr(ctx.options, 'with_'+lower, None)
57  incdir = getattr(ctx.options, 'with_%s_include'%lower, None)
58  libdir = getattr(ctx.options, 'with_%s_lib'%lower, None)
59  bindir = getattr(ctx.options, 'with_%s_bin'%lower, None)
60  #print ("CONFIGURE", name, inst,inc,lib, mandatory)
61 
62  if mandatory:
63  if instdir:
64  assert (instdir.lower() not in ['no','off','false'])
65  else: # optional
66  if not any([instdir, incdir, libdir]):
67  print ("skipping non mandatory %s, use --with-%s=[yes|<dir>] to force" % (name, lower))
68  return
69  if instdir and instdir.lower() in ['no','off','false']:
70  return
71 
72  # rely on package config
73  if not any([instdir,incdir,libdir,bindir]) or (instdir and instdir.lower() in ['yes','on','true']):
74  ctx.start_msg('Checking for %s in PKG_CONFIG_PATH' % name)
75  args = "--cflags"
76  if libs: # things like eigen may not have libs
77  args += " --libs"
78  ctx.check_cfg(package=pcname, uselib_store=UPPER,
79  args=args, mandatory=mandatory)
80  if 'HAVE_'+UPPER in ctx.env:
81  ctx.end_msg("found")
82  else:
83  ctx.end_msg("failed")
84  return
85  else: # do manual setting
86 
87  if incs:
88  if not incdir and instdir:
89  incdir = osp.join(instdir, 'include')
90  if incdir:
91  setattr(ctx.env, 'INCLUDES_'+UPPER, [incdir])
92 
93  if libs:
94  if not libdir and instdir:
95  libdir = osp.join(instdir, 'lib')
96  if libdir:
97  setattr(ctx.env, 'LIBPATH_'+UPPER, [libdir])
98 
99  if bins:
100  if not bindir and instdir:
101  bindir = osp.join(instdir, 'bin')
102  if libdir:
103  setattr(ctx.env, 'PATH_'+UPPER, [bindir])
104 
105 
106  # now check, this does some extra work in the caseof pkg-config
107 
108  if incs:
109  ctx.start_msg("Location for %s headers" % name)
110  for tryh in incs:
111  ctx.check_cxx(header_name=tryh,
112  use=UPPER, uselib_store=UPPER, mandatory=mandatory)
113  ctx.end_msg(str(getattr(ctx.env, 'INCLUDES_' + UPPER, None)))
114 
115  if libs:
116  ctx.start_msg("Location for %s libs" % name)
117  for tryl in libs:
118  ctx.check_cxx(lib=tryl,
119  use=UPPER, uselib_store=UPPER, mandatory=mandatory)
120  ctx.end_msg(str(getattr(ctx.env, 'LIBPATH_' + UPPER, None)))
121 
122  ctx.start_msg("Libs for %s" % name)
123  ctx.end_msg(str(getattr(ctx.env, 'LIB_' + UPPER)))
124 
125  if bins:
126  ctx.start_msg("Bins for %s" % name)
127  found_bins = list()
128  for tryb in bins:
129  ctx.find_program(tryb, var=tryb.upper(), mandatory=mandatory)
130  found_bins += ctx.env[tryb.upper()]
131  ctx.end_msg(str(found_bins))
132 
133 
def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True)
Definition: generic.py:50
std::string str(const std::pair< Type, Type > &tt)
Definition: test_pimpos.cxx:12
def generic._options (   opt,
  name 
)
private

Definition at line 39 of file generic.py.

39 def _options(opt, name):
40  lower = name.lower()
41  opt = opt.add_option_group('%s Options' % name)
42  opt.add_option('--with-%s'%lower, type='string', default=None,
43  help="give %s installation location" % name)
44  opt.add_option('--with-%s-include'%lower, type='string',
45  help="give %s include installation location"%name)
46  opt.add_option('--with-%s-lib'%lower, type='string',
47  help="give %s lib installation location"%name)
48  return
49 
def _options(opt, name)
Definition: generic.py:39