2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2018-02-02 17:34:31 +03:00
import os, string
2010-10-06 13:11:01 +04:00
from samba_utils import MODE_755
2018-02-02 17:34:31 +03:00
from waflib import Logs
2010-03-27 10:13:44 +03:00
2014-02-28 18:59:41 +04:00
# This function checks if a perl module is installed on the system.
def check_system_perl_module(conf, module, version=None):
bundle_name = module.replace('::', '_')
module_check = module
# Create module string with version
if version:
module_check = module + ' ' + str(version)
# Check if we have to bundle it.
if conf.LIB_MUST_BE_BUNDLED(bundle_name.lower()):
return False
# Check for system perl module
2016-03-26 15:18:07 +03:00
if conf.check_perl_module(module_check) is None:
2014-02-28 18:59:41 +04:00
return False
conf.define('USING_SYSTEM_%s' % bundle_name.upper(), 1)
return True
2018-02-02 17:34:31 +03:00
def options(opt):
2014-08-26 23:33:05 +04:00
return
2010-03-27 10:13:44 +03:00
def configure(conf):
2014-02-28 18:59:45 +04:00
# Check if perl(Parse::Yapp::Driver) is available.
check_system_perl_module(conf, "Parse::Yapp::Driver", 1.05)
2010-03-28 08:51:57 +04:00
# we need a recent version of MakeMaker to get the right man page names
2010-03-28 14:00:51 +04:00
if conf.CHECK_PERL_MANPAGE():
conf.env.PERLMAN1EXT = conf.CHECK_PERL_MANPAGE(section='1')
conf.env.PERLMAN3EXT = conf.CHECK_PERL_MANPAGE(section='3')
2010-06-16 02:00:01 +04:00
conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
2010-03-27 10:13:44 +03:00
2010-03-29 14:28:49 +04:00
# yapp is used for building the parser
conf.find_program('yapp', var='YAPP')
2010-06-17 10:44:53 +04:00
conf.find_program('pod2man', var='POD2MAN')
2010-03-29 14:28:49 +04:00
2010-03-27 10:13:44 +03:00
def build(bld):
2014-08-26 01:57:23 +04:00
bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=MODE_755, perl_fixup=True)
2010-03-27 10:13:44 +03:00
2010-04-04 07:08:05 +04:00
bld.RECURSE('lib')
2010-03-27 10:13:44 +03:00
if not bld.CONFIG_SET('HAVE_PERL_MAKEMAKER'):
return
2010-06-16 20:25:04 +04:00
pidl_manpages = {
'pidl': 'man1/pidl.${PERLMAN1EXT}',
'lib/Parse/Pidl/NDR.pm': 'man3/Parse::Pidl::NDR.${PERLMAN3EXT}',
'lib/Parse/Pidl/Wireshark/Conformance.pm': 'man3/Parse::Pidl::Wireshark::Conformance.${PERLMAN3EXT}',
'lib/Parse/Pidl/Dump.pm': 'man3/Parse::Pidl::Dump.${PERLMAN3EXT}',
'lib/Parse/Pidl/Util.pm': 'man3/Parse::Pidl::Util.${PERLMAN3EXT}',
'lib/Parse/Pidl/Wireshark/NDR.pm': 'man3/Parse::Pidl::Wireshark::NDR.${PERLMAN3EXT}'
}
for k, v in pidl_manpages.iteritems():
pidl_manpages[k] = bld.EXPAND_VARIABLES(v)
2010-03-27 10:13:44 +03:00
# use perl to build the manpages
bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
2010-06-17 10:55:10 +04:00
bld.SET_BUILD_GROUP('final')
2010-06-17 10:49:36 +04:00
if 'POD2MAN' in bld.env and bld.env['POD2MAN'] != '':
for src, manpage in pidl_manpages.iteritems():
2018-05-01 22:59:23 +03:00
section = string.rsplit(manpage, ".", 1)[1]
bld(rule='${POD2MAN} -c "Samba Documentation" -s %s ${SRC} ${TGT}' % section,
2010-06-17 10:49:36 +04:00
shell=True,
source=src,
install_path=os.path.dirname(bld.EXPAND_VARIABLES('${MANDIR}/'+manpage)),
target=os.path.basename(manpage))
2010-04-02 13:18:57 +04:00
2011-01-05 14:00:01 +03:00
# we want to prefer the git version of the parsers if we can.
# Only if the source has changed do we want to re-run yapp
# But we force the developer to use the pidl standalone build
# to regenerate the files.
2011-01-18 09:20:26 +03:00
# TODO: only warn in developer mode and if 'git diff HEAD'
# shows a difference
warn_about_grammar_changes = ('PIDL_BUILD_WARNINGS' in bld.env and (
2010-04-02 13:18:57 +04:00
bld.IS_NEWER('idl.yp', 'lib/Parse/Pidl/IDL.pm') or
bld.IS_NEWER('expr.yp', 'lib/Parse/Pidl/Expr.pm')))
2011-01-18 09:20:26 +03:00
if warn_about_grammar_changes:
2011-01-06 15:41:08 +03:00
Logs.warn('''
2011-01-05 14:00:01 +03:00
Pidl grammar files have changed. Please use the pidl standalone build
to regenerate them with yapp.
2011-01-06 15:41:08 +03:00
$ cd ../pidl
2011-01-05 14:00:01 +03:00
$ perl Makefile.PL
$ make lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
$ git add lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
$ git commit
2011-01-06 15:41:08 +03:00
$ cd -
2011-01-05 14:00:01 +03:00
If your 100% sure you haven't changed idl.yp and expr.yp
try this to avoid this message:
2011-01-06 15:41:08 +03:00
$ touch ../pidl/lib/Parse/Pidl/IDL.pm ../pidl/lib/Parse/Pidl/Expr.pm
2011-01-05 14:00:01 +03:00
''')