[U-Boot] [RFC] Proposal to change include search model

Vasili Galka vvv444 at gmail.com
Tue Jun 10 17:53:23 CEST 2014


Hi,

Currently U-Boot has a long list of include search paths. This makes
it hard to understand the location of each header. Moreover, it opens
an easy opportunity for breaking build by including the wrong header.
This is especially easy when compiling the tools directory. I found
numerous commits dealing with such problems over the years.

What I propose is changing the way of how #include directives are
written. For example instead of:

#include <stdlib.h>             /* From toolchain */
#include <api_public.h>         /* include/api_public.h */
#include <linux/mii.h>          /* include/linux/mii.h */
#include <config.h>             /* Auto-generated somewhere */
#include <bmp_logo.h>           /* Auto-generated somewhere */
#include <asm/arcregs.h>        /* arch/arc/include/asm/arcregs.h */
#include <asm/arch/emac_defs.h> /* arch/arm/include/asm/
                                     arch-davinci/emac_defs.h */
#include "../../../../../drivers/net/davinci_emac.h"

and let the developer guess the locations... I propose writing:

#include <stdlib.h>             /* <> means from toolchain */
#include "inc/api_public.h"     /* From u-boot/include/ dir */
#include "inc/linux/mii.h"
#include "config/config.h"      /* From dedicated config dir */
#include "generated/bmp_logo.h"
#include "arch/asm/arcregs.h"   /* From configured architecture */
#include "soc/emac_defs.h"      /* From configured SoC */
#include "u-boot/drivers/net/davinci_emac.h"

This way the developer will instantly know the exact header locations.
Moreover, the chance for ambiguities is very small which makes build
breakages less likely.

The proposal may seem strange to you at first, as most of you are
probably used to a different approach. But please consider its
advantages. I've been working on projects that used similar scheme
and it significantly simplifies the developer life.

The above can be implemented by creating
inc/ arch/ soc/ u-boot/
filesystem links in ${objtree}/include. Then, the only compiler flag
required will be "-iquote ${objtree}/include". No ugly -idirafter flags,
no long search list. Keep it simple.

I'll be glad for your opinions!

P.S. I've already mentioned this proposal when discussing Cygwin/FreeBSD
build breakages. But it deserves a separate thread.

Best,
Vasili


More information about the U-Boot mailing list