Skip to content

Commit

Permalink
Do not generate unneeded files
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Aug 24, 2022
1 parent efb7b91 commit a6e9184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion gen/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ func (gg *Generator) generateHostFile(f *fileInfo) {
filename := f.GeneratedFilenamePrefix + "_host.pb.go"
g := gg.plugin.NewGeneratedFile(filename, f.GoImportPath)

if len(f.pluginServices) == 0 {
g.Skip()
}

// Build constraints
g.P("//go:build !tinygo.wasm")

gg.generateHeader(g, f)
gg.genHostFunctions(g, f)

for _, service := range f.allServices {
for _, service := range f.pluginServices {
genHost(g, f, service)
}
}
Expand Down
9 changes: 5 additions & 4 deletions gen/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ func (gg *Generator) generatePluginFile(f *fileInfo) {
filename := f.GeneratedFilenamePrefix + "_plugin.pb.go"
g := gg.plugin.NewGeneratedFile(filename, f.GoImportPath)

if len(f.pluginServices) == 0 {
g.Skip()
}

// Build constraints
g.P("//go:build tinygo.wasm")

gg.generateHeader(g, f)

for _, service := range f.allServices {
for _, service := range f.pluginServices {
genPlugin(g, f, service)
}
}

func genPlugin(g *protogen.GeneratedFile, f *fileInfo, service *serviceInfo) {
if service.Type != ServicePlugin {
return
}
serviceVar := strings.ToLower(service.GoName[:1]) + service.GoName[1:]

// Variable definition
Expand Down

0 comments on commit a6e9184

Please sign in to comment.