|
|
@ -13,19 +13,13 @@ import ( |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: GoGet
|
|
|
|
|
|
|
|
// TODO: Build
|
|
|
|
|
|
|
|
// TODO: Clean
|
|
|
|
|
|
|
|
|
|
|
|
func InstallZapMarshaler(ctx context.Context) error { |
|
|
|
type Protobuf mg.Namespace |
|
|
|
alreadyDone, err := build.HasExecutableInBuildtools("protoc-gen-zap-marshaler") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if alreadyDone { |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return build.InstallGoExecutable(ctx, "github.com/kazegusuri/go-proto-zap-marshaler/protoc-gen-zap-marshaler@latest") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func InstallGoProtoc(ctx context.Context) error { |
|
|
|
func (Protobuf) InstallGoPlugin(ctx context.Context) error { |
|
|
|
alreadyDone, err := build.HasExecutableInBuildtools("protoc-gen-go") |
|
|
|
alreadyDone, err := build.HasExecutableInBuildtools("protoc-gen-go") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -36,21 +30,22 @@ func InstallGoProtoc(ctx context.Context) error { |
|
|
|
return build.InstallGoExecutable(ctx, "google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1") |
|
|
|
return build.InstallGoExecutable(ctx, "google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func InstallProtoDeps(ctx context.Context) { |
|
|
|
func (Protobuf) InstallPlugins(ctx context.Context) { |
|
|
|
mg.CtxDeps(ctx, InstallZapMarshaler, InstallGoProtoc) |
|
|
|
mg.CtxDeps(ctx, Protobuf.InstallGoPlugin) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Protobuf mg.Namespace |
|
|
|
func (Protobuf) Build(ctx context.Context) error { |
|
|
|
|
|
|
|
mg.CtxDeps(ctx, Protobuf.Clean, Protobuf.InstallPlugins) |
|
|
|
func (Protobuf) BuildProtocolBuffers(ctx context.Context) error { |
|
|
|
|
|
|
|
mg.CtxDeps(ctx, InstallProtoDeps) |
|
|
|
|
|
|
|
tooldir, err := build.GetBuildToolsDir() |
|
|
|
tooldir, err := build.GetBuildToolsDir() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
pluginPathFlag := fmt.Sprintf("--plugin=%s", path.Join(tooldir, "protoc-gen-go")) |
|
|
|
goPluginPathFlag := fmt.Sprintf("--plugin=%s", path.Join(tooldir, "protoc-gen-go")) |
|
|
|
cmd := exec.CommandContext(ctx, "protoc", pluginPathFlag, "-I=proto", "--go_out=.", "--go_opt=module=git.reya.zone/reya/hexmap", "proto/action.proto", "proto/client.proto", "proto/coords.proto", "proto/map.proto", "proto/server.proto", "proto/user.proto") |
|
|
|
cmd := exec.CommandContext(ctx, "protoc", goPluginPathFlag, "-I=proto", "--go_out=.", "--go_opt=module=git.reya.zone/reya/hexmap", "proto/action.proto", "proto/client.proto", "proto/coords.proto", "proto/map.proto", "proto/server.proto", "proto/user.proto") |
|
|
|
cmd.Stderr = os.Stderr |
|
|
|
cmd.Stderr = os.Stderr |
|
|
|
|
|
|
|
if mg.Verbose() { |
|
|
|
|
|
|
|
cmd.Stdout = os.Stdout |
|
|
|
|
|
|
|
} |
|
|
|
return cmd.Run() |
|
|
|
return cmd.Run() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -73,4 +68,4 @@ func (Protobuf) Clean(ctx context.Context) error { |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|