summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_pidl.py118
-rw-r--r--buildtools/wafsamba/samba_utils.py44
-rw-r--r--buildtools/wafsamba/wafsamba.py25
3 files changed, 140 insertions, 47 deletions
diff --git a/buildtools/wafsamba/samba_pidl.py b/buildtools/wafsamba/samba_pidl.py
index d239bb07b3..9269566111 100644
--- a/buildtools/wafsamba/samba_pidl.py
+++ b/buildtools/wafsamba/samba_pidl.py
@@ -1,53 +1,105 @@
# waf build tool for building IDL files with pidl
from TaskGen import taskgen, before
-import Build, os, string
+import Build, os, string, Utils
from samba_utils import *
-def SAMBA_PIDL(bld, directory, source, options=''):
+def SAMBA_PIDL(bld, pname, source, options=''):
'''Build a IDL file using pidl.
This will produce 7 output files'''
- name = os.path.basename(string.replace(source, '.idl', ''))
- name = "PIDL_%s" % name.upper()
+ bname = source[0:-4];
+ name = "PIDL_%s" % bname.upper()
if not SET_TARGET_TYPE(bld, name, 'PIDL'):
return
bld.SET_BUILD_GROUP('build_source')
- t = bld(name=name, source=source, options=options)
- t.mappings['.idl'] = process_pidl
+
+ gen_ndr_dir = '../gen_ndr/'
+ out_files = []
+ out_files.append(gen_ndr_dir + 'ndr_%s.c' % bname)
+ out_files.append(gen_ndr_dir + 'ndr_%s.h' % bname)
+ out_files.append(gen_ndr_dir + '%s.h' % bname)
+ out_files.append(gen_ndr_dir + 'ndr_%s_s.c' % bname)
+ out_files.append(gen_ndr_dir + 'ndr_%s_c.c' % bname)
+ out_files.append(gen_ndr_dir + 'ndr_%s_c.h' % bname)
+ out_files.append(gen_ndr_dir + 'py_%s.c' % bname)
+
+ pidl = bld.srcnode.find_resource('pidl/pidl').relpath_gen(bld.path)
+ t = bld(rule='${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC[0].abspath(env)}',
+ ext_out = '.c',
+ before = 'cc',
+ shell = False,
+ source=source,
+ target = out_files,
+ name=name)
+
t.env.PIDL = "../../pidl/pidl"
t.env.PIDL_BUILD_TYPES = '--header --ndr-parser --client --python --server'.split()
t.env.OPTIONS = options
+ t.env.OUTPUTDIR = bld.BUILD_PATH(gen_ndr_dir)
+
+ # I'm creating the list of headers for the tables rule here.
+ # then the tables rule itself is below
+ #t.collect_headers = [bld.path.find_or_declare(out_files[1])] #, bld.path.find_or_declare(out_files[6])]
+ #if name.rfind('PIDL') > -1:
+ # print name, "t.coll", t.collect_headers
+ #print name, "so bld.PIDL_STUFF is defined", id(bld)
+ try:
+ bld.PIDL_STUFF[name] = [bld.path.find_or_declare(out_files[1])]
+ except AttributeError:
+ bld.PIDL_STUFF = {}
+ bld.PIDL_STUFF[name] = [bld.path.find_or_declare(out_files[1])]
+
+ # I think I need to build this list as absolute paths, then
+ # re-do as relative paths in the tables rule
+ t.more_includes = '#' + bld.path.relpath_gen(bld.srcnode)
+ #if not 'PIDL_HEADERS' in bld.env:
+ # bld.env.PIDL_HEADERS = []
+ #bld.env.PIDL_HEADERS.append(gen_ndr_dir + 'ndr_%s.h' % bname)
+
+
Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL
-@taskgen
-def process_pidl(self, node, options=''):
- '''Generate the list of output nodes for a given input IDL
- file, and create the task to build them'''
- bname = node.file_base()
- # the output of pidl needs to go in the gen_ndr directory
- gen_ndr_dir = "../gen_ndr/"
- c_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s.c' % bname)
- h1_node = NEW_NODE(node, gen_ndr_dir + '%s.h' % bname)
- h2_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s.h' % bname)
- s_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_s.c' % bname)
- cli_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_c.c' % bname)
- cli_h_node = NEW_NODE(node, gen_ndr_dir + 'ndr_%s_c.h' % bname)
- py_node = NEW_NODE(node, gen_ndr_dir + 'py_%s.c' % bname)
- t = self.create_task('pidl', node, [c_node, h1_node, h2_node, s_node,
- cli_node, cli_h_node, py_node])
- # setup ${OUTPUTDIR} in the pidl rule, and make sure it exists
- t.env.OUTPUTDIR = os.path.dirname(c_node.abspath(self.env))
- if not os.path.isdir(t.env.OUTPUTDIR):
- os.mkdir(t.env.OUTPUTDIR, 0777)
-
-
-# the pidl task itself
-import Task
-Task.simple_task_type('pidl',
- '${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC}',
- color='BLUE', before='cc', shell=False)
+#################################################################
+# define a set of Samba PIDL targets
+def SAMBA_PIDL_LIST(bld, name, source, options=''):
+ for p in source.split():
+ bld.SAMBA_PIDL(name, p, options)
+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):
+ for (name, hd) in self.bld.PIDL_STUFF.items():
+ y = self.bld.name_to_obj(name, self.env)
+ if not y:
+ raise "!"+str(name)
+ y.post()
+ for node in hd:
+ self.source += " " + node.relpath_gen(self.path)
+
+def SAMBA_PIDL_TABLES(bld, name, target):
+ headers = bld.env.PIDL_HEADERS
+ # this print line should tell us what we ended up with
+ # we're ending up with the wrong relative path
+ #print "tables target=%s curdir=%s headers=%s" % (target, bld.curdir, headers)
+ t = bld(
+ features = 'collect',
+ rule='${SRC} --output ${TGT} > ${TGT}',
+ ext_out = '.c',
+ before = 'cc',
+ shell = True,
+ source = '../../librpc/tables.pl',
+ target=target,
+ name=name)
+ print name
+Build.BuildContext.SAMBA_PIDL_TABLES = SAMBA_PIDL_TABLES
+
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 0c8a832c70..bdbd3c7b93 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -157,7 +157,7 @@ def ADD_COMMAND(opt, name, function):
Options.Handler.ADD_COMMAND = ADD_COMMAND
-@feature('cprogram cc')
+@feature('cprogram','cc','cshlib')
@before('apply_core')
def process_depends_on(self):
'''The new depends_on attribute for build rules
@@ -169,6 +169,27 @@ def process_depends_on(self):
y = self.bld.name_to_obj(x, self.env)
y.post()
+ if getattr(y, 'more_includes', None):
+ self.includes += " " + y.more_includes
+
+
+#@feature('cprogram cc cshlib')
+#@before('apply_core')
+#def process_generated_dependencies(self):
+# '''Ensure that any dependent source generation happens
+# before any task that requires the output'''
+# if getattr(self , 'depends_on', None):
+# lst = self.to_list(self.depends_on)
+# for x in lst:
+# y = self.bld.name_to_obj(x, self.env)
+# y.post()
+
+
+def FIND_TASKGEN(bld, name):
+ '''find a waf task generator given a target name'''
+ return bld.name_to_obj(name)
+Build.BuildContext.FIND_TASKGEN = FIND_TASKGEN
+
#import TaskGen, Task
#
@@ -179,3 +200,24 @@ def process_depends_on(self):
#
#for y in ['cc', 'cxx']:
# TaskGen.classes[y].post_run = new_post_run
+
+def ENABLE_MAGIC_ORDERING(bld):
+ '''enable automatic build order constraint calculation
+ see page 35 of the waf book'''
+ print "Enabling magic ordering"
+ bld.use_the_magic()
+Build.BuildContext.ENABLE_MAGIC_ORDERING = ENABLE_MAGIC_ORDERING
+
+
+def BUILD_PATH(bld, relpath):
+ '''return a relative build path, given a relative path
+ for example, if called in the source4/librpc directory, with the path
+ gen_ndr/tables.c, then it will return default/source4/gen_ndr/tables.c
+ '''
+
+ ret = os.path.normpath(os.path.join(os.path.relpath(bld.curdir, bld.env.TOPDIR), relpath))
+ ret = 'default/%s' % ret
+ return ret
+Build.BuildContext.BUILD_PATH = BUILD_PATH
+
+
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 58f98fe1ca..932b9e3bd0 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -8,6 +8,7 @@ from TaskGen import extension
# bring in the other samba modules
from samba_utils import *
+# should be enabled from the above?
from samba_autoconf import *
from samba_patterns import *
from samba_pidl import *
@@ -110,12 +111,13 @@ def ADD_DEPENDENCIES(bld, name, deps):
sys.stderr.write("Removing dependency %s from target %s\n" % (d, name))
del(lib_deps[name][d])
+ target_cache = LOCAL_CACHE(bld, 'TARGET_TYPE')
+
# extract out the system dependencies
sysdeps = []
localdeps = []
add_objects = []
cache = LOCAL_CACHE(bld, 'EMPTY_TARGETS')
- target_cache = LOCAL_CACHE(bld, 'TARGET_TYPE')
predeclare = LOCAL_CACHE(bld, 'PREDECLARED_TARGET')
for d in list2:
recurse = False
@@ -188,7 +190,8 @@ def SAMBA_LIBRARY(bld, libname, source,
cflags='',
output_type=None,
realname=None,
- autoproto=None):
+ autoproto=None,
+ depends_on=''):
if not SET_TARGET_TYPE(bld, libname, 'LIBRARY'):
return
@@ -211,6 +214,7 @@ def SAMBA_LIBRARY(bld, libname, source,
add_objects = add_objects,
ccflags = CURRENT_CFLAGS(bld, cflags),
includes='. ' + bld.env['BUILD_DIRECTORY'] + '/default ' + ilist,
+ depends_on=depends_on,
vnum=vnum)
# put a link to the library in bin/shared
@@ -336,14 +340,6 @@ Build.BuildContext.SAMBA_ERRTABLE = SAMBA_ERRTABLE
-#################################################################
-# define a set of Samba PIDL targets
-def SAMBA_PIDL_LIST(bld, directory, source, options=''):
- for p in source.split():
- bld.SAMBA_PIDL(directory, p, options)
-Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
-
-
################################################################
# build a C prototype file automatically
def AUTOPROTO(bld, header, source):
@@ -402,7 +398,8 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
cflags='',
group='main',
config_option=None,
- init_function_sentinal=None):
+ init_function_sentinal=None,
+ depends_on=''):
if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
return
@@ -422,12 +419,14 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
ilist = bld.SAMBA_LIBRARY_INCLUDE_LIST(deps) + bld.SUBDIR(bld.curdir, include_list)
ilist = bld.NORMPATH(ilist)
bld.SET_BUILD_GROUP(group)
- bld(
+ t = bld(
features = 'cc',
source = source,
target=modname,
ccflags = CURRENT_CFLAGS(bld, cflags),
- includes='. ' + bld.env['BUILD_DIRECTORY'] + '/default ' + ilist)
+ includes='. ' + bld.env['BUILD_DIRECTORY'] + '/default ' + ilist,
+ depends_on=depends_on)
+ return t
Build.BuildContext.SAMBA_SUBSYSTEM = SAMBA_SUBSYSTEM