Skip to content

Commit

Permalink
Add --thriftNoRecurse flag to control passing -r to thrift
Browse files Browse the repository at this point in the history
To allow generating thrift without generating for all dependencies. Flag
is a negative to preserve current behaviour.
  • Loading branch information
robbertvanginkel committed Aug 19, 2020
1 parent 3edb77b commit 4ef1873
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion thrift/thrift-gen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
thriftBinary = flag.String("thriftBinary", "thrift", "Command to use for the Apache Thrift binary")
apacheThriftImport = flag.String("thriftImport", "github.com/apache/thrift/lib/go/thrift", "Go package to use for the Thrift import")
packagePrefix = flag.String("packagePrefix", "", "The package prefix (will be used similar to how Apache Thrift uses it)")
thriftNoRecurse = flag.Bool("thriftNoRecurse", false, "Indicates if thrift should not generate included files (-r flag)")
)

func execCmd(name string, args ...string) error {
Expand Down Expand Up @@ -78,7 +79,13 @@ func runThrift(inFile string, outDir string) error {

// Generate the Apache Thrift generated code.
goArgs := fmt.Sprintf("go:thrift_import=%s,package_prefix=%s", *apacheThriftImport, *packagePrefix)
if err := execThrift("-r", "--gen", goArgs, "-out", outDir, inFile); err != nil {
args := []string{
"--gen", goArgs, "-out", outDir, inFile,
}
if !*thriftNoRecurse {
args = append(args, "-r")
}
if err := execThrift(args...); err != nil {
return fmt.Errorf("thrift compile failed: %v", err)
}

Expand Down

0 comments on commit 4ef1873

Please sign in to comment.