How to require the other component in .cdef?

Hi all,

I recently had a problem regarding requiring component in .cdef file. According to the reference guide, in requires: section, subsection component: can be included. But when I tried, directly writing the component’s name leads to a build error saying “Couldn’t find component xxxx”, even though the desired component is in the same app folder.

How can I do this properly?

Hi @lichen,

So the structure was something like:

Component.cdef
toto/Component.cdef

with the first Component.cdef with something like:

requires:
{
    component:
    {
        toto
    }
}

Would that be correct?
Could you post the build logs?
Also which version of Legato are you building with?

Okay…I see that you mean the component toto that will be required has to be inside the folder of the component that requires toto. Am I right?

If so, I do have a mistake here. But I don’t see the necessity of requiring another component in this way. Why don’t not just put all the source files in toto in the outer component folder and do a little bit modification on the .cdef?

Besides, the thing that triggered my interest on requiring another component is when I try to include the mangoh gpio expander service from GPIO expander into default.sdef, after I mksys, an error occurs saying

/home/lichen/mangOH/apps/GpioExpander/gpioExpanderService/gpioExpanderGreen/Component.cdef:21:8: error: Couldn’t find component ‘gpioExpanderCommon’.

The component ‘gpioExpanderCommon’ is required in this .cdef file GpioExpanderGreen, while gpioExpanderCommon itself is located outside component GpioExpanderGreen in GpioExpanderService. Is this a bug or is there anything that I did wrong?

The legato version is 16.10.3 by the way.

Hi @lichen

Xdef files doesn’t provide a way to set an alternative “source” path (for where to find apps, components…)
This needs to be set on the command-line.
Please check the mangOH makefile: https://github.com/mangOH/mangOH/blob/master/Makefile

They’re using a -s $(MANGOH_ROOT)/apps/GpioExpander/gpioExpanderService option to help finding the component you’re looking for.