brettviren / moo

ruminants on module oriented programming
GNU General Public License v3.0
4 stars 4 forks source link

moo render-deps not listing all dependencies #30

Closed jcfreeman2 closed 3 years ago

jcfreeman2 commented 3 years ago

One thing I'm noticing is that when moo render-deps gets called within daq-cmake 's moo_render function to make a list of dependencies for a generated header in a *.d file, not all the dependencies are listed. We can look at such a file by setting up a work area and building opmonlib and appfwk (where appfwk uses a template file opmonlib provides):

source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh
setup_dbt dunedaq-v2.6.0 
dbt-create.sh dunedaq-v2.6.0 daqbuild_template_dependency_check
cd daqbuild_template_dependency_check
dbt-workarea-env
cd sourcecode/
git clone https://github.com/DUNE-DAQ/opmonlib -b dunedaq-v2.6.0
git clone https://github.com/DUNE-DAQ/appfwk -b dunedaq-v2.6.0
cd ..
dbt-build.sh --install

The resulting build/appfwk/codegen/include/appfwk/queueinfo/InfoStructs.hpp.d looks like the following (I've inserted newlines for ease-of-reading):

appfwk/codegen/include/appfwk/queueinfo/InfoStructs.hpp: 
/home/jcfree/daqbuild_template_dependency_check/dbt-pyvenv/lib/python3.8/site-packages/moo/templates/ocpp.hpp.j2 
/home/jcfree/daqbuild_template_dependency_check/sourcecode/opmonlib/schema/opmonlib/info_hpp_macros.j2 
/home/jcfree/daqbuild_template_dependency_check/dbt-pyvenv/lib/python3.8/site-packages/moo/jsonnet-code/oschema.jsonnet

It makes sense that info_hpp_macros.j2 is listed, but I'd also have expected the InfoStructs.hpp.j2 which imports it to have been included.

You can also replicate this by directly running moo, of course:

# Assume you begin at the base of your work area, <your work area>
cd build
moo -T<your work area>/sourcecode/appfwk/schema -T<your work area>/sourcecode/opmonlib/schema -M<your work area>/sourcecode/appfwk/schema -M<your work area>/sourcecode/opmonlib/schema -g /lang:ocpp.jsonnet -A path=dunedaq.appfwk.appinfo -A ctxpath=dunedaq -A os=appfwk/appinfo.jsonnet render-deps -t appfwk/codegen/include/appfwk/appinfo/InfoStructs.hpp omodel.jsonnet opmonlib/InfoStructs.hpp.j2
brettviren commented 3 years ago

Thanks @jcfreeman2. The fix also adds the model file to the dependency list. But, I'm not sure if this is good or bad as in this particular example, the model is provided by moo itself and not by the project source. As long as render-deps and eventual render is all with the same moo I think there will not be any weirdness.

jcfreeman2 commented 3 years ago

Thanks for the speedy resolution @brettviren. Adding the model file to the dependency list strikes me as the right call.