build: fixed --includedir options for PIDL
[sfrench/samba-autobuild/.git] / buildtools / wafsamba / samba_patterns.py
1 # a waf tool to add extension based build patterns for Samba
2
3 import os, sys, Options
4 import string, Task, Utils, optparse
5 from Configure import conf
6 from Logs import debug
7 from TaskGen import extension
8 from samba_utils import *
9
10 ##########################################################
11 # create a node with a new name, based on an existing node
12 def NEW_NODE(node, name):
13     ret = node.parent.find_or_declare([name])
14     ASSERT(node, ret is not None, "Unable to find new target with name '%s' from '%s'" % (
15             name, node.name))
16     return ret
17
18
19 ################################################################################
20 # a et task which calls out to compile_et to do the work
21 Task.simple_task_type('et',
22                       '../heimdal_build/et_compile_wrapper.sh . ${TGT[0].bld_dir(env)} default/source4/heimdal_build/compile_et ${SRC[0].abspath(env)} ${TGT[0].bldpath(env)}',
23                       color='BLUE', ext_out='.c',
24                       shell = False)
25
26 @extension('.et')
27 def process_et(self, node):
28     c_node = node.change_ext('.c')
29     h_node  = node.change_ext('.h')
30     self.create_task('et', node, [c_node, h_node])
31     self.allnodes.append(c_node)
32
33
34
35 ################################################################################
36 # a idl task which calls out to pidl to do the work
37 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')
38
39 @extension('.idl')
40 def process_idl(self, node):
41     bname      = node.file_base()
42     c_node     = NEW_NODE(node, 'ndr_%s.c' % bname)
43     h1_node    = NEW_NODE(node, '%s.h' % bname)
44     h2_node    = NEW_NODE(node, 'ndr_%s.h' % bname)
45     s_node     = NEW_NODE(node, 'ndr_%s_s.c' % bname)
46     cli_node   = NEW_NODE(node, 'ndr_%s_c.c' % bname)
47     cli_h_node = NEW_NODE(node, 'ndr_%s_c.h' % bname)
48     py_node    = NEW_NODE(node, 'py_%s.c' % bname)
49
50
51     dname = os.path.dirname(node.bld_dir(self.env)) + "/gen_ndr"
52     c_node.outputdir = dname
53     c_node.options   = self.options
54
55     self.create_task('idl', node, [c_node, h1_node, h2_node, s_node, cli_node, cli_h_node, py_node])
56
57     # reinject the c node to the list of nodes to process
58     self.allnodes.append(c_node)
59
60
61
62
63 ################################################################################
64 # a asn1 task which calls out to asn1_compile_wrapper.sh to do the work
65 Task.simple_task_type('asn1',
66                       '''
67 # shell script to convert ASN1 to C. This could be separated out if we want to
68 set -e
69 compiler=${TGT[0].compiler}
70 destdir=${TGT[0].destdir}
71 wrapper=${TGT[0].asn1wrapper}
72 srcfile=${SRC[0].abspath(env)}
73 asn1name=${TGT[0].asn1name}
74 options="${TGT[0].asn1options}"
75
76 # run the wrapper
77 $wrapper . $destdir $compiler $srcfile $asn1name ${options} --one-code-file
78
79 # that generated 3 files:
80 #    ${asn1name}.hx
81 #    asn1_${asn1name}.x
82 #    ${asn1name}_files
83
84
85 hxfile=$destdir/$asn1name.hx
86 xfile=$destdir/asn1_$asn1name.x
87 listfilee=$destdir/"$asn1name"_files
88
89 cfile=${TGT[0].abspath(env)}
90 hfile=${TGT[1].abspath(env)}
91
92 cp $hxfile $hfile
93 echo '#include "config.h"' > $cfile
94 cat $xfile >> $cfile
95 rm -f $listfile
96
97 ''',
98                       color='BLUE',
99                       ext_out='.c',
100                       shell = True)
101
102 @extension('.asn1')
103 def process_asn1(self, node):
104
105     asn1name = string.replace(node.file(), '.', '_')
106     c_node  = NEW_NODE(node, 'asn1_%s.c' % asn1name)
107     h_node  = NEW_NODE(node, '%s.h' % asn1name)
108
109     c_node.destdir      = "default/source4/heimdal/" + self.asn1directory
110     c_node.asn1options  = self.asn1options
111     c_node.asn1name     = asn1name
112     c_node.asn1wrapper  = "../heimdal_build/asn1_compile_wrapper.sh"
113     c_node.compiler     = "default/source4/heimdal_build/asn1_compile"
114
115     self.create_task('asn1', node, [c_node, h_node])
116     self.allnodes.append(c_node)
117