[PATCH 2/5] scripts: Add common library functions

Sascha Hauer s.hauer at pengutronix.de
Mon Oct 11 07:52:48 PDT 2021


On Mon, Oct 11, 2021 at 11:37:07PM +0900, Masahiro Yamada wrote:
> On Wed, Oct 6, 2021 at 11:26 PM Sascha Hauer <s.hauer at pengutronix.de> wrote:
> >
> > Several functions are duplicated in different host tools. This patch
> > starts collecting them in a single C file. We start with read_file()
> > and read_file_2(), others follow in separate commits.
> >
> > It would be great to compile these functions in a separate library, but
> > I don't know how this can be archieved in Kbuild. Instead, the C file
> > is included where needed. Not nice, not beautiful, but at least enough
> > to get something going.
> 
> 
> You can try this.
> 
> 
> hostprogs-always-$(CONFIG_IMD)   += bareboximd
> bareboximd-objs                                 := bareboximd.o common.o
> 
> 
> hostprogs-always-$(CONFIG_OMAP3_USB_LOADER) += omap3-usb-loader
> omap3-usb-loader-objs                       := omap3-usb-loader.o common.o

I did and it works well as long as common.o is used only in a single
directory. Unfortunately some tools are in subdirectories, like for
example scripts/imx/imx-usb-loader.c. Of course these could be moved up
one level, but I didn't want to go that path.
Do you see any possibility to archieve the same with files in different
directories?

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list