-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathbuilder.go
54 lines (41 loc) · 880 Bytes
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package api
import (
"fmt"
"os"
"os/exec"
"github.com/project-flogo/cli/common"
"github.com/project-flogo/cli/util"
)
type AppBuilder struct {
}
func (*AppBuilder) Build(project common.AppProject) error {
err := restoreMain(project)
if err != nil {
return err
}
err = simpleGoBuild(project)
if err != nil {
return err
}
return nil
}
func simpleGoBuild(project common.AppProject) error {
if _, err := os.Stat(project.BinDir()); err != nil {
if Verbose() {
fmt.Println("Creating 'bin' directory")
}
err = os.MkdirAll(project.BinDir(), os.ModePerm)
if err != nil {
return err
}
}
if Verbose() {
fmt.Println("Performing 'go build'...")
}
err := util.ExecCmd(exec.Command("go", "build", "-o", project.Executable()), project.SrcDir())
if err != nil {
fmt.Println("Error in building", project.SrcDir())
return err
}
return nil
}