mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
cmd: improve build command
This commit is contained in:
parent
5790c10a38
commit
1f18c36870
|
@ -80,8 +80,6 @@ func Build(ctx context.Context, userConfig *Config, targetConfig BuildTargetConf
|
|||
return "", err
|
||||
}
|
||||
|
||||
defer os.RemoveAll(packageDir)
|
||||
|
||||
if err := compilePackage(packageDir, userConfig, imports); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -110,8 +108,9 @@ func Build(ctx context.Context, userConfig *Config, targetConfig BuildTargetConf
|
|||
|
||||
output := filepath.Join(buildDir, binary)
|
||||
|
||||
logrus.Infof("building binary %s from %s...", output, buildTarget)
|
||||
buildCmd := exec.CommandContext(ctx, "go", "build", "-tags", "wrapper", "-o", output, buildTarget)
|
||||
args := []string{"build", "-tags", "wrapper", "-o", output, buildTarget}
|
||||
logrus.Debugf("building binary %s from %s: go %v", output, buildTarget, args)
|
||||
buildCmd := exec.CommandContext(ctx, "go", args...)
|
||||
buildCmd.Env = append(os.Environ(), buildEnvs...)
|
||||
buildCmd.Stdout = os.Stdout
|
||||
buildCmd.Stderr = os.Stderr
|
||||
|
@ -119,7 +118,7 @@ func Build(ctx context.Context, userConfig *Config, targetConfig BuildTargetConf
|
|||
return output, err
|
||||
}
|
||||
|
||||
return output, nil
|
||||
return output, os.RemoveAll(packageDir)
|
||||
}
|
||||
|
||||
func BuildTarget(ctx context.Context, userConfig *Config, target BuildTargetConfig) (string, error) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
BuildCmd.Flags().String("config", "", "config file")
|
||||
BuildCmd.Flags().String("config", "bbgo.yaml", "config file")
|
||||
RootCmd.AddCommand(BuildCmd)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user