Nunavut Python Library to use SupportGenerator

I am trying to use nunavut python library to generate support includes as I do from command line like:
nnvg --target-language c -O include --target-endianness little --generate-support only"

I am trying code like this but it do not generate any code:

from pydsdl import read_namespace
from nunavut import build_namespace_tree
from nunavut.lang import LanguageContext
from nunavut.jinja import DSDLCodeGenerator, SupportGenerator
from pathlib import Path

root_namespace_dir_uavcan =  "data_types/uavcan"
root_namespace_dir_reg = "data_types/reg"
out_dir = "include"

lookup_directories = [root_namespace_dir_uavcan,root_namespace_dir_reg]

# parse the dsdl
compound_types = read_namespace(root_namespace_dir_reg, lookup_directories)

# select a target language
language_context = LanguageContext('c')

# build the namespace tree
root_namespace = build_namespace_tree(compound_types,
                                      root_namespace_dir_reg,
                                      out_dir,
                                      language_context)

root_namespace.base_output_path = "include"
print(root_namespace.get_support_output_folder())
support_generator = SupportGenerator(root_namespace)
print(support_generator.get_templates())
support_generator.generate_all()

Thanks for any suggestion

Let me take a look…

Sorry for the delay. There is a helper in nunavut/__init__.py that isn’t often used that will do all this for you:

from nunavut import generate_types

generate_types("cpp", "submodules/public_regulated_data_types/uavcan", "fooout", omit_serialization_support=False)

That said, this doesn’t allows to to specify “support only.” If I created a new version of this helper that was for support-only generation would you want to use that?

Otherwise just look at the implementation of the generate_types method and note that c does not have any support files unless you enable serialization (omit_serialization_support=False, It’s odd that I made the default True. That also is something I should fix).

This code:

from nunavut import generate_types

generate_types("c", "data_types/uavcan", "include", omit_serialization_support=False)
generate_types("c", "data_types/reg", "include", omit_serialization_support=False, lookup_directories=["data_types/uavcan",])

make what I need.

Thaks a lot!