build: rewrote PIDL rules, breaking them into a separate waf tool
[samba.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 # a et task which calls out to compile_et to do the work
12 Task.simple_task_type('et',
13                       '../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)}',
14                       color='BLUE', ext_out='.c',
15                       shell = False)
16
17 @extension('.et')
18 def process_et(self, node):
19     c_node = node.change_ext('.c')
20     h_node  = node.change_ext('.h')
21     self.create_task('et', node, [c_node, h_node])
22     self.allnodes.append(c_node)
23
24
25
26
27
28 ################################################################################
29 # a asn1 task which calls out to asn1_compile_wrapper.sh to do the work
30 Task.simple_task_type('asn1',
31                       '''
32 # shell script to convert ASN1 to C. This could be separated out if we want to
33 set -e
34 compiler=${TGT[0].compiler}
35 destdir=${TGT[0].destdir}
36 wrapper=${TGT[0].asn1wrapper}
37 srcfile=${SRC[0].abspath(env)}
38 asn1name=${TGT[0].asn1name}
39 options="${TGT[0].asn1options}"
40
41 # run the wrapper
42 $wrapper . $destdir $compiler $srcfile $asn1name ${options} --one-code-file
43
44 # that generated 3 files:
45 #    ${asn1name}.hx
46 #    asn1_${asn1name}.x
47 #    ${asn1name}_files
48
49
50 hxfile=$destdir/$asn1name.hx
51 xfile=$destdir/asn1_$asn1name.x
52 listfilee=$destdir/"$asn1name"_files
53
54 cfile=${TGT[0].abspath(env)}
55 hfile=${TGT[1].abspath(env)}
56
57 cp $hxfile $hfile
58 echo '#include "config.h"' > $cfile
59 cat $xfile >> $cfile
60 rm -f $listfile
61
62 ''',
63                       color='BLUE',
64                       ext_out='.c',
65                       shell = True)
66
67 @extension('.asn1')
68 def process_asn1(self, node):
69
70     asn1name = string.replace(node.file(), '.', '_')
71     c_node  = NEW_NODE(node, 'asn1_%s.c' % asn1name)
72     h_node  = NEW_NODE(node, '%s.h' % asn1name)
73
74     c_node.destdir      = "default/source4/heimdal/" + self.asn1directory
75     c_node.asn1options  = self.asn1options
76     c_node.asn1name     = asn1name
77     c_node.asn1wrapper  = "../heimdal_build/asn1_compile_wrapper.sh"
78     c_node.compiler     = "default/source4/heimdal_build/asn1_compile"
79
80     self.create_task('asn1', node, [c_node, h_node])
81     self.allnodes.append(c_node)
82