Expose golang fqbn package for public use by cmaglie · Pull Request #2768 · arduino/arduino-cli (original) (raw)
Please check if the PR fulfills these requirements
- The PR has no duplicates (please search among the Pull Requests
before creating one) - The PR follows
our contributing guidelines - Tests for the changes have been added (for bug fixes / features)
- Docs have been added / updated (for bug fixes / features)
UPGRADING.mdhas been updated with a migration guide (for breaking changes)configuration.schema.jsonupdated if new parameters are added.
What kind of change does this PR introduce?
This is a tentative design for exporting some of the internals of the Arduino CLI for reuse in other projects.
What is the current behavior?
The FQBN struct is not exported.
What is the new behavior?
The FQBN struct is exported through a public fqbn package.
Does this PR introduce a breaking change, and is titled accordingly?
Other information
Importing the newly created fqbn package as-is would cause a small dependency hell:
require (
github.com/arduino/go-paths-helper v1.12.1 // indirect
github.com/arduino/go-properties-orderedmap v1.8.1 // indirect
github.com/leonelquinteros/gotext v1.7.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/sys v0.27.0 // indirect
)
I also suspect that the Arduino CLI locales are bundled as part of the dependencies. To reduce this burden I've isolated the i18n.Tr function from the rest of the locales handling, and moved those latter functions to the locales package. I've also replaced the gotext.Po instance with an interface with only the Get method required for i18n to work properly.
If the translations are not used in the importing project, a thin wrapper is used instead of gotext.Po.
This change has reduced the dependencies to the minimum:
require (
github.com/arduino/go-paths-helper v1.12.1 // indirect
github.com/arduino/go-properties-orderedmap v1.8.1 // indirect
)
and also reduced the executable size by 300KB (that I suppose are the locales that are no longer bundled).