3 from TaskGen import before
5 from samba_utils import *
6 from samba_autoconf import *
9 def SAMBA_ASN1(bld, name, source,
14 '''Build a ASN1 file using the asn1 compiler.
15 This will produce 2 output files'''
16 bname = os.path.basename(source)[0:-5];
17 dname = os.path.dirname(source)
18 asn1name = "%s_asn1" % bname
20 if not SET_TARGET_TYPE(bld, name, 'ASN1'):
23 # for ASN1 compilation, I always put it in build_source, as it doesn't make
25 bld.SET_BUILD_GROUP('build_source')
28 out_files.append("../heimdal/%s/asn1_%s_asn1.x" % (directory, bname))
29 out_files.append("../heimdal/%s/%s_asn1.hx" % (directory, bname))
30 out_files.append("../heimdal/%s/%s_asn1-priv.hx" % (directory, bname))
32 # the ${TGT[0].parent.abspath(env)} expression gives us the parent directory of
33 # the first target in the build directory
34 # SRC[0].abspath(env) gives the absolute path to the source directory for the first
35 # source file. Note that in the case of a option_file, we have more than
37 cd_rule = 'cd ${TGT[0].parent.abspath(env)}'
38 asn1_rule = cd_rule + ' && ${BLDBIN}/asn1_compile ${OPTION_FILE} ${ASN1OPTIONS} --one-code-file ${SRC[0].abspath(env)} ${ASN1NAME}'
40 source = TO_LIST(source)
41 source.append('asn1_compile')
43 if option_file is not None:
44 source.append(option_file)
46 t = bld(rule=asn1_rule,
55 t.env.ASN1NAME = asn1name
56 t.env.ASN1OPTIONS = options
57 t.env.BLDBIN = os.path.normpath(os.path.join(bld.srcnode.abspath(bld.env), '..'))
58 if option_file is not None:
59 t.env.OPTION_FILE = "--option-file=%s" % os.path.normpath(os.path.join(bld.curdir, option_file))
61 cfile = out_files[0][0:-2] + '.c'
62 hfile = out_files[1][0:-3] + '.h',
63 hpriv = out_files[2][0:-3] + '.h',
65 # now generate a .c file from the .x file
66 t = bld(rule='''( echo '#include "config.h"' && cat ${SRC} ) > ${TGT}''',
67 source = out_files[0],
73 depends_on = name + '_ASN1',
76 # and generate a .h file from the .hx file
77 t = bld(rule='cp ${SRC} ${TGT}',
78 source = out_files[1],
83 depends_on = name + '_ASN1',
86 # and generate a .h file from the .hx file
87 t = bld(rule='cp ${SRC} ${TGT}',
88 source = out_files[2],
93 depends_on = name + '_ASN1',
94 name = name + '_PRIV_H')
96 bld.SET_BUILD_GROUP('main')
98 includes = TO_LIST(includes)
99 includes.append(os.path.dirname(out_files[0]))
101 t = bld(features = 'cc',
104 samba_cflags = CURRENT_CFLAGS(bld, name, ''),
106 samba_deps = TO_LIST('HEIMDAL_ROKEN'),
107 samba_includes = includes,
108 local_include = True)
110 Build.BuildContext.SAMBA_ASN1 = SAMBA_ASN1