diff options
-rw-r--r-- | buildtools/wafsamba/samba_patterns.py | 35 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_pidl.py | 53 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_utils.py | 48 | ||||
-rw-r--r-- | buildtools/wafsamba/wafsamba.py | 45 |
4 files changed, 103 insertions, 78 deletions
diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py index e6c7f4d3d2..f706895586 100644 --- a/buildtools/wafsamba/samba_patterns.py +++ b/buildtools/wafsamba/samba_patterns.py @@ -7,15 +7,6 @@ from Logs import debug from TaskGen import extension from samba_utils import * -########################################################## -# create a node with a new name, based on an existing node -def NEW_NODE(node, name): - ret = node.parent.find_or_declare([name]) - ASSERT(node, ret is not None, "Unable to find new target with name '%s' from '%s'" % ( - name, node.name)) - return ret - - ################################################################################ # a et task which calls out to compile_et to do the work Task.simple_task_type('et', @@ -32,32 +23,6 @@ def process_et(self, node): -################################################################################ -# a idl task which calls out to pidl to do the work -Task.simple_task_type('idl', '../../pidl/pidl ${TGT[0].options} --header --ndr-parser --client --python --server --outputdir=${TGT[0].outputdir} -- ${SRC}', color='BLUE', ext_out='.c') - -@extension('.idl') -def process_idl(self, node): - bname = node.file_base() - gen_ndr = "../gen_ndr/" - c_node = NEW_NODE(node, gen_ndr + 'ndr_%s.c' % bname) - h1_node = NEW_NODE(node, gen_ndr + '%s.h' % bname) - h2_node = NEW_NODE(node, gen_ndr + 'ndr_%s.h' % bname) - s_node = NEW_NODE(node, gen_ndr + 'ndr_%s_s.c' % bname) - cli_node = NEW_NODE(node, gen_ndr + 'ndr_%s_c.c' % bname) - cli_h_node = NEW_NODE(node, gen_ndr + 'ndr_%s_c.h' % bname) - py_node = NEW_NODE(node, gen_ndr + 'py_%s.c' % bname) - - dname = os.path.dirname(node.bld_dir(self.env)) + "/gen_ndr" - c_node.outputdir = dname - c_node.options = self.options - - self.create_task('idl', node, [c_node, h1_node, h2_node, s_node, cli_node, cli_h_node, py_node]) - - # reinject the c node to the list of nodes to process - self.allnodes.append(c_node) - - ################################################################################ diff --git a/buildtools/wafsamba/samba_pidl.py b/buildtools/wafsamba/samba_pidl.py new file mode 100644 index 0000000000..d239bb07b3 --- /dev/null +++ b/buildtools/wafsamba/samba_pidl.py @@ -0,0 +1,53 @@ +# waf build tool for building IDL files with pidl + +from TaskGen import taskgen, before +import Build, os, string +from samba_utils import * + +def SAMBA_PIDL(bld, directory, source, options=''): + '''Build a IDL file using pidl. + This will produce 7 output files''' + + name = os.path.basename(string.replace(source, '.idl', '')) + name = "PIDL_%s" % name.upper() + + if not SET_TARGET_TYPE(bld, name, 'PIDL'): + return + + bld.SET_BUILD_GROUP('build_source') + t = bld(name=name, source=source, options=options) + t.mappings['.idl'] = process_pidl + t.env.PIDL = "../../pidl/pidl" + t.env.PIDL_BUILD_TYPES = '--header --ndr-parser --client --python --server'.split() + t.env.OPTIONS = options + +Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL + + +@taskgen +def process_pidl(self, node, options=''): + '''Generate the list of output nodes for a given input IDL + file, and create the task to build them''' + bname = node.file_base() + # the output of pidl needs to go in the gen_ndr directory + gen_ndr_dir = "../gen_ndr/" + c_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s.c' % bname) + h1_node = NEW_NODE(node, gen_ndr_dir + '%s.h' % bname) + h2_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s.h' % bname) + s_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_s.c' % bname) + cli_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_c.c' % bname) + cli_h_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_c.h' % bname) + py_node = NEW_NODE(node, gen_ndr_dir + 'py_%s.c' % bname) + t = self.create_task('pidl', node, [c_node, h1_node, h2_node, s_node, + cli_node, cli_h_node, py_node]) + # setup ${OUTPUTDIR} in the pidl rule, and make sure it exists + t.env.OUTPUTDIR = os.path.dirname(c_node.abspath(self.env)) + if not os.path.isdir(t.env.OUTPUTDIR): + os.mkdir(t.env.OUTPUTDIR, 0777) + + +# the pidl task itself +import Task +Task.simple_task_type('pidl', + '${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC}', + color='BLUE', before='cc', shell=False) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 412fbe38a7..0c8a832c70 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -2,12 +2,47 @@ # and for SAMBA_ macros for building libraries, binaries etc import Build, os, Logs, sys, Configure, Options, string, Task, Utils, optparse +from TaskGen import feature, before from Configure import conf from Logs import debug from TaskGen import extension LIB_PATH="shared" + +########################################################## +# create a node with a new name, based on an existing node +def NEW_NODE(node, name): + ret = node.parent.find_or_declare([name]) + ASSERT(node, ret is not None, "Unable to find new target with name '%s' from '%s'" % ( + name, node.name)) + return ret + + +############################################################# +# set a value in a local cache +# return False if it's already set +def SET_TARGET_TYPE(ctx, target, value): + cache = LOCAL_CACHE(ctx, 'TARGET_TYPE') + if target in cache: + ASSERT(ctx, cache[target] == value, + "Target '%s' re-defined as %s - was %s" % (target, value, cache[target])) + debug("task_gen: Skipping duplicate target %s (curdir=%s)" % (target, ctx.curdir)) + return False + assumed = LOCAL_CACHE(ctx, 'ASSUMED_TARGET') + if target in assumed: + #if assumed[target] != value: + # print "Target '%s' was assumed of type '%s' but is '%s'" % (target, assumed[target], value) + ASSERT(ctx, assumed[target] == value, + "Target '%s' was assumed of type '%s' but is '%s'" % (target, assumed[target], value)) + predeclared = LOCAL_CACHE(ctx, 'PREDECLARED_TARGET') + if target in predeclared: + ASSERT(ctx, predeclared[target] == value, + "Target '%s' was predeclared of type '%s' but is '%s'" % (target, predeclared[target], value)) + LOCAL_CACHE_SET(ctx, 'TARGET_TYPE', target, value) + debug("task_gen: Target '%s' created of type '%s' in %s" % (target, value, ctx.curdir)) + return True + ###################################################### # this is used as a decorator to make functions only # run once. Based on the idea from @@ -122,6 +157,19 @@ def ADD_COMMAND(opt, name, function): Options.Handler.ADD_COMMAND = ADD_COMMAND +@feature('cprogram cc') +@before('apply_core') +def process_depends_on(self): + '''The new depends_on attribute for build rules + allow us to specify a dependency on output from + a source generation rule''' + if getattr(self , 'depends_on', None): + lst = self.to_list(self.depends_on) + for x in lst: + y = self.bld.name_to_obj(x, self.env) + y.post() + + #import TaskGen, Task # #old_post_run = Task.Task.post_run diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index a33d5d4ada..76bc3ba011 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -10,35 +10,11 @@ from TaskGen import extension from samba_utils import * from samba_autoconf import * from samba_patterns import * +from samba_pidl import * LIB_PATH="shared" -############################################################# -# set a value in a local cache -# return False if it's already set -def SET_TARGET_TYPE(ctx, target, value): - cache = LOCAL_CACHE(ctx, 'TARGET_TYPE') - if target in cache: - ASSERT(ctx, cache[target] == value, - "Target '%s' re-defined as %s - was %s" % (target, value, cache[target])) - debug("task_gen: Skipping duplicate target %s (curdir=%s)" % (target, ctx.curdir)) - return False - assumed = LOCAL_CACHE(ctx, 'ASSUMED_TARGET') - if target in assumed: - #if assumed[target] != value: - # print "Target '%s' was assumed of type '%s' but is '%s'" % (target, assumed[target], value) - ASSERT(ctx, assumed[target] == value, - "Target '%s' was assumed of type '%s' but is '%s'" % (target, assumed[target], value)) - predeclared = LOCAL_CACHE(ctx, 'PREDECLARED_TARGET') - if target in predeclared: - ASSERT(ctx, predeclared[target] == value, - "Target '%s' was predeclared of type '%s' but is '%s'" % (target, predeclared[target], value)) - LOCAL_CACHE_SET(ctx, 'TARGET_TYPE', target, value) - debug("task_gen: Target '%s' created of type '%s' in %s" % (target, value, ctx.curdir)) - return True - - ################################################################# # create the samba build environment @conf @@ -131,7 +107,7 @@ def ADD_DEPENDENCIES(bld, name, deps): CHECK_TARGET_DEPENDENCY(bld, name) list2.append(d) except AssertionError: - debug("deps: Removing dependency %s from target %s" % (d, name)) + sys.stderr.write("Removing dependency %s from target %s" % (d, name)) del(lib_deps[name][d]) # extract out the system dependencies @@ -357,23 +333,6 @@ def SAMBA_ERRTABLE(bld, name, source, ) Build.BuildContext.SAMBA_ERRTABLE = SAMBA_ERRTABLE -################################################################# -# define a PIDL target -def SAMBA_PIDL(bld, directory, source, options=''): - name = os.path.basename(string.replace(source, '.idl', '')) - name = "%s/ndr_%s.o" % (directory, name) - - if not SET_TARGET_TYPE(bld, name, 'PIDL'): - return - - bld.SET_BUILD_GROUP('build_source') - bld( - features = 'cc', - source = source, - target = name, - options = options - ) -Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL |