Skip to content

Commit

Permalink
移除filelist.txt生成
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Sep 18, 2022
1 parent deb2ad3 commit b89e5d1
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions gen/pbscheme/gen_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import (
"github.com/davyxu/protoplus/codegen"
"github.com/davyxu/protoplus/gen"
"github.com/davyxu/protoplus/model"
"io/ioutil"
"path/filepath"
"sort"
"strings"
)

const protoDirCodeTemplate = `// Generated by github.com/davyxu/protoplus
Expand Down Expand Up @@ -104,38 +102,38 @@ func GenProtoDir(ctx *gen.Context) error {

rootDS := &PBDescriptorSet{DescriptorSet: *ctx.DescriptorSet}

var sb strings.Builder
//var sb strings.Builder

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

srcNameList = append(srcNameList, srcName)

gen := codegen.NewCodeGen("dirproto").
generator := codegen.NewCodeGen("dirproto").
RegisterTemplateFunc(codegen.UsefulFunc).
RegisterTemplateFunc(UsefulFunc).
ParseTemplate(protoDirCodeTemplate, ds)

if gen.Error() != nil {
fmt.Println(string(gen.Data()))
return gen.Error()
if generator.Error() != nil {
fmt.Println(string(generator.Data()))
return generator.Error()
}

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

err := gen.WriteOutputFile(fullPathName).Error()
err := generator.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)
//for _, d := range srcNameList {
// fmt.Fprintf(&sb, "%s ", d)
//}
//
//err := ioutil.WriteFile(filepath.Join(ctx.OutputFileName, "filelist.txt"), []byte(sb.String()), 0666)

return err
return nil
}

0 comments on commit b89e5d1

Please sign in to comment.