Skip to content

Commit

Permalink
filelist排序
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Aug 3, 2021
1 parent 1caf0eb commit 19cc05e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gen/pbscheme/gen_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/davyxu/protoplus/model"
"io/ioutil"
"path/filepath"
"sort"
"strings"
)

Expand Down Expand Up @@ -105,8 +106,11 @@ func GenProtoDir(ctx *gen.Context) error {

var sb strings.Builder

var srcNameList []string
for srcName, ds := range rootDS.DescriptorSetBySource() {

srcNameList = append(srcNameList, srcName)

gen := codegen.NewCodeGen("dirproto").
RegisterTemplateFunc(codegen.UsefulFunc).
RegisterTemplateFunc(UsefulFunc).
Expand All @@ -119,14 +123,18 @@ func GenProtoDir(ctx *gen.Context) error {

fullPathName := filepath.Join(ctx.OutputFileName, srcName)

fmt.Fprintf(&sb, "%s ", srcName)

err := gen.WriteOutputFile(fullPathName).Error()
if err != nil {
return err
}
}

sort.Strings(srcNameList)

for _, d := range srcNameList {
fmt.Fprintf(&sb, "%s ", d)
}

err := ioutil.WriteFile(filepath.Join(ctx.OutputFileName, "filelist.txt"), []byte(sb.String()), 0666)

return err
Expand Down

0 comments on commit 19cc05e

Please sign in to comment.