-
Notifications
You must be signed in to change notification settings - Fork 602
Description
This feature request is partly inspired by:
- toolkit: refactor all binary packages as library packages to enable building on top of the toolkit #2982
- Hypothetical new toolchain build flow #6788
Is your feature request related to a problem? Please describe.
Our build logic exists both in Makefiles and Go, making it somewhat hard to maintain/develop. Makefile is currently used to store default configs, prepare/compile source files, etc. The Go tools on the other hand are only used as separate utilities for each build (sub)step. We could use the Go tools a bit more since it makes organizing and error-handling easier. Moreover, I personally find Go code easier to understand than some Makefile magic.
Describe the solution you'd like
I have been looking at alternatives for the CLI parser kingpin and found kong, which is developed by the same author. This library allows us to structure subcommands, flags using Go types and annotations. Config files of multiple formats are also supported so we can have dedicated files to store defaults config and ideally skip having to specify the command line flags whenever we run any build command. We can even have multiple default config files to use for each different build environment, e.g on a local dev machine vs on official build servers.
I have a demo PR where I refactor 2 of the Go tools, bldtracker and depsearch into 2 packages, and invoke them through a single CLI, as opposed to having 2 standalone programs:
A sample config file is also included. This structure allows for both common and individual configs. With more refactor work like #6981, I can see how this library and structure will become useful.