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