py:dcerpc/raw_testcase: let do_single_request() check stub length against alloc_hint
[samba.git] / pidl / wscript
1 #!/usr/bin/env python
2
3 import os, string
4 from samba_utils import MODE_755
5 from waflib import Logs
6
7 # This function checks if a perl module is installed on the system.
8 def check_system_perl_module(conf, module, version=None):
9     bundle_name = module.replace('::', '_')
10     module_check = module
11
12     # Create module string with version
13     if version:
14         module_check = module + ' ' + str(version)
15
16     # Check if we have to bundle it.
17     if conf.LIB_MUST_BE_BUNDLED(bundle_name.lower()):
18         return False
19
20     # Check for system perl module
21     if conf.check_perl_module(module_check) is None:
22         return False
23
24     conf.define('USING_SYSTEM_%s' % bundle_name.upper(), 1)
25
26     return True
27
28 def options(opt):
29     return
30
31 def configure(conf):
32     # Check if perl(Parse::Yapp::Driver) is available.
33     check_system_perl_module(conf, "Parse::Yapp::Driver", 1.05)
34
35     # we need a recent version of MakeMaker to get the right man page names
36     if conf.CHECK_PERL_MANPAGE():
37         conf.env.PERLMAN1EXT = conf.CHECK_PERL_MANPAGE(section='1')
38         conf.env.PERLMAN3EXT = conf.CHECK_PERL_MANPAGE(section='3')
39         conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
40
41     # yapp is used for building the parser
42     conf.find_program('yapp', var='YAPP')
43     conf.find_program('pod2man', var='POD2MAN')
44
45 def build(bld):
46     bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=MODE_755, perl_fixup=True)
47
48     bld.RECURSE('lib')
49
50     if not bld.CONFIG_SET('HAVE_PERL_MAKEMAKER'):
51         return
52
53     pidl_manpages = {
54         'pidl': 'man1/pidl.${PERLMAN1EXT}',
55         'lib/Parse/Pidl/NDR.pm': 'man3/Parse::Pidl::NDR.${PERLMAN3EXT}',
56         'lib/Parse/Pidl/Wireshark/Conformance.pm': 'man3/Parse::Pidl::Wireshark::Conformance.${PERLMAN3EXT}',
57         'lib/Parse/Pidl/Dump.pm': 'man3/Parse::Pidl::Dump.${PERLMAN3EXT}',
58         'lib/Parse/Pidl/Util.pm': 'man3/Parse::Pidl::Util.${PERLMAN3EXT}',
59         'lib/Parse/Pidl/Wireshark/NDR.pm': 'man3/Parse::Pidl::Wireshark::NDR.${PERLMAN3EXT}'
60     }
61
62     for k in pidl_manpages.keys():
63         pidl_manpages[k] = bld.EXPAND_VARIABLES(pidl_manpages[k])
64
65     # use perl to build the manpages
66     bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
67
68     bld.SET_BUILD_GROUP('final')
69     if 'POD2MAN' in bld.env and bld.env['POD2MAN'] != '':
70         for src in pidl_manpages.keys():
71             manpage = pidl_manpages[src]
72             section = manpage.rsplit( ".", 1)[1]
73             bld(rule='${POD2MAN} -c "Samba Documentation" -s %s ${SRC} ${TGT}' % section,
74                 shell=True,
75                 source=src,
76                 install_path=os.path.dirname(bld.EXPAND_VARIABLES('${MANDIR}/'+manpage)),
77                 target=os.path.basename(manpage))
78
79     # we want to prefer the git version of the parsers if we can.
80     # Only if the source has changed do we want to re-run yapp
81     # But we force the developer to use the pidl standalone build
82     # to regenerate the files.
83     # TODO: only warn in developer mode and if 'git diff HEAD'
84     #       shows a difference
85     warn_about_grammar_changes = ('PIDL_BUILD_WARNINGS' in bld.env and (
86         bld.IS_NEWER('idl.yp', 'lib/Parse/Pidl/IDL.pm') or
87         bld.IS_NEWER('expr.yp', 'lib/Parse/Pidl/Expr.pm')))
88
89     if warn_about_grammar_changes:
90         Logs.warn('''
91 Pidl grammar files have changed. Please use the pidl standalone build
92 to regenerate them with yapp.
93
94 $ cd ../pidl
95 $ perl Makefile.PL
96 $ make lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
97 $ git add lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
98 $ git commit
99 $ cd -
100
101 If your 100% sure you haven't changed idl.yp and expr.yp
102 try this to avoid this message:
103
104 $ touch ../pidl/lib/Parse/Pidl/IDL.pm ../pidl/lib/Parse/Pidl/Expr.pm
105 ''')
106