1 # waf build tool for building IDL files with pidl
3 from TaskGen import taskgen, before
4 import Build, os, string, Utils
5 from samba_utils import *
7 def SAMBA_PIDL(bld, pname, source, options=''):
8 '''Build a IDL file using pidl.
9 This will produce 7 output files'''
12 name = "PIDL_%s" % bname.upper()
14 if not SET_TARGET_TYPE(bld, name, 'PIDL'):
17 bld.SET_BUILD_GROUP('build_source')
19 gen_ndr_dir = '../gen_ndr/'
21 out_files.append(gen_ndr_dir + 'ndr_%s.c' % bname)
22 out_files.append(gen_ndr_dir + 'ndr_%s.h' % bname)
23 out_files.append(gen_ndr_dir + '%s.h' % bname)
24 out_files.append(gen_ndr_dir + 'ndr_%s_s.c' % bname)
25 out_files.append(gen_ndr_dir + 'ndr_%s_c.c' % bname)
26 out_files.append(gen_ndr_dir + 'ndr_%s_c.h' % bname)
27 out_files.append(gen_ndr_dir + 'py_%s.c' % bname)
29 pidl = bld.srcnode.find_resource('pidl/pidl').relpath_gen(bld.path)
30 t = bld(rule='${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC[0].abspath(env)}',
38 t.env.PIDL = "../../pidl/pidl"
39 t.env.PIDL_BUILD_TYPES = '--header --ndr-parser --client --python --server'.split()
40 t.env.OPTIONS = options
41 t.env.OUTPUTDIR = bld.BUILD_PATH(gen_ndr_dir)
43 # I'm creating the list of headers for the tables rule here.
44 # then the tables rule itself is below
45 #t.collect_headers = [bld.path.find_or_declare(out_files[1])] #, bld.path.find_or_declare(out_files[6])]
46 #if name.rfind('PIDL') > -1:
47 # print name, "t.coll", t.collect_headers
48 #print name, "so bld.PIDL_STUFF is defined", id(bld)
50 bld.PIDL_STUFF[name] = [bld.path.find_or_declare(out_files[1])]
51 except AttributeError:
53 bld.PIDL_STUFF[name] = [bld.path.find_or_declare(out_files[1])]
55 # I think I need to build this list as absolute paths, then
56 # re-do as relative paths in the tables rule
57 t.more_includes = '#' + bld.path.relpath_gen(bld.srcnode)
58 #if not 'PIDL_HEADERS' in bld.env:
59 # bld.env.PIDL_HEADERS = []
60 #bld.env.PIDL_HEADERS.append(gen_ndr_dir + 'ndr_%s.h' % bname)
64 Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL
67 #################################################################
68 # define a set of Samba PIDL targets
69 def SAMBA_PIDL_LIST(bld, name, source, options=''):
70 for p in source.split():
71 bld.SAMBA_PIDL(name, p, options)
72 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
75 #################################################################
76 # the rule for generating the NDR tables
77 from TaskGen import feature, before
81 for (name, hd) in self.bld.PIDL_STUFF.items():
82 y = self.bld.name_to_obj(name, self.env)
87 self.source += " " + node.relpath_gen(self.path)
89 def SAMBA_PIDL_TABLES(bld, name, target):
90 headers = bld.env.PIDL_HEADERS
91 # this print line should tell us what we ended up with
92 # we're ending up with the wrong relative path
93 #print "tables target=%s curdir=%s headers=%s" % (target, bld.curdir, headers)
96 rule='${SRC} --output ${TGT} > ${TGT}',
100 source = '../../librpc/tables.pl',
104 Build.BuildContext.SAMBA_PIDL_TABLES = SAMBA_PIDL_TABLES