Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ brews:
name: "homebrew-tap"
install: |
bin.install "starport"

3 changes: 1 addition & 2 deletions scripts/gen-nodetime
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ npm run build
tar -czvf nodetime-linux-amd64.tar.gz nodetime-linux
tar -czvf nodetime-darwin-amd64.tar.gz nodetime-macos

mv nodetime-linux-amd64.tar.gz ../../../starport/pkg/nodetime/
mv nodetime-darwin-amd64.tar.gz ../../../starport/pkg/nodetime/
mv nodetime-*.tar.gz ../../../starport/pkg/nodetime/data

rm nodetime-linux nodetime-macos
rm -rf dist/
51 changes: 37 additions & 14 deletions starport/cmd/tools.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package starportcmd

import (
"context"
"os"

"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/pkg/cmdrunner"
"github.com/tendermint/starport/starport/pkg/cmdrunner/step"
"github.com/tendermint/starport/starport/pkg/nodetime"
"github.com/tendermint/starport/starport/pkg/protoc"
)

// NewTools returns a command where various tools (binaries) are attached as sub commands
Expand All @@ -18,28 +20,37 @@ func NewTools() *cobra.Command {
}
c.AddCommand(NewToolsIBCSetup())
c.AddCommand(NewToolsIBCRelayer())
c.AddCommand(NewToolsProtoc())
return c
}

func NewToolsIBCSetup() *cobra.Command {
c := &cobra.Command{
return &cobra.Command{
Use: "ibc-setup [--] [...]",
Short: "Collection of commands to quickly setup a relayer",
RunE: toolsNodetimeProxy(nodetime.CommandIBCSetup),
Example: `starport tools ibc-setup -- -h
starport relayer lowlevel ibc-setup -- init --src relayer_test_1 --dest relayer_test_2`,
starport tools ibc-setup -- init --src relayer_test_1 --dest relayer_test_2`,
}
return c
}

func NewToolsIBCRelayer() *cobra.Command {
c := &cobra.Command{
return &cobra.Command{
Use: "ibc-relayer [--] [...]",
Short: "Typescript implementation of an IBC relayer",
RunE: toolsNodetimeProxy(nodetime.CommandIBCRelayer),
Example: `starport tools ibc-relayer -- -h`,
}
return c
}

func NewToolsProtoc() *cobra.Command {
return &cobra.Command{
Use: "protoc [--] [...]",
Short: "Execute the protoc command",
Long: "The protoc command. You don't need to setup the global protoc include folder with -I, it's automatically handled",
RunE: toolsProtocProxy,
Example: `starport tools protoc -- --version`,
}
}

func toolsNodetimeProxy(c nodetime.CommandName) func(cmd *cobra.Command, args []string) error {
Expand All @@ -50,15 +61,27 @@ func toolsNodetimeProxy(c nodetime.CommandName) func(cmd *cobra.Command, args []
}
defer cleanup()

command = append(command, args...)
return toolsProxy(cmd.Context(), append(command, args...))
}
}

return cmdrunner.New().Run(
cmd.Context(),
step.New(
step.Exec(command[0], command[1:]...),
step.Stdout(os.Stdout),
step.Stderr(os.Stderr),
),
)
func toolsProtocProxy(cmd *cobra.Command, args []string) error {
command, cleanup, err := protoc.Command()
if err != nil {
return err
}
defer cleanup()

return toolsProxy(cmd.Context(), append(command, args...))
}

func toolsProxy(ctx context.Context, command []string) error {
return cmdrunner.New().Run(
ctx,
step.New(
step.Exec(command[0], command[1:]...),
step.Stdout(os.Stdout),
step.Stderr(os.Stderr),
),
)
}
6 changes: 3 additions & 3 deletions starport/pkg/cosmosgen/generate_javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/tendermint/starport/starport/pkg/cosmosanalysis/module"
"github.com/tendermint/starport/starport/pkg/giturl"
"github.com/tendermint/starport/starport/pkg/gomodulepath"
"github.com/tendermint/starport/starport/pkg/nodetime/sta"
tsproto "github.com/tendermint/starport/starport/pkg/nodetime/ts-proto"
"github.com/tendermint/starport/starport/pkg/nodetime/tsc"
"github.com/tendermint/starport/starport/pkg/nodetime/programs/sta"
tsproto "github.com/tendermint/starport/starport/pkg/nodetime/programs/ts-proto"
"github.com/tendermint/starport/starport/pkg/nodetime/programs/tsc"
"github.com/tendermint/starport/starport/pkg/protoc"
"github.com/tendermint/starport/starport/pkg/xstrings"
"golang.org/x/sync/errgroup"
Expand Down
2 changes: 1 addition & 1 deletion starport/pkg/cosmosgen/generate_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/iancoleman/strcase"
"github.com/tendermint/starport/starport/pkg/cosmosanalysis/module"
swaggercombine "github.com/tendermint/starport/starport/pkg/nodetime/swagger-combine"
swaggercombine "github.com/tendermint/starport/starport/pkg/nodetime/programs/swagger-combine"
"github.com/tendermint/starport/starport/pkg/protoc"
)

Expand Down
6 changes: 6 additions & 0 deletions starport/pkg/nodetime/data/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package data

// Binary returns the compressed platform spesific nodetime binary.
func Binary() []byte {
return binaryCompressed
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// +build darwin amd64

package nodetime
package data

import _ "embed" // embed is required for binary embedding.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// +build darwin arm64

package nodetime
package data

import _ "embed" // embed is required for binary embedding.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// +build linux amd64

package nodetime
package data

import _ "embed" // embed is required for binary embedding.

Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion starport/pkg/nodetime/nodetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"

"github.com/tendermint/starport/starport/pkg/localfs"
"github.com/tendermint/starport/starport/pkg/nodetime/data"
)

// the list of CLIs included.
Expand Down Expand Up @@ -49,7 +50,7 @@ var (
func Binary() []byte {
onceBinary.Do(func() {
// untar the binary.
gzr, err := gzip.NewReader(bytes.NewReader(binaryCompressed))
gzr, err := gzip.NewReader(bytes.NewReader(data.Binary()))
if err != nil {
panic(err)
}
Expand Down
20 changes: 20 additions & 0 deletions starport/pkg/protoc/data/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package data

import (
"embed"
"io/fs"
)

//go:embed include/* include/**/*
var include embed.FS

// Include returns a file system that contains standard proto files used by protoc.
func Include() fs.FS {
f, _ := fs.Sub(include, "include")
return f
}

// Binary returns the platform spesific protoc binary.
func Binary() []byte {
return binary
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// +build linux

package protoc
package data

import _ "embed" // embed is required for binary embedding.

//go:embed data/protoc-linux-amd64
//go:embed protoc-darwin-amd64
var binary []byte
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// +build darwin

package protoc
package data

import _ "embed" // embed is required for binary embedding.

//go:embed data/protoc-darwin-amd64
//go:embed protoc-darwin-amd64
var binary []byte
6 changes: 6 additions & 0 deletions starport/pkg/protoc/data/data_linux_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package data

import _ "embed" // embed is required for binary embedding.

//go:embed protoc-linux-amd64
var binary []byte
6 changes: 6 additions & 0 deletions starport/pkg/protoc/data/data_linux_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package data

import _ "embed" // embed is required for binary embedding.

//go:embed protoc-linux-arm64
var binary []byte
18 changes: 10 additions & 8 deletions starport/pkg/protoc/data/include/google/protobuf/descriptor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ message FileOptions {
optional string java_package = 1;


// If set, all the classes from the .proto file are wrapped in a single
// outer class with the given name. This applies to both Proto1
// (equivalent to the old "--one_java_file" option) and Proto2 (where
// a .proto always translates to a single class, but you may want to
// explicitly choose the class name).
// Controls the name of the wrapper Java class generated for the .proto file.
// That class will always contain the .proto file's getDescriptor() method as
// well as any top-level extensions defined in the .proto file.
// If java_multiple_files is disabled, then all the other classes from the
// .proto file will be nested inside the single wrapper outer class.
optional string java_outer_classname = 8;

// If set true, then the Java code generator will generate a separate .java
// If enabled, then the Java code generator will generate a separate .java
// file for each top-level message, enum, and service defined in the .proto
// file. Thus, these types will *not* be nested inside the outer class
// named by java_outer_classname. However, the outer class will still be
// file. Thus, these types will *not* be nested inside the wrapper class
// named by java_outer_classname. However, the wrapper class will still be
// generated to contain the file's getDescriptor() method as well as any
// top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default = false];
Expand Down Expand Up @@ -496,6 +496,8 @@ message MessageOptions {
// this is a formalization for deprecating messages.
optional bool deprecated = 3 [default = false];

reserved 4, 5, 6;

// Whether the message is an automatically generated map entry type for the
// maps field.
//
Expand Down
Binary file modified starport/pkg/protoc/data/protoc-darwin-amd64
Binary file not shown.
Binary file modified starport/pkg/protoc/data/protoc-linux-amd64
Binary file not shown.
Binary file added starport/pkg/protoc/data/protoc-linux-arm64
Binary file not shown.
51 changes: 28 additions & 23 deletions starport/pkg/protoc/protoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ package protoc

import (
"context"
"embed"
"io/fs"
"os"

"github.com/tendermint/starport/starport/pkg/cmdrunner/exec"
"github.com/tendermint/starport/starport/pkg/cmdrunner/step"
"github.com/tendermint/starport/starport/pkg/localfs"
"github.com/tendermint/starport/starport/pkg/protoanalysis"
"github.com/tendermint/starport/starport/pkg/protoc/data"
)

//go:embed data/include/* data/include/**/*
var include embed.FS

// Option configures Generate configs.
type Option func(*configs)

Expand All @@ -31,36 +27,45 @@ func Plugin(path string) Option {
}
}

// Generate generates code into outDir from protoPath and its includePaths by using plugins provided with protocOuts.
func Generate(ctx context.Context, outDir, protoPath string, includePaths, protocOuts []string, options ...Option) error {
c := &configs{}
for _, o := range options {
o(c)
// Command sets the protoc binary up and returns the command needed to execute c.
func Command() (command []string, cleanup func(), err error) {
path, cleanupProto, err := localfs.SaveBytesTemp(data.Binary(), "protoc", 0755)
if err != nil {
return nil, nil, err
}

// setup protoc and global protos.
protocPath, cleanup, err := localfs.SaveBytesTemp(binary, "protoc", 0755)
include, cleanupInclude, err := localfs.SaveTemp(data.Include())
if err != nil {
return err
cleanupProto()
return nil, nil, err
}
defer cleanup()

fsInInclude, err := fs.Sub(include, "data/include")
if err != nil {
return err
cleanup = func() {
cleanupProto()
cleanupInclude()
}

command = []string{
path,
"-I", include,
}

return command, cleanup, nil
}

// Generate generates code into outDir from protoPath and its includePaths by using plugins provided with protocOuts.
func Generate(ctx context.Context, outDir, protoPath string, includePaths, protocOuts []string, options ...Option) error {
c := &configs{}
for _, o := range options {
o(c)
}

globalIncludePath, cleanup, err := localfs.SaveTemp(fsInInclude)
command, cleanup, err := Command()
if err != nil {
return err
}
defer cleanup()

includePaths = append(includePaths, globalIncludePath)

// start preparing the protoc command for execution.
command := []string{protocPath}

// add plugin if set.
if c.pluginPath != "" {
command = append(command, "--plugin", c.pluginPath)
Expand Down
2 changes: 1 addition & 1 deletion starport/pkg/xrelayer/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/pkg/errors"
"github.com/tendermint/starport/starport/pkg/cosmosfaucet"
tsrelayer "github.com/tendermint/starport/starport/pkg/nodetime/ts-relayer"
tsrelayer "github.com/tendermint/starport/starport/pkg/nodetime/programs/ts-relayer"
"github.com/tendermint/starport/starport/pkg/tendermintrpc"
)

Expand Down
2 changes: 1 addition & 1 deletion starport/pkg/xrelayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xrelayer
import (
"context"

tsrelayer "github.com/tendermint/starport/starport/pkg/nodetime/ts-relayer"
tsrelayer "github.com/tendermint/starport/starport/pkg/nodetime/programs/ts-relayer"
)

// Link links all chains that has a path to each other.
Expand Down