forked from marvin-automator/marvin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Magefile.go
72 lines (60 loc) · 1.84 KB
/
Magefile.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// +build mage
package main
import (
"fmt"
"github.com/gobuffalo/envy"
"os"
"os/exec"
"runtime"
"strings"
)
func errorAndExit(err error) {
if err != nil {
println("Error encountered: ", err.Error())
os.Exit(1)
}
}
func runCommand(ignoreError bool, path, name string, args ...string) {
cmd := exec.Command(name, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = path
println(name, strings.Join(args, " "))
err := cmd.Run()
if ignoreError {
return
}
errorAndExit(err)
}
const V8_VERSION = "6.3.292.48.1"
func Setup() {
println("Installing deps...")
runCommand(true, "", "go", "get", "-u", "-v", "./...")
runCommand(true, "", "go", "-get", "-u", "-v", "github.com/gobuffalo/packr/packr")
var os_arch string
switch runtime.GOOS {
case "darwin":
os_arch = "x86_64-darwin-16"
case "linux":
os_arch = "x86_64-linux"
default:
println("Unsupported os", runtime.GOOS)
os.Exit(1)
}
filename := fmt.Sprintf("libv8-%v-%v.gem", V8_VERSION, os_arch)
wd, err := os.Getwd()
errorAndExit(err)
os.Mkdir("v8binary", 0700)
runCommand(false, wd+"/v8binary", "curl", "https://rubygems.org/downloads/"+filename, "-o", filename)
runCommand(false, wd+"/v8binary", "tar", "-xvf", filename)
runCommand(false, wd+"/v8binary", "tar", "-xzvf", "data.tar.gz")
runCommand(false, "", "ln", "-f", "-s", wd+"/v8binary/vendor/v8/out/x64.release", envy.GoPath()+"/src/github.com/joesonw/js8/libv8")
runCommand(false, "", "ln", "-f", "-s", wd+"/v8binary/vendor/v8/include", envy.GoPath()+"/src/github.com/joesonw/js8/include")
println("Installing frontend deps...")
runCommand(false, wd+"", "npm", "install", "-g", "yarn")
runCommand(false, wd+"/frontend", "yarn")
println("Building frontend...")
runCommand(false, wd+"/frontend", "yarn", "run", "build")
println("Building and installing marvin...")
runCommand(false, "", "packr", "install")
}