github.com/rpdict/ponzu@v0.10.1-0.20190226054626-477f29d6bf5e/cmd/ponzu/build.go (about) 1 package main 2 3 import ( 4 "path/filepath" 5 "strings" 6 7 "github.com/spf13/cobra" 8 ) 9 10 func buildPonzuServer() error { 11 // copy all ./content files to internal vendor directory 12 src := "content" 13 dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "rpdict", "ponzu", "content") 14 err := emptyDir(dst) 15 if err != nil { 16 return err 17 } 18 err = copyFilesWarnConflicts(src, dst, []string{"doc.go"}) 19 if err != nil { 20 return err 21 } 22 23 // copy all ./addons files & dirs to internal vendor directory 24 src = "addons" 25 dst = filepath.Join("cmd", "ponzu", "vendor") 26 err = copyFilesWarnConflicts(src, dst, nil) 27 if err != nil { 28 return err 29 } 30 31 // execute go build -o rpdict cmd/ponzu/*.go 32 cmdPackageName := strings.Join([]string{".", "cmd", "ponzu"}, "/") 33 buildOptions := []string{"build", "-o", buildOutputName(), cmdPackageName} 34 return execAndWait(gocmd, buildOptions...) 35 } 36 37 var buildCmd = &cobra.Command{ 38 Use: "build [flags]", 39 Short: "build will build/compile the project to then be run.", 40 Long: `From within your Ponzu project directory, running build will copy and move 41 the necessary files from your workspace into the vendored directory, and 42 will build/compile the project to then be run. 43 44 By providing the 'gocmd' flag, you can specify which Go command to build the 45 project, if testing a different release of Go. 46 47 Errors will be reported, but successful build commands return nothing.`, 48 Example: `$ ponzu build 49 (or) 50 $ ponzu build --gocmd=go1.8rc1`, 51 RunE: func(cmd *cobra.Command, args []string) error { 52 return buildPonzuServer() 53 }, 54 } 55 56 func init() { 57 RegisterCmdlineCommand(buildCmd) 58 }