Integrating Nunavut with a Makefile based build process

I’m working on integrating nnvg from Nunavut into our build process, which is based on Makefile. The files generated by nnvg include a disclaimer about version control, suggesting they should be generated as part of the build process:

// Checking this file under version control is not recommended unless it is used as part of a high-SIL
// safety-critical codebase. The typical usage scenario is to generate it as part of the build process.

I’m looking for examples or recommendations on creating Makefile rules that trigger nnvg only when changes occur in either the source or the lookup DSDL files. While I’ve discovered the --list-outputs and --list-inputs options in nnvg, integrating their outputs into the Makefile-based build process isn’t straightforward.

Here are the development steps I aim to achieve:
0. Install nunavut.

  1. Clone the project and its subprojects without the committed DSDL-generated code.
  2. Execute make:
    • The build process should detect the absence of DSDL-generated code and generate it from the configured DSDL directories before compiling the project code.
  3. Make changes in the project code without modifying DSDL files.
  4. Execute make again:
    • The build process should recognize that the DSDL-generated code exists and hasn’t changed, hence doing nothing before compiling the project code.
  5. Make changes in the project code that affect DSDL files.
  6. Execute make once more:
    • The build process should detect changes in the DSDL files and either regenerate the modified files optimally or regenerate all the code before compiling the project code.

Any guidance or examples on setting up these Makefile rules with the appropriate nnvg options would be greatly appreciated.

If you remove points 5 and 6 then a simple make build target for the nnvg output directory will do the trick. This is trivial and does not require the use of --list-outputs et al. Here’s one way to do it:

	wget -q
	unzip -n > /dev/null
	rm -f*

public_regulated_data_types: public_regulated_data_types-master
	mkdir -p public_regulated_data_types
	mv -v public_regulated_data_types-master/** public_regulated_data_types/
	rm -rf public_regulated_data_types-master

generated/nunavut_out: public_regulated_data_types
	nnvg public_regulated_data_types/reg    -eh -O generated/nunavut_out -I public_regulated_data_types/uavcan
	nnvg public_regulated_data_types/uavcan -eh -O generated/nunavut_out

Recompiling on changes to DSDL files is a neat feature but is usually not a critical one because DSDL files are not modified often.

1 Like