wafsamba: remove tru64cc.py as it's not compatible with waf 2
[samba.git] / buildtools / wafsamba / samba_pidl.py
index 2770728a442e3e8948e3ff12c2954e8207d31e08..2ff2c0dc64dbc724463d8ca1e14c2b3a75f97976 100644 (file)
@@ -1,13 +1,13 @@
 # waf build tool for building IDL files with pidl
 
-from TaskGen import before
-import Build, os, sys, Logs
-from samba_utils import *
+import os
+from waflib import Build, Utils
+from waflib.TaskGen import feature, before
+from samba_utils import SET_TARGET_TYPE, TO_LIST, LOCAL_CACHE
 
 def SAMBA_PIDL(bld, pname, source,
                options='',
                output_dir='.',
-               symlink=False,
                generate_tables=True):
     '''Build a IDL file using pidl.
        This will produce up to 13 output files depending on the options used'''
@@ -31,8 +31,8 @@ def SAMBA_PIDL(bld, pname, source,
                     '--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'
+                    '--dcom-proxy'        : '%s_p.c',
+                    '--com-header'        : 'com_%s.h'
                     }
 
     table_header_idx = None
@@ -60,11 +60,11 @@ def SAMBA_PIDL(bld, pname, source,
     # the cd .. is needed because pidl currently is sensitive to the directory it is run in
     cpp = ""
     cc = ""
-    if bld.CONFIG_SET("CPP"):
+    if bld.CONFIG_SET("CPP") and bld.CONFIG_GET("CPP") != "":
         if isinstance(bld.CONFIG_GET("CPP"), list):
-            cpp = "CPP=%s" % bld.CONFIG_GET("CPP")[0]
+            cpp = 'CPP="%s"' % " ".join(bld.CONFIG_GET("CPP"))
         else:
-            cpp = "CPP=%s" % bld.CONFIG_GET("CPP")
+            cpp = 'CPP="%s"' % bld.CONFIG_GET("CPP")
 
     if cpp == "CPP=xlc_r":
         cpp = ""
@@ -72,14 +72,14 @@ def SAMBA_PIDL(bld, pname, source,
 
     if bld.CONFIG_SET("CC"):
         if isinstance(bld.CONFIG_GET("CC"), list):
-            cc = "CC=%s" % bld.CONFIG_GET("CC")[0]
+            cc = 'CC="%s"' % " ".join(bld.CONFIG_GET("CC"))
         else:
-            cc = "CC=%s" % bld.CONFIG_GET("CC")
+            cc = 'CC="%s"' % bld.CONFIG_GET("CC")
 
     t = bld(rule='cd .. && %s %s ${PERL} "${PIDL}" --quiet ${OPTIONS} --outputdir ${OUTPUTDIR} -- "${SRC[0].abspath(env)}"' % (cpp, cc),
             ext_out    = '.c',
-            before     = 'cc',
-            on_results = True,
+            before     = 'c',
+            update_outputs = True,
             shell      = True,
             source     = source,
             target     = out_files,
@@ -91,73 +91,51 @@ def SAMBA_PIDL(bld, pname, source,
 
     t.env.PIDL = os.path.join(bld.srcnode.abspath(), 'pidl/pidl')
     t.env.OPTIONS = TO_LIST(options)
-
-    # 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
-
-    found_dir = bld.path.find_dir(output_dir)
-    if not 'abspath' in dir(found_dir):
-        Logs.error('Unable to find pidl output directory %s' %
-                   os.path.normpath(os.path.join(bld.curdir, output_dir)))
-        sys.exit(1)
-
-    outdir = bld.path.find_dir(output_dir).abspath(t.env)
-
-    if symlink and not os.path.lexists(outdir):
-        link_source = os.path.normpath(os.path.join(bld.curdir,output_dir))
-        os.symlink(link_source, outdir)
-
-    real_outputdir = os.path.realpath(outdir)
-    t.env.OUTPUTDIR = os_path_relpath(real_outputdir, os.path.dirname(bld.env.BUILD_DIRECTORY))
+    t.env.OUTPUTDIR = bld.bldnode.parent.name + '/default/' + bld.path.find_dir(output_dir).path_from(bld.srcnode)
 
     if generate_tables and table_header_idx is not None:
         pidl_headers = LOCAL_CACHE(bld, 'PIDL_HEADERS')
         pidl_headers[name] = [bld.path.find_or_declare(out_files[table_header_idx])]
 
-    t.more_includes = '#' + bld.path.relpath_gen(bld.srcnode)
+    t.more_includes = '#' + bld.path.path_from(bld.srcnode)
 Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL
 
 
 def SAMBA_PIDL_LIST(bld, name, source,
                     options='',
                     output_dir='.',
-                    symlink=False,
                     generate_tables=True):
     '''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, symlink=symlink, generate_tables=generate_tables)
+        bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir, generate_tables=generate_tables)
 Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
 
 
 #################################################################
 # the rule for generating the NDR tables
-from TaskGen import feature, before
 @feature('collect')
 @before('exec_rule')
 def collect(self):
     pidl_headers = LOCAL_CACHE(self.bld, 'PIDL_HEADERS')
+    self.source = Utils.to_list(self.source)
     for (name, hd) in pidl_headers.items():
-        y = self.bld.name_to_obj(name, self.env)
+        y = self.bld.get_tgen_by_name(name)
         self.bld.ASSERT(y is not None, 'Failed to find PIDL header %s' % name)
         y.post()
         for node in hd:
             self.bld.ASSERT(node is not None, 'Got None as build node generating PIDL table for %s' % name)
-            self.source += " " + node.relpath_gen(self.path)
+            self.source.append(node)
 
 
 def SAMBA_PIDL_TABLES(bld, name, target):
     '''generate the pidl NDR tables file'''
-    headers = bld.env.PIDL_HEADERS
     bld.SET_BUILD_GROUP('main')
     t = bld(
             features = 'collect',
             rule     = '${PERL} ${SRC} --output ${TGT} | sed "s|default/||" > ${TGT}',
             ext_out  = '.c',
-            before   = 'cc',
-            on_results = True,
+            before   = 'c',
+            update_outputs = True,
             shell    = True,
             source   = '../../librpc/tables.pl',
             target   = target,