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))
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
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,
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',
63 # now generate a .c file from the .x file
64 t = bld(rule='''( echo '#include "config.h"' && cat ${SRC} ) > ${TGT}''',
65 source = out_files[0],
71 depends_on = name + '_ASN1',
74 # and generate a .h file from the .hx file
75 t = bld(rule='cp ${SRC} ${TGT}',
76 source = out_files[1],
81 depends_on = name + '_ASN1',
84 bld.SET_BUILD_GROUP('main')
86 includes = TO_LIST(includes)
87 includes.append(os.path.dirname(out_files[0]))
89 t = bld(features = 'cc',
92 samba_cflags = CURRENT_CFLAGS(bld, name, ''),
94 samba_deps = TO_LIST('HEIMDAL_ROKEN'),
95 samba_includes = includes,
98 Build.BuildContext.SAMBA_ASN1 = SAMBA_ASN1