build: only depend on the actual pidl source files in the pidl rule
[nivanova/samba-autobuild/.git] / buildtools / wafsamba / samba_pidl.py
index d37e7f1d23cdef88ac7ef0ae4da26252b878a990..14a5b3fb126699aaa1a5a941f5063974a2096ef9 100644 (file)
@@ -1,10 +1,13 @@
 # waf build tool for building IDL files with pidl
 
-from TaskGen import taskgen, before
-import Build, os, string, Utils
+from TaskGen import before
+import Build, os
 from samba_utils import *
 
-def SAMBA_PIDL(bld, pname, source, options='', output_dir='.'):
+def SAMBA_PIDL(bld, pname, source,
+               options='',
+               output_dir='.',
+               symlink=False):
     '''Build a IDL file using pidl.
        This will produce up to 13 output files depending on the options used'''
 
@@ -26,6 +29,8 @@ def SAMBA_PIDL(bld, pname, source, options='', output_dir='.'):
                     '--client'            : 'ndr_%s_c.c ndr_%s_c.h',
                     '--python'            : 'py_%s.c',
                     '--tdr-parser'        : 'tdr_%s.c tdr_%s.h',
+                    '--dcom-proxy'       : '%s_p.c',
+                    '--com-header'       : 'com_%s.h'
                     }
 
     table_header_idx = None
@@ -41,21 +46,46 @@ def SAMBA_PIDL(bld, pname, source, options='', output_dir='.'):
                     # remember this one for the tables generation
                     table_header_idx = len(out_files) - 1
 
-    pidl = bld.srcnode.find_resource('pidl/pidl').relpath_gen(bld.path)
+    # depend on the full pidl sources
+    source = TO_LIST(source)
+    try:
+        pidl_src_nodes = bld.pidl_files_cache
+    except AttributeError:
+        bld.pidl_files_cache = bld.srcnode.ant_glob('pidl/**/*.pm', flat=False)
+        bld.pidl_files_cache.extend(bld.srcnode.ant_glob('pidl', flat=False))
+        pidl_src_nodes = bld.pidl_files_cache
 
     # the cd .. is needed because pidl currently is sensitive to the directory it is run in
     t = bld(rule='cd .. && ${PIDL} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC[0].abspath(env)}',
-            ext_out = '.c',
-            before  = 'cc',
-            shell   = True,
-            source  = source,
-            target  = out_files,
-            name    = name)
+            ext_out    = '.c',
+            before     = 'cc',
+            on_results = True,
+            shell      = True,
+            source     = source,
+            target     = out_files,
+            name       = name,
+            samba_type = 'PIDL')
+
+    # prime the list of nodes we are dependent on with the cached pidl sources
+    t.allnodes = pidl_src_nodes
 
     t.env.PIDL = "../pidl/pidl"
     t.env.OPTIONS = TO_LIST(options)
-    t.env.OUTPUTDIR = 'bin/' + bld.BUILD_PATH(output_dir)
 
+    # this rather convoluted set of path calculations is to cope with the possibility
+    # that gen_ndr is a symlink into the source tree. By doing this for the source3
+    # gen_ndr directory we end up generating identical output in gen_ndr for the old
+    # build system and the new one. That makes keeping things in sync much easier.
+    # eventually we should drop the gen_ndr files in git, but in the meanwhile this works
+    outdir = bld.bldnode.name + '/' + bld.path.find_dir(output_dir).bldpath(t.env)
+
+    if not os.path.lexists(outdir):
+        link_source = os.path.normpath(os.path.join(bld.curdir,output_dir))
+        link_source = os_path_relpath(link_source, os.path.dirname(outdir))
+        os.symlink(link_source, outdir)
+
+    real_outputdir = os.path.realpath(outdir)
+    t.env.OUTPUTDIR = os_path_relpath(real_outputdir, bld.bldnode.name + '/..')
 
     if table_header_idx is not None:
         pidl_headers = LOCAL_CACHE(bld, 'PIDL_HEADERS')
@@ -65,10 +95,13 @@ def SAMBA_PIDL(bld, pname, source, options='', output_dir='.'):
 Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL
 
 
-def SAMBA_PIDL_LIST(bld, name, source, options='', output_dir='.'):
+def SAMBA_PIDL_LIST(bld, name, source,
+                    options='',
+                    output_dir='.',
+                    symlink=False):
     '''A wrapper for building a set of IDL files'''
     for p in TO_LIST(source):
-        bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir)
+        bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir, symlink=symlink)
 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
 
 
@@ -94,6 +127,7 @@ def SAMBA_PIDL_TABLES(bld, name, target):
             rule     = '${SRC} --output ${TGT} | sed "s|default/||" > ${TGT}',
             ext_out  = '.c',
             before   = 'cc',
+            on_results = True,
             shell    = True,
             source   = '../../librpc/tables.pl',
             target   = target,