diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-02-23 11:53:59 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-06 20:26:35 +1000 |
commit | aa0476024c2bc3c2a8a1ab70bee515ded86c3e51 (patch) | |
tree | 15b1b6db5b1a1e1c481cfbbf42f6cc748abfb555 /lib | |
parent | ff9f972d5558052b0346672df182966e947a5169 (diff) | |
download | samba-aa0476024c2bc3c2a8a1ab70bee515ded86c3e51.tar.gz samba-aa0476024c2bc3c2a8a1ab70bee515ded86c3e51.tar.bz2 samba-aa0476024c2bc3c2a8a1ab70bee515ded86c3e51.zip |
build: use runonce for config checks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/replace/wafsamba.py | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/lib/replace/wafsamba.py b/lib/replace/wafsamba.py index 5afdd4af1b..46a1ea86af 100644 --- a/lib/replace/wafsamba.py +++ b/lib/replace/wafsamba.py @@ -1,25 +1,46 @@ # a waf tool to add autoconf-like macros to the configure section # and for SAMBA_ macros for building libraries, binaries etc -import Build, os, Logs, sys +import Build, os, Logs, sys, Configure, Options from Configure import conf LIB_PATH="shared" +###################################################### +# this is used as a decorator to make functions only +# run once. Based on the idea from +# http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values +runonce_ret = {} +def runonce(function): + def wrapper(*args): + if args in runonce_ret: + return runonce_ret[args] + else: + ret = function(*args) + runonce_ret[args] = ret + return ret + return wrapper + + #################################################### # some autoconf like helpers, to make the transition # to waf a bit easier for those used to autoconf # m4 files +@runonce @conf def DEFUN(conf, d, v): conf.define(d, v, quote=False) conf.env.append_value('CCDEFINES', d + '=' + str(v)) +@runonce +def CHECK_HEADER(conf, h): + if conf.check(header_name=h): + conf.env.hlist.append(h) + @conf def CHECK_HEADERS(conf, list): for hdr in list.split(): - if conf.check(header_name=hdr): - conf.env.hlist.append(hdr) + CHECK_HEADER(conf, hdr) @conf def CHECK_TYPES(conf, list): @@ -36,10 +57,15 @@ def CHECK_TYPE(conf, t, alternate): if not conf.check(type_name=t, header_name=conf.env.hlist): conf.DEFUN(t, alternate) +@runonce +def CHECK_FUNC(conf, f): + conf.check(function_name=f, header_name=conf.env.hlist) + + @conf def CHECK_FUNCS(conf, list): for f in list.split(): - conf.check(function_name=f, header_name=conf.env.hlist) + CHECK_FUNC(conf, f) @conf def CHECK_FUNCS_IN(conf, list, library): @@ -48,6 +74,7 @@ def CHECK_FUNCS_IN(conf, list, library): conf.check(function_name=f, lib=library, header_name=conf.env.hlist) conf.env['LIB_' + library.upper()] = library + ################################################# # write out config.h in the right directory @conf @@ -82,7 +109,6 @@ def ADD_CFLAGS(conf, flags): # Note that this should really check if rpath is available on this platform # and it should also honor an --enable-rpath option def set_rpath(bld): - import Options if Options.is_install: if bld.env['RPATH_ON_INSTALL']: bld.env['RPATH'] = ['-Wl,-rpath=%s/lib' % bld.env.PREFIX] @@ -323,17 +349,3 @@ def exec_command(self, cmd, **kw): Build.BuildContext.exec_command = exec_command -###################################################### -# this is used as a decorator to make functions only -# run once. Based on the idea from -# http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values -runonce_ret = {} -def runonce(function): - def wrapper(*args): - if args in runonce_ret: - return runonce_ret[args] - else: - ret = function(*args) - runonce_ret[args] = ret - return ret - return wrapper |