Header file name collisions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Header file name collisions

Barnes, Peter D.
Hello Folks,

We’re encountering header file name collisions between a private contrib module and the main ns-3 distribution.

Waf just dumps all the headers in the build directory 'build/debug/ns3/' (or similar).  Is there any way to get it to put some headers in a sub-directory, such as ‘build/debug/ns3/foo/‘ ?

Yes, we could change our file names and refactor all our includes, but that would be extremely onerous, and doesn’t scale when mixing contrib modules from different sources.

Thanks,
Peter
_____________________________________________________________
Dr. Peter D. Barnes, Jr. CASC Division, B451 R2035
Lawrence Livermore National Laboratory Computation Directorate
7000 East Avenue, L-561 email:  [hidden email]<mailto:[hidden email]>
P. O. Box 808 Voice:  (925) 422-3384
Livermore, California 94550



Reply | Threaded
Open this post in threaded view
|

Re: Header file name collisions

Alex Afanasyev-2
Hi Peter,

I actually had similar issue (though on a slightly different level) in my module.  What I end up doing is creating extra feature to custom install headers added as ".full_headers" to the module:

def build(bld):
    module = bld.create_ns3_module('module', deps)
    module_dirs = ['apps', 'helper', 'model', 'utils', 'bindings']
    module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs])

@TaskGen.feature('ns3fullmoduleheaders')
@TaskGen.after_method('process_rule')
def apply_ns3fullmoduleheaders(self):
    # ## get all of the ns3 headers
    ns3_dir_node = self.bld.path.find_or_declare("ns3")

    mode = getattr(self, "mode", "install")

    for src_node in set(self.full_headers):
        dst_node = ns3_dir_node.find_or_declare(src_node.path_from(self.bld.path.find_dir('src')))
        assert dst_node is not None

        relpath = src_node.parent.path_from(self.bld.path.find_dir('src'))

        task = self.create_task('ns3header')
        task.mode = getattr(self, 'mode', 'install')
        if task.mode == 'install':
            self.bld.install_files('${INCLUDEDIR}/%s%s/ns3/%s' % (wutils.APPNAME, wutils.VERSION, relpath),
                                   [src_node])
            task.set_inputs([src_node])
            task.set_outputs([dst_node])
        else:
            task.header_to_remove = dst_node


This will install headers with relative paths inside build/ns3 folder (e.g., build/ns3/module/helper/foobar.hpp).

--
Alex

> On May 27, 2020, at 4:37 PM, Barnes, Peter D. <[hidden email]> wrote:
>
> Hello Folks,
>
> We’re encountering header file name collisions between a private contrib module and the main ns-3 distribution.
>
> Waf just dumps all the headers in the build directory 'build/debug/ns3/' (or similar).  Is there any way to get it to put some headers in a sub-directory, such as ‘build/debug/ns3/foo/‘ ?
>
> Yes, we could change our file names and refactor all our includes, but that would be extremely onerous, and doesn’t scale when mixing contrib modules from different sources.
>
> Thanks,
> Peter