Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nunavut 4.0 proposal #341

Open
thirtytwobits opened this issue Jul 25, 2024 · 0 comments
Open

Nunavut 4.0 proposal #341

thirtytwobits opened this issue Jul 25, 2024 · 0 comments
Labels
feature New feature or request
Milestone

Comments

@thirtytwobits
Copy link
Member

thirtytwobits commented Jul 25, 2024

Nunavut was never designed as a library. It started as a CLI, separate from libcanard, to integrate with makefiles and later cmake. It grew organically from its origin as a quick-and-dirty wrapper around jinja and the internals have gone through torturous evolutions as new languages were added and features requested. With 3.0 nunavut will start acting more like gcc in handling lists of files instead of directories and in managing dependencies between dsdl files. To get there it took on more debt supporting an incompatible "legacy" mode that is no longer aligned with the newer CLI or generate_all helper function.

This issue is a proposal for significant changes to the library's internals with Nunavut 4.0 to make it more usable as a python library as well as a CLI. To do this 4.0 will remove all deprecated paths in the core and will refactor the various generator types to be the primary API instead of the generate_all function, with it's burdening argument list. By moving to a builder pattern for a single generator object (instead of separate support and code generators) the CLI will use the same pattern and code to construct objects as any direct consumer. For example:

# CLI
NewGeneratorBuilder(**args).create().generate_all()

# API
NewGeneratorBuilder()
    .set_target_files(dsdl_files)
    .set_output_folder(outdir)
    .set_target_language('c')
    .create()
    .generate_all()

Simplification - De-creeping features

If this proposal is agreed upon then the following features will be marked as deprecated in 3.0 and removed in 4.0 in order to simplify Nunavut.

Non-Jinja file processing

All post processing features will be removed where users will be encouraged to use a more unix-like model of pipelining nnvg outputs through other utilities instead of asking nnvg to do it for them. Specifically the following CLI options will be removed:

  1. --trim-blocks
  2. --lstrip-blocks
  3. --pp-max-emptylines
  4. --pp-trim-trailing-whitespace
  5. --pp-run-program
  6. --pp-run-program-arg

To this end, the "listing" options like --list-outputs may be modified slightly to support shell pipelines like nnvg --list-outputs | xargs awk 'awk stuff blarg'

Un-targeted code generation

Un-targeted generation support (i.e. no target language specified) will be removed as this was never used and introduces a lot of additional edge cases that requires conditional checks and tests. While the ln global will remain, all templates will require a target_language to be set and not doing so will be an error checked as a precondition by generators.

@thirtytwobits thirtytwobits added this to the 4.0 milestone Jul 25, 2024
@thirtytwobits thirtytwobits added the feature New feature or request label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant