[PATCH] s3:modules: Fix compilation of nfs41acl_xdr.c when building outside src

Alexander Bokovoy ab at samba.org
Thu Feb 7 12:07:31 UTC 2019


On ke, 06 helmi 2019, Karaliou, Aliaksei via samba-technical wrote:
> Hi,
> 
> Please review (and even maybe accept) this change for a build script.
> This change deals with non-common case with Samba build which I want
> to make real - allow build directory to be outside Samba tree at all
> (with other required of course).
> 
> Patch itself and approach looks like a hack, but there is a valid
> reason for that.  If reviewer/community does not like the way how it
> was done, I'm open for suggestions.
> 
> This was the only way it worked for me. Probably I've missed something, but:
>     * I don't know how to at least make this as 2 stages (copy and
> then rpcgen so that ${SRC} appears to be good relative path from
> 'bin/default') - cannot make an order them and tell waf that
> inexistent nfs41acl.x-copy is ok.
>     * I was not able to utilize WAF variables in other way because
>     they either return full path or cannot compile because in
>     expression like ${SRC.method(SRC.value)} or similar WAF cannot
>     perform substitution inside method() params.
> 
> Other approaches are also failed for me for for such a reason that WAF
> scans directories when builds Nodes and even if first run passes, then
> it finds copied files instead of original ones (if names are similar)
> and so on.

We do something similar in ctdb/wscript as well. Not exactly that as we
have placed the header along the actuall code there inside ctdb but
nevertheless is close to it.

It looks OK for me but I'd really like to see it run through the gitlab
CI runners.

> 
> Best regards,
>   Aliaksei

> From b5393b031d24635318a6847071a364135453e13b Mon Sep 17 00:00:00 2001
> From: Aliaksei Karaliou <akaraliou at panasas.com>
> Date: Mon, 28 Jan 2019 03:17:07 -0500
> Subject: [PATCH] s3:modules: Fix compilation of nfs41acl_xdr.c when building
>  outside src
> 
> If the Samba build directory is outside its source directory, generation
> of nfs41acl_xdr.c by rpcgen leads to improper include paths to nfs41acl.h.
> 
> This happens because rpcgen is designed to produce its generated file in the
> same directory as the input template. If the build directory is not located
> under the source directory, this relative path will be invalid and the header
> will not be found.
> 
> Example:
>  src dir is ~/samba-src
>  bld dir is ~/samba-bld
> 
> rpcgen will use path ../../samba-src/source3/modules/nfs41acl.x
> running from ~/samba-bld/default and nfs41acl_xdr.c will contain:
>  #include "../../samba-src/source3/modules/nfs41acl.h"
> 
> This behaviour is fixed through an intermediate copy of the input file to
> the build directory so that rpcgen receives the path as if located in src.
> 
> Also now we avoid generation of nfs41acl_xdr.c when HAVE_RPC_XDR_H is
> not defined because it will not be used as part of the vfs_nfs4acl_xattr
> module.
> 
> Signed-off-by: Aliaksei Karaliou <akaraliou at panasas.com>
> ---
>  source3/modules/wscript_build | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
> index c666aa0..30347e0 100644
> --- a/source3/modules/wscript_build
> +++ b/source3/modules/wscript_build
> @@ -242,13 +242,6 @@ bld.SAMBA3_MODULE('vfs_zfsacl',
>                   internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_zfsacl'),
>                   enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_zfsacl'))
>  
> -xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
> -
> -bld.SAMBA_GENERATOR('nfs41acl-xdr-c',
> -                    source='nfs41acl.x',
> -                    target='nfs41acl_xdr.c',
> -                    rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
> -
>  bld.SAMBA_GENERATOR('nfs41acl-h',
>                      source='nfs41acl.x',
>                      target='nfs41acl.h',
> @@ -261,6 +254,23 @@ vfs_nfs4acl_xattr_source = '''
>                             '''
>  
>  if bld.CONFIG_SET("HAVE_RPC_XDR_H"):
> +    xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
> +
> +    # By default rpcgen assumes that the input file, generated header and
> +    # source file are located in the same directory, which is extracted from
> +    # the provided path to the input file.
> +    # However if the build directory is not under the source tree, ${SRC} will
> +    # be a long relative path through a common parent directory, resulting
> +    # in an invalid path used in #include for the header.
> +    # In order to fix that, the input file is first copied to the output build
> +    # directory and then rpcgen is called with the proper path.
> +    bld.SAMBA_GENERATOR('nfs41acl-xdr-c',
> +                        source='nfs41acl.x',
> +                        target='nfs41acl_xdr.c',
> +                        rule='cp -f ${SRC} ${TGT[0].parent} && rpcgen -c ' \
> +                             '${TGT[0].path_from(tsk.get_cwd())[:-len(tsk.outputs[0].name)] + tsk.inputs[0].name} | ' + \
> +                             xdr_buf_hack + ' > ${TGT}')
> +
>      vfs_nfs4acl_xattr_source += ' nfs41acl_xdr.c'
>  
>  bld.SAMBA3_MODULE('vfs_nfs4acl_xattr',
> -- 
> 1.8.3.1
> 


-- 
/ Alexander Bokovoy



More information about the samba-technical mailing list