|
|
@ -23,12 +23,24 @@ func (g *DefaultGenerator) GenPb(ctx DirContext, protoImportPath []string, proto
|
|
|
|
directory = filepath.Clean(directory)
|
|
|
|
directory = filepath.Clean(directory)
|
|
|
|
cw.WriteString("protoc ")
|
|
|
|
cw.WriteString("protoc ")
|
|
|
|
protoImportPathSet := collection.NewSet()
|
|
|
|
protoImportPathSet := collection.NewSet()
|
|
|
|
|
|
|
|
isSamePackage := true
|
|
|
|
for _, ip := range protoImportPath {
|
|
|
|
for _, ip := range protoImportPath {
|
|
|
|
pip := " --proto_path=" + ip
|
|
|
|
pip := " --proto_path=" + ip
|
|
|
|
if protoImportPathSet.Contains(pip) {
|
|
|
|
if protoImportPathSet.Contains(pip) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abs, err := filepath.Abs(ip)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if abs == directory {
|
|
|
|
|
|
|
|
isSamePackage = true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
isSamePackage = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protoImportPathSet.AddStr(pip)
|
|
|
|
protoImportPathSet.AddStr(pip)
|
|
|
|
cw.WriteString(pip)
|
|
|
|
cw.WriteString(pip)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -36,6 +48,7 @@ func (g *DefaultGenerator) GenPb(ctx DirContext, protoImportPath []string, proto
|
|
|
|
if !protoImportPathSet.Contains(currentPath) {
|
|
|
|
if !protoImportPathSet.Contains(currentPath) {
|
|
|
|
cw.WriteString(currentPath)
|
|
|
|
cw.WriteString(currentPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cw.WriteString(" " + proto.Name)
|
|
|
|
cw.WriteString(" " + proto.Name)
|
|
|
|
if strings.Contains(proto.GoPackage, "/") {
|
|
|
|
if strings.Contains(proto.GoPackage, "/") {
|
|
|
|
cw.WriteString(" --go_out=plugins=grpc:" + ctx.GetMain().Filename)
|
|
|
|
cw.WriteString(" --go_out=plugins=grpc:" + ctx.GetMain().Filename)
|
|
|
@ -57,6 +70,7 @@ func (g *DefaultGenerator) GenPb(ctx DirContext, protoImportPath []string, proto
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var currentFileOpt string
|
|
|
|
var currentFileOpt string
|
|
|
|
|
|
|
|
if !isSamePackage || (len(proto.GoPackage) > 0 && proto.GoPackage != proto.Package.Name) {
|
|
|
|
if filepath.IsAbs(proto.GoPackage) {
|
|
|
|
if filepath.IsAbs(proto.GoPackage) {
|
|
|
|
currentFileOpt = " --go_opt=M" + base + "=" + proto.GoPackage
|
|
|
|
currentFileOpt = " --go_opt=M" + base + "=" + proto.GoPackage
|
|
|
|
} else if strings.Contains(proto.GoPackage, string(filepath.Separator)) {
|
|
|
|
} else if strings.Contains(proto.GoPackage, string(filepath.Separator)) {
|
|
|
@ -64,6 +78,10 @@ func (g *DefaultGenerator) GenPb(ctx DirContext, protoImportPath []string, proto
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
currentFileOpt = " --go_opt=M" + base + "=../" + proto.GoPackage
|
|
|
|
currentFileOpt = " --go_opt=M" + base + "=../" + proto.GoPackage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
currentFileOpt = " --go_opt=M" + base + "=."
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !optSet.Contains(currentFileOpt) {
|
|
|
|
if !optSet.Contains(currentFileOpt) {
|
|
|
|
cw.WriteString(currentFileOpt)
|
|
|
|
cw.WriteString(currentFileOpt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|