Skip to content

Commit 4ef1873

Browse files
Add --thriftNoRecurse flag to control passing -r to thrift
To allow generating thrift without generating for all dependencies. Flag is a negative to preserve current behaviour.
1 parent 3edb77b commit 4ef1873

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

thrift/thrift-gen/generate.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var (
3333
thriftBinary = flag.String("thriftBinary", "thrift", "Command to use for the Apache Thrift binary")
3434
apacheThriftImport = flag.String("thriftImport", "github.com/apache/thrift/lib/go/thrift", "Go package to use for the Thrift import")
3535
packagePrefix = flag.String("packagePrefix", "", "The package prefix (will be used similar to how Apache Thrift uses it)")
36+
thriftNoRecurse = flag.Bool("thriftNoRecurse", false, "Indicates if thrift should not generate included files (-r flag)")
3637
)
3738

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

7980
// Generate the Apache Thrift generated code.
8081
goArgs := fmt.Sprintf("go:thrift_import=%s,package_prefix=%s", *apacheThriftImport, *packagePrefix)
81-
if err := execThrift("-r", "--gen", goArgs, "-out", outDir, inFile); err != nil {
82+
args := []string{
83+
"--gen", goArgs, "-out", outDir, inFile,
84+
}
85+
if !*thriftNoRecurse {
86+
args = append(args, "-r")
87+
}
88+
if err := execThrift(args...); err != nil {
8289
return fmt.Errorf("thrift compile failed: %v", err)
8390
}
8491

0 commit comments

Comments
 (0)