From 19cc05eb2caa393377e9671a5ea2fd33b99eec2d Mon Sep 17 00:00:00 2001 From: davyxu Date: Tue, 3 Aug 2021 22:54:29 +0800 Subject: [PATCH] =?UTF-8?q?filelist=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gen/pbscheme/gen_dir.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gen/pbscheme/gen_dir.go b/gen/pbscheme/gen_dir.go index 31c96f4..683bb3f 100644 --- a/gen/pbscheme/gen_dir.go +++ b/gen/pbscheme/gen_dir.go @@ -7,6 +7,7 @@ import ( "github.com/davyxu/protoplus/model" "io/ioutil" "path/filepath" + "sort" "strings" ) @@ -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). @@ -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