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>
This commit is contained in:
Jonathan A. Sternberg
2024-10-08 13:35:06 -05:00
parent d353f5f6ba
commit 64c5139ab6
109 changed files with 68070 additions and 2941 deletions

View File

@ -0,0 +1,41 @@
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
})
}