Skip to content

Commit 07a9db1

Browse files
committed
Update package.go
1 parent 78c84ca commit 07a9db1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

serve/package.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (s *PluginServe) writeTablesJSON(ctx context.Context, dir string) error {
117117
return os.WriteFile(outputPath, buffer.Bytes(), 0644)
118118
}
119119

120-
func (s *PluginServe) build(pluginDirectory string, target plugin.BuildTarget, distPath, pluginVersion string) (*TargetBuild, error) {
120+
func (s *PluginServe) build(pluginDirectory string, target plugin.BuildTarget, distPath, pluginVersion, buildTags string) (*TargetBuild, error) {
121121
pluginFileName := fmt.Sprintf("plugin-%s-%s-%s-%s", s.plugin.Name(), pluginVersion, target.OS, target.Arch)
122122
pluginPath := path.Join(distPath, pluginFileName)
123123
importPath, err := s.getModuleName(pluginDirectory)
@@ -134,7 +134,7 @@ func (s *PluginServe) build(pluginDirectory string, target plugin.BuildTarget, d
134134
args = append(args, "-ldflags", ldFlags)
135135
// This disables gRPC tracing, which introduces a dependency that blocks dead code elimination\
136136
// https://github.com/grpc/grpc-go/blob/030938e543b4a721cd426d15611d50ecf097dcf3/trace_notrace.go#L23-L25
137-
args = append(args, "-tags", "grpcnotrace")
137+
args = append(args, "-tags", buildTags)
138138
cmd := exec.Command("go", args...)
139139
cmd.Dir = pluginDirectory
140140
cmd.Stdout = os.Stdout
@@ -404,6 +404,10 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
404404
message = string(messageBytes)
405405
}
406406
message = normalizeMessage(message)
407+
buildTags := "grpcnotrace"
408+
if cmd.Flag("build-tags").Changed {
409+
buildTags = cmd.Flag("build-tags").Value.String()
410+
}
407411

408412
if err := os.MkdirAll(distPath, 0755); err != nil {
409413
return err
@@ -437,7 +441,7 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
437441
targets := []TargetBuild{}
438442
for _, target := range s.plugin.Targets() {
439443
fmt.Println("Building for OS: " + target.OS + ", ARCH: " + target.Arch)
440-
targetBuild, err := s.build(pluginDirectory, target, distPath, pluginVersion)
444+
targetBuild, err := s.build(pluginDirectory, target, distPath, pluginVersion, buildTags)
441445
if err != nil {
442446
return fmt.Errorf("failed to build plugin for %s/%s: %w", target.OS, target.Arch, err)
443447
}
@@ -458,6 +462,7 @@ func (s *PluginServe) newCmdPluginPackage() *cobra.Command {
458462
cmd.Flags().StringP("dist-dir", "D", "", "dist directory to output the built plugin. (default: <plugin_directory>/dist)")
459463
cmd.Flags().StringP("docs-dir", "", "", "docs directory containing markdown files to copy to the dist directory. (default: <plugin_directory>/docs)")
460464
cmd.Flags().StringP("message", "m", "", "message that summarizes what is new or changed in this version. Use @<file> to read from file. Supports markdown.")
465+
cmd.Flags().StringP("build-tags", "", "", "build tags to use when building the plugin. (default: grpcnotrace)")
461466
return cmd
462467
}
463468

0 commit comments

Comments
 (0)