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
2020-02-02 06:05:38 +03:00
from waflib import Logs, Errors
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):
module_check = module
# Create module string with version
if version:
module_check = module + ' ' + str(version)
# 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
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.
2020-02-02 06:05:38 +03:00
if not check_system_perl_module(conf,
"Parse::Yapp::Driver",
1.05):
raise Errors.WafError('perl module "Parse::Yapp::Driver" not found')
2014-02-28 18:59:45 +04:00
2010-03-29 14:28:49 +04:00
# yapp is used for building the parser
2020-02-02 06:05:38 +03:00
if not conf.find_program('yapp', var='YAPP'):
raise Errors.WafError('yapp not found')
2010-03-29 14:28:49 +04:00
2010-03-27 10:13:44 +03:00
def build(bld):
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
''')