s4-waf: added rules for rebuilding the yapp parser in pidl
authorAndrew Tridgell <tridge@samba.org>
Mon, 29 Mar 2010 10:28:49 +0000 (21:28 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:16 +0000 (20:27 +1000)
buildtools/wafsamba/samba_utils.py
pidl/wscript

index d3be7945c01e43eddd89358a871696acdf6c4c9c..4230d8066f5b67c816be94e4bf9031c9ec2a954d 100644 (file)
@@ -383,3 +383,12 @@ def LOAD_ENVIRONMENT():
     env = Environment.Environment()
     env.load('bin/c4che/default.cache.py')
     return env
+
+
+def IS_NEWER(bld, file1, file2):
+    '''return True if file1 is newer than file2'''
+    t1 = os.stat(os.path.join(bld.curdir, file1)).st_mtime
+    t2 = os.stat(os.path.join(bld.curdir, file2)).st_mtime
+    return t1 > t2
+Build.BuildContext.IS_NEWER = IS_NEWER
+
index 733a45505954695fe3ae48b2f5e01494dc1d4865..4d7e468a9742d78c696ac198fab565603d25db3b 100644 (file)
@@ -13,6 +13,10 @@ def configure(conf):
         conf.env.PERLMAN3EXT = conf.CHECK_PERL_MANPAGE(section='3')
         conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
 
+    # yapp is used for building the parser
+    conf.find_program('yapp', var='YAPP')
+
+
 def build(bld):
     bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=0755)
 
@@ -35,6 +39,13 @@ def build(bld):
     # use perl to build the manpages
     bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
 
+    # we want to prefer the git version if we can. Only if the
+    # source has changed do we want to re-run yapp
+    if ('YAPP' in bld.env and (
+        bld.IS_NEWER('idl.yp', 'lib/Parse/Pidl/IDL.pm') or
+        bld.IS_NEWER('expr.yp', 'lib/Parse/Pidl/Expr.pm'))):
+        pidl_src.extend(['idl.yp', 'expr.yp'])
+
     bld.SAMBA_GENERATOR('pidl_manpages',
                         source=pidl_src,
                         target=pidl_manpages,