Jonathan A. Sternberg 64c5139ab6
hack: generate vtproto files for buildx
Integrates vtproto into buildx. The generated files dockerfile has been
modified to copy the buildkit equivalent file to ensure files are laid
out in the appropriate way for imports.

An import has also been included to change the grpc codec to the version
in buildkit that supports vtproto. This will allow buildx to utilize the
speed and memory improvements from that.

Also updates the gc control options for prune.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-08 13:35:06 -05:00

42 lines
1.4 KiB
Go

package main
import (
"flag"
"strings"
_ "github.com/planetscale/vtprotobuf/features/clone"
_ "github.com/planetscale/vtprotobuf/features/equal"
_ "github.com/planetscale/vtprotobuf/features/grpc"
_ "github.com/planetscale/vtprotobuf/features/marshal"
_ "github.com/planetscale/vtprotobuf/features/pool"
_ "github.com/planetscale/vtprotobuf/features/size"
_ "github.com/planetscale/vtprotobuf/features/unmarshal"
"github.com/planetscale/vtprotobuf/generator"
"google.golang.org/protobuf/compiler/protogen"
)
func main() {
var cfg generator.Config
var features string
var f flag.FlagSet
f.BoolVar(&cfg.AllowEmpty, "allow-empty", false, "allow generation of empty files")
cfg.Poolable = generator.NewObjectSet()
cfg.PoolableExclude = generator.NewObjectSet()
f.Var(&cfg.Poolable, "pool", "use memory pooling for this object")
f.Var(&cfg.PoolableExclude, "pool-exclude", "do not use memory pooling for this object")
f.BoolVar(&cfg.Wrap, "wrap", false, "generate wrapper types")
f.StringVar(&features, "features", "all", "list of features to generate (separated by '+')")
f.StringVar(&cfg.BuildTag, "buildTag", "", "the go:build tag to set on generated files")
protogen.Options{ParamFunc: f.Set}.Run(func(plugin *protogen.Plugin) error {
gen, err := generator.NewGenerator(plugin, strings.Split(features, "+"), &cfg)
if err != nil {
return err
}
gen.Generate()
return nil
})
}