libbsd: How to add an option for switching off IPv6 (or other BSD Kernel configurations)

Christian Mauderer christian.mauderer at embedded-brains.de
Tue Aug 2 10:05:16 UTC 2016


Am 02.08.2016 um 08:57 schrieb Christian Mauderer:
> Am 02.08.2016 um 04:09 schrieb Chris Johns:
>> On 02/08/2016 00:04, Christian Mauderer wrote:
[...]
> 
>>> Are there any better ideas how to implement such an option?
>>
>> There are 2 parts that need be to changed to make this work. This
>> assumes you will need to control the source being built.
>>
>> The first is the module descriptions in libbsd.py and then the
>> generator. I suggest you look at the various module class methods used
>> to add source and consider adding a 'section' argument which defaults to
>> 'default' (always True). This would lets you move code into specific
>> sections, for example:
>>
>>     dhcpcd_defines='-D__FreeBSD__ -DTHERE_IS_NO_FORK ...'
>>     mod.addSourceFiles(
>>         [
>>             'dhcpcd/ipv6.c',
>>             'dhcpcd/ipv6nd.c',
>>         ],
>>         mm.generator['source'](dhcpcd_defines),
>>         section = 'networking.ipv6_yes'
>>     )
>>
>> Note, this definition generates something that is evaluated when waf
>> runs so the 'section' populates a dict where the 'networking.ipv6_yes'
>> key is tested for True or False depending what the user specifies.
>>
>> You could also change the class constructor so you have:
>>
>>  mod = builder.Module('dhcpcd', section = 'networking.dhcp')
>>
>> The dot notation would allow control of the sources at the module level
>> to finally get sorted out. The dhcpcd module becomes 'networking.dhcpcd'
>> which means build if networking and dhcpcd are True. You could work down
>> the dots checking at each point to make sure the module can be built.
>> Currently module level user control has been left hanging with commented
>> modules, eg '#mm.addModule(dev_usb_controller_add_on(mm)'. If the
>> section 'usb.dev_usb_controller_add_on' is False by default that module
>> is not built which is what we have now.
>>
>> The second part is in the waf script (wscript) which handles the user
>> interface, ie parses
>> --config="networking:ipv6=no,pink-frames-only,chrismac-buf-frames=64". I
>> would add this code in a new Python module libbsd_opts.py and imported
>> into libbsd_waf.py (generated) and called in the 'options' function in
>> libbsd_waf.py. This would parse and populate a dict the generated module
>> code uses.
>>
> 
> Thanks for the detailed description. I'll need some time to understand
> everything but it looks like a good starting point.
> 
[...]
> 

Hello Chris,

I think I managed to understand most of it even if I still only have a
rough Idea where to start.

If I'm right, you suggested two alternative possible methods:

1) Add the section-option as parameter to a addSourceFiles. This means
it is only valid for some sources in a module.

2) Alternatively add it directly to the module.

Did I understand you correct. Or did you mean that the section is added
to both - the module and the source?


As far as I understand the first method, this could be also used for the
define that depends on the option. Something like this:

    def dhcpcd(mm):
        mod = builder.Module('dhcpcd')
        dhcpcd_sources =
            [
                'dhcpcd/arp.c',
                'dhcpcd/auth.c',
                ...
            ]
        dhcpcd_defines_base = '-D__FreeBSD__ -DTHERE_IS_NO_FORK ...'
        dhcpcd_defines_inet6 = dhcpcd_defines_base + ' -DINET6'
        mod.addSourceFiles(
            dhcpcd_sources,
            mm.generator['source'](dhcpcd_defines_base),
            section = 'networking.ipv6_no'
        )
        mod.addSourceFiles(
            dhcpcd_sources,
            mm.generator['source'](dhcpcd_defines_inet6),
            section = 'networking.ipv6_yes'
        )
        return mod

I'm not sure how this would be possible with the second method.

Kind regards,

Christian
-- 
--------------------------------------------
embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.mauderer at embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list