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

Enhancements for binapigen #93

Merged
merged 19 commits into from
Mar 2, 2023
Merged

Enhancements for binapigen #93

merged 19 commits into from
Mar 2, 2023

Conversation

ondrej-fabry
Copy link
Member

@ondrej-fabry ondrej-fabry commented Dec 8, 2022

This PR contains enhancements for the binapi-generator and binapigen package. The aim was to finish the implementation of generator plugins and allow adding custom plugins by users.

This change contains the following changes:

  • adds support for running external plugins in generator
    • external plugin is a binary (*.so) compiled from Go main package using go build -buildmode=plugin ...
    • this Go package must contain at least one exported function:
      • GenerateFile(g *binapigen.Generator, f *binapigen.File) *binapigen.GenFile (runs once for each file)
      • GenerateAll(g *binapigen.Generator) []*binapigen.GenFile (runs only once for all)
    • the binapi-generator accepts path to an external plugin and loads its symbol (via plugin package)
  • adds universal input reference URI to the generator, resolving the VPP input parameters depending on the format
    • supporte formats are:
      • path to directory to VPP API files (e.g. /usr/share/vpp/api)
      • path to directory containing VPP repository (runs make json-api-files automatically)
      • (more formats will be added in the future..)
  • adds new helper functions and constructors to generated code for converting address types like Address, MacAddress, Prefix, .. into types from net package (IP, IPNet...)
  • minor cleanups/refactorings of code in binapigen package

This PR includes collective changes from Nathan's PRs: #67 #68

There is a discussion created for design and overall info for this feature: #94

- add support for loading external plugins (as pre-compiled library)

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
@ondrej-fabry ondrej-fabry self-assigned this Dec 8, 2022
@ondrej-fabry ondrej-fabry added this to the v0.8.0 milestone Dec 8, 2022
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
@ondrej-fabry ondrej-fabry added the wip [status] In Progress label Dec 8, 2022
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
@ondrej-fabry ondrej-fabry removed the wip [status] In Progress label Dec 15, 2022
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
- add helper methods and constructors for IP, MAC types
- regenerate binapi
- add more comments to code

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
binapigen/vppapi/util.go Outdated Show resolved Hide resolved
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Copy link
Contributor

@sknat sknat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the big refactoring !
I think the main thing to discuss is the plugin API
Otherwise lgtm 😄

binapigen/run.go Show resolved Hide resolved
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Makefile Show resolved Hide resolved
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
sknat
sknat previously approved these changes Mar 2, 2023
@sknat
Copy link
Contributor

sknat commented Mar 2, 2023

lgtm ! Thanks 😄

@ondrej-fabry ondrej-fabry merged commit 5ee4cc8 into master Mar 2, 2023
@ondrej-fabry ondrej-fabry deleted the binapigen branch March 2, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants