From 4626f25b5353c4c648e9403c6593feb2c9a2e347 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 17 May 2012 14:49:08 +0200 Subject: Add include/lib folders from the commandline By using opt.add_option(..., match=['Checking for library iconv'], dest='iconvdir'), all configuration tests displaying 'Checking for library iconv' will get $(iconvdir)/lib and $(iconvdir)/include --- buildtools/wafsamba/samba_conftests.py | 67 +++++++++++++++++++++++++++++++++- buildtools/wafsamba/wscript | 5 +++ 2 files changed, 71 insertions(+), 1 deletion(-) (limited to 'buildtools') diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py index 1838b57c96..3605e33f08 100644 --- a/buildtools/wafsamba/samba_conftests.py +++ b/buildtools/wafsamba/samba_conftests.py @@ -1,10 +1,75 @@ # a set of config tests that use the samba_autoconf functions # to test for commonly needed configuration options -import os, Build, shutil, Utils, re +import os, shutil, re +import Build, Configure, Utils from Configure import conf from samba_utils import * + +def add_option(self, *k, **kw): + '''syntax help: provide the "match" attribute to opt.add_option() so that folders can be added to specific config tests''' + match = kw.get('match', []) + if match: + del kw['match'] + opt = self.parser.add_option(*k, **kw) + opt.match = match + return opt +Options.Handler.add_option = add_option + +@conf +def check(self, *k, **kw): + '''Override the waf defaults to inject --with-directory options''' + + if not 'env' in kw: + kw['env'] = self.env.copy() + + # match the configuration test with speficic options, for example: + # --with-libiconv -> Options.options.iconv_open -> "Checking for library iconv" + additional_dirs = [] + if 'msg' in kw: + msg = kw['msg'] + for x in Options.Handler.parser.parser.option_list: + if getattr(x, 'match', None) and msg in x.match: + d = getattr(Options.options, x.dest, '') + if d: + additional_dirs.append(d) + + # we add the additional dirs twice: once for the test data, and again if the compilation test suceeds below + def add_options_dir(dirs, env): + for x in dirs: + if not x in env.CPPPATH: + env.CPPPATH = [os.path.join(x, 'include')] + env.CPPPATH + if not x in env.LIBPATH: + env.LIBPATH = [os.path.join(x, 'lib')] + env.LIBPATH + + add_options_dir(additional_dirs, kw['env']) + + self.validate_c(kw) + self.check_message_1(kw['msg']) + ret = None + try: + ret = self.run_c_code(*k, **kw) + except Configure.ConfigurationError, e: + self.check_message_2(kw['errmsg'], 'YELLOW') + if 'mandatory' in kw and kw['mandatory']: + if Logs.verbose > 1: + raise + else: + self.fatal('the configuration failed (see %r)' % self.log.name) + else: + kw['success'] = ret + self.check_message_2(self.ret_msg(kw['okmsg'], kw)) + + # success! keep the CPPPATH/LIBPATH + add_options_dir(additional_dirs, self.env) + + self.post_check(*k, **kw) + if not kw.get('execute', False): + return ret == 0 + return ret + + @conf def CHECK_ICONV(conf, define='HAVE_NATIVE_ICONV'): '''check if the iconv library is installed diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 4db341202e..7bbec946c5 100755 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -77,6 +77,11 @@ def set_options(opt): help=("private library directory [PREFIX/lib/%s]" % Utils.g_module.APPNAME), action="store", dest='PRIVATELIBDIR', default=None) + opt.add_option('--with-libiconv', + help='installation directory for libiconv', + action='store', dest='iconv_open', default=None, + match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h']) + gr = opt.option_group('developer options') gr.add_option('-C', -- cgit