1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

build: much nicer pidl rules

This commit is contained in:
Andrew Tridgell 2010-03-17 21:48:26 +11:00
parent 6bba8cfd92
commit e916aff9e1
4 changed files with 77 additions and 78 deletions

View File

@ -4,89 +4,71 @@ from TaskGen import taskgen, before
import Build, os, string, Utils
from samba_utils import *
def SAMBA_PIDL(bld, pname, source, options=''):
def SAMBA_PIDL(bld, pname, source, options='', output_dir='.'):
'''Build a IDL file using pidl.
This will produce 7 output files'''
This will produce up to 13 output files depending on the options used'''
bname = source[0:-4];
name = "PIDL_%s" % bname.upper()
bname = source[0:-4]; # strip off the .idl suffix
name = "%s_%s" % (pname, bname.upper())
if not SET_TARGET_TYPE(bld, name, 'PIDL'):
return
bld.SET_BUILD_GROUP('build_source')
gen_ndr_dir = '../gen_ndr/'
# the output files depend on the options used. Use this dictionary
# to map between the options and the resulting file names
options_map = { '--header' : '%s.h',
'--ndr-parser' : 'ndr_%s.c ndr_%s.h',
'--samba3-ndr-server' : 'srv_%s.c srv_%s.h',
'--samba3-ndr-client' : 'cli_%s.c cli_%s.h',
'--server' : 'ndr_%s_s.c',
'--client' : 'ndr_%s_c.c ndr_%s_c.h',
'--python' : 'py_%s.c',
'--tdr-parser' : 'tdr_%s.c tdr_%s.h',
}
table_header_idx = None
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)
options_list = to_list(options)
for o in options_list:
if o in options_map:
ofiles = to_list(options_map[o])
for f in ofiles:
out_files.append(os.path.join(output_dir, f % bname))
if f == 'ndr_%s.h':
# 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)
t = bld(rule='${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${OUTPUTDIR} -- ${SRC[0].abspath(env)}',
# 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 = False,
source=source,
target = out_files,
name=name)
before = 'cc',
shell = True,
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)
t.env.PIDL = "../pidl/pidl"
t.env.OPTIONS = to_list(options)
t.env.OUTPUTDIR = 'bin/' + bld.BUILD_PATH(output_dir)
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])]
if 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)
Build.BuildContext.SAMBA_PIDL = SAMBA_PIDL
def SAMBA_PIDL_TDR(bld, pname, source, options=''):
'''Build a IDL file using pidl.
This will only produce the header and tdr parser'''
bname = source[0:-4];
name = "PIDL_%s" % bname.upper()
if not SET_TARGET_TYPE(bld, name, 'PIDL'):
return
bld.SET_BUILD_GROUP('build_source')
out_files = []
out_files.append('tdr_%s.c' % bname)
out_files.append('tdr_%s.h' % bname)
pidl = bld.srcnode.find_resource('pidl/pidl').relpath_gen(bld.path)
t = bld(rule='${PIDL} ${PIDL_BUILD_TYPES} ${OPTIONS} --outputdir ${TGT[0].parent.abspath(env)} -- ${SRC[0].abspath(env)}',
ext_out = '.c',
before = 'cc',
shell = True,
source=source,
target = out_files,
name=name)
t.env.PIDL = "../../pidl/pidl"
t.env.PIDL_BUILD_TYPES = '--header --tdr-parser'
t.env.OPTIONS = options
Build.BuildContext.SAMBA_PIDL_TDR = SAMBA_PIDL_TDR
#################################################################
# define a set of Samba PIDL targets
def SAMBA_PIDL_LIST(bld, name, source,options=''):
def SAMBA_PIDL_LIST(bld, name, source, options='', output_dir='.'):
'''A wrapper for building a set of IDL files'''
for p in to_list(source):
bld.SAMBA_PIDL(name, p, options)
bld.SAMBA_PIDL(name, p, options=options, output_dir=output_dir)
Build.BuildContext.SAMBA_PIDL_LIST = SAMBA_PIDL_LIST
@ -96,28 +78,26 @@ from TaskGen import feature, before
@feature('collect')
@before('exec_rule')
def collect(self):
for (name, hd) in self.bld.PIDL_STUFF.items():
pidl_headers = LOCAL_CACHE(self.bld, 'PIDL_HEADERS')
for (name, hd) in pidl_headers.items():
y = self.bld.name_to_obj(name, self.env)
if not y:
raise "!"+str(name)
self.bld.ASSERT(y is not None, 'Failed to find PIDL header %s' % 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)
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

12
librpc/idl/wscript_build Normal file
View File

@ -0,0 +1,12 @@
bld.SAMBA_PIDL_LIST('PIDL_COMMON',
'''atsvc.idl dcom.idl drsuapi.idl epmapper.idl initshutdown.idl
misc.idl ntlmssp.idl protected_storage.idl schannel.idl trkwks.idl
wmi.idl audiosrv.idl dfsblobs.idl dsbackup.idl eventlog.idl keysvc.idl
msgsvc.idl ntsvcs.idl remact.idl security.idl unixinfo.idl wzcsvc.idl
browser.idl dfs.idl dssetup.idl frsapi.idl krb5pac.idl
named_pipe_auth.idl orpc.idl rot.idl spoolss.idl w32time.idl xattr.idl
dbgidl.idl dnsserver.idl echo.idl frsrpc.idl lsa.idl nbt.idl
oxidresolver.idl samr.idl srvsvc.idl winreg.idl dcerpc.idl
drsblobs.idl efs.idl frstrans.idl mgmt.idl netlogon.idl
policyagent.idl scerpc.idl svcctl.idl wkssvc.idl''')

View File

@ -1,5 +1,6 @@
bld.SAMBA_PIDL_TDR('PIDL_REG',
source='regf.idl')
bld.SAMBA_PIDL('PIDL_REG',
source='regf.idl',
options='--header --tdr-parser')
bld.SAMBA_SUBSYSTEM('TDR_REGF',
source='tdr_regf.c',

View File

@ -0,0 +1,6 @@
bld.SAMBA_PIDL_LIST('PIDL_S4',
source='''irpc.idl nfs4acl.idl notify.idl ntp_signd.idl
opendb.idl sasl_helpers.idl server_id.idl winbind.idl
winsif.idl winsrepl.idl winstation.idl''',
options="--includedir=../../librpc/idl"
)