4 from samba_utils
import *
5 from samba_autoconf
import *
8 def SAMBA_ASN1(bld
, name
, source
,
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'):
22 # for ASN1 compilation, I always put it in build_source, as it doesn't make
24 bld
.SET_BUILD_GROUP('build_source')
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
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',
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],
72 depends_on
= name
+ '_ASN1',
75 # and generate a .h file from the .hx file
76 t
= bld(rule
='cp ${SRC} ${TGT}',
77 source
= out_files
[1],
82 depends_on
= name
+ '_ASN1',
85 # and generate a .h file from the .hx file
86 t
= bld(rule
='cp ${SRC} ${TGT}',
87 source
= out_files
[2],
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',
103 samba_cflags
= CURRENT_CFLAGS(bld
, name
, ''),
105 samba_deps
= TO_LIST('HEIMDAL_ROKEN'),
106 samba_includes
= includes
,
107 local_include
= True)
109 Build
.BuildContext
.SAMBA_ASN1
= SAMBA_ASN1