Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions plugins/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ func (b *Builder) preBuild(ctx context.Context) error {
}

log.Debug("executing prebuild script for plugin %s", pluginName)
cmd := b.env.NewCommand(ctx, b.env.Go(), "run", "scripts/prebuild.go", v, tmpPath)
cmd.Dir = packagePath

err = b.env.RunCmd(ctx, cmd)
err = b.runGoRun(ctx, packagePath, []string{"scripts/prebuild.go", v, tmpPath})
if err != nil {
return err
}
Expand Down Expand Up @@ -324,6 +321,19 @@ func (b *Builder) preBuild(ctx context.Context) error {
return nil
}

func (b *Builder) runGoRun(ctx context.Context, dir string, args []string) error {
runArgs := append([]string{"run"}, args...)
cmd := b.env.NewCommand(ctx, b.env.Go(), runArgs...)
cmd.Dir = dir
env := make(envVars, len(cmd.Env))
copy(env, cmd.Env)
// Exclude target platform information as it may break "go run".
env.Unset("GOOS")
env.Unset("GOARCH")
cmd.Env = env
return b.env.RunCmd(ctx, cmd)
}

func (b *Builder) runGen(ctx context.Context) error {
genArgs := []string{"generate", "./..."}
cmd := b.env.NewCommand(ctx, b.env.Go(), genArgs...)
Expand Down