s3-dceprc: consolidate use of dcerpc_push_dcerpc_auth()
[Samba.git] / buildtools / wafsamba / samba_asn1.py
blobeb17f6bfe39051c8f0d4ae3478129dd33c06d0d8
1 # samba ASN1 rules
3 import Build, os
4 from samba_utils import *
5 from samba_autoconf import *
8 def SAMBA_ASN1(bld, name, source,
9 options='',
10 directory='',
11 option_file=None,
12 includes=''):
13 '''Build a ASN1 file using the asn1 compiler.
14 This will produce 2 output files'''
15 bname = os.path.basename(source)[0:-5];
16 dname = os.path.dirname(source)
17 asn1name = "%s_asn1" % bname
19 if not SET_TARGET_TYPE(bld, name, 'ASN1'):
20 return
22 # for ASN1 compilation, I always put it in build_source, as it doesn't make
23 # sense elsewhere
24 bld.SET_BUILD_GROUP('build_source')
26 out_files = []
27 out_files.append("../heimdal/%s/asn1_%s_asn1.x" % (directory, bname))
28 out_files.append("../heimdal/%s/%s_asn1.hx" % (directory, bname))
29 out_files.append("../heimdal/%s/%s_asn1-priv.hx" % (directory, bname))
31 # the ${TGT[0].parent.abspath(env)} expression gives us the parent directory of
32 # the first target in the build directory
33 # SRC[0].abspath(env) gives the absolute path to the source directory for the first
34 # source file. Note that in the case of a option_file, we have more than
35 # one source file
36 cd_rule = 'cd ${TGT[0].parent.abspath(env)}'
37 asn1_rule = cd_rule + ' && ${BLDBIN}/asn1_compile ${OPTION_FILE} ${ASN1OPTIONS} --one-code-file ${SRC[0].abspath(env)} ${ASN1NAME}'
39 source = TO_LIST(source)
40 source.append('asn1_compile')
42 if option_file is not None:
43 source.append(option_file)
45 t = bld(rule=asn1_rule,
46 ext_out = '.x',
47 before = 'cc',
48 on_results = True,
49 shell = True,
50 source = source,
51 target = out_files,
52 name=name + '_ASN1')
54 t.env.ASN1NAME = asn1name
55 t.env.ASN1OPTIONS = options
56 t.env.BLDBIN = os.path.normpath(os.path.join(bld.srcnode.abspath(bld.env), '..'))
57 if option_file is not None:
58 t.env.OPTION_FILE = "--option-file=%s" % os.path.normpath(os.path.join(bld.curdir, option_file))
60 cfile = out_files[0][0:-2] + '.c'
61 hfile = out_files[1][0:-3] + '.h',
62 hpriv = out_files[2][0:-3] + '.h',
64 # now generate a .c file from the .x file
65 t = bld(rule='''( echo '#include "config.h"' && cat ${SRC} ) > ${TGT}''',
66 source = out_files[0],
67 target = cfile,
68 shell = True,
69 on_results=True,
70 ext_out = '.c',
71 ext_in = '.x',
72 depends_on = name + '_ASN1',
73 name = name + '_C')
75 # and generate a .h file from the .hx file
76 t = bld(rule='cp ${SRC} ${TGT}',
77 source = out_files[1],
78 ext_out = '.c',
79 ext_in = '.x',
80 on_results=True,
81 target = hfile,
82 depends_on = name + '_ASN1',
83 name = name + '_H')
85 # and generate a .h file from the .hx file
86 t = bld(rule='cp ${SRC} ${TGT}',
87 source = out_files[2],
88 ext_out = '.c',
89 ext_in = '.x',
90 on_results=True,
91 target = hpriv,
92 depends_on = name + '_ASN1',
93 name = name + '_PRIV_H')
95 bld.SET_BUILD_GROUP('main')
97 includes = TO_LIST(includes)
98 includes.append(os.path.dirname(out_files[0]))
100 t = bld(features = 'cc',
101 source = cfile,
102 target = name,
103 samba_cflags = CURRENT_CFLAGS(bld, name, ''),
104 depends_on = '',
105 samba_deps = TO_LIST('HEIMDAL_ROKEN'),
106 samba_includes = includes,
107 local_include = True)
109 Build.BuildContext.SAMBA_ASN1 = SAMBA_ASN1