Is there a way to find out module dependancies?

I’m compiling yang module in a makefile and I wish to know what are the submodules this module depends.

My makefile rule is:
`%.fxs: %.yang
confdc …

module a: depends on module b.
I want this module_a.fxs file to be compiled again if module_b.yang is changed.

Is there a way to do that, that is not manual?

I saw an option of confdc which is: --check-deps but I don’t think it’s what I look for…

Thanks

You can use the standard makefile feature by adding the following line to indicate this dependency in your Makefile:

module_a.fxs:<tab>module_b.yang

By adding the above line, you are telling makefile that each time module_b.yang is modified, module_a.fxs needs to be rebuilt.

I know that; I’m asking if there’s something automatic:

If I have:
module_a.yang:

module module_a {

include module_b
include module_c
}

module_b.yang:

submodule module_b {

belongs-to module_a...
}

module_c.yang:

submodule module_c {

belongs-to module_a...
}

Can I do some command with confdc, such as:
confdc --emit-deps module_a.yang
which will output:
module_b.yang module_c.yang

So I won’t have to write manually:

module_a.fxs: module_a.yang module_b.yang module_c.yang

and I could use:

%.fxs: %.yang $(depends)

When $(depends) is the output of something such as confdc --emit-deps
I hope I was clear,
Thanks

You can use the Depend output specific options of pyang to automatically generate the dependencies. An example usage of pyang to generate the dependency of your use case is as follows:

 pyang -f depend --depend-target module_a.fxs --depend-extension .yang module_a.yang

Refer to the man page of pyang for more details of its usage.

1 Like

Here’s a snippet from a GNU Makefile implementing a generic form of the method described by Wai ($(YANG_MODULES) is expected to be a list of YANG module (not submodule) file names, without the .yang extension):

#
# Dependencies for YANG modules
#
YANG_DEPS = $(YANG_MODULES:%=.%.yang.d)

.%.yang.d: %.yang
        $(PYANG) -f depend --depend-include-path --depend-target=$*.fxs --depend-extension=.yang $< > $@


ifneq ($(MAKECMDGOALS),clean)
-include $(YANG_DEPS)
endif
1 Like