-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.go
59 lines (50 loc) · 1.05 KB
/
install.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
package main
import (
_ "fmt"
"github.com/scott-x/gutils/fs"
"log"
"strings"
)
const (
INCLUDE_DIR = "/usr/local/include/fizz"
LIB_DIR = "/usr/local/lib"
DYLIB_FIZZ = "src/libfizz.dylib"
)
var dylib_fizz_des = LIB_DIR + "/" + strings.Split(DYLIB_FIZZ, "/")[1]
var header = map[string]string{
"cmd.h": "src/cmd/cmd.h",
"color.h": "src/cl/color.h",
"db.h": "src/db/db.h",
"excel.h": "src/excel/excel.h",
"fs.h": "src/fs/fs.h",
"sql.h": "src/parse/sql.h",
"reg.h": "src/reg/reg.h",
"str.h": "src/str/str.h",
"time.h": "src/t/time.h",
"fizz.h": "src/fizz.h",
}
func main() {
if !fs.IsExist(DYLIB_FIZZ) {
log.Println("dynamic lib for fizz not found...")
return
}
// uninstall
uninstall()
//install
install()
}
func uninstall() {
if fs.IsExist(INCLUDE_DIR) {
fs.RemoveAll(INCLUDE_DIR)
}
if fs.IsExist(dylib_fizz_des) {
fs.RemoveAll(dylib_fizz_des)
}
}
func install() {
fs.CreateDirIfNotExist(INCLUDE_DIR)
for h, des := range header {
fs.CopyFile(des, INCLUDE_DIR+"/"+h)
}
fs.CopyFile(DYLIB_FIZZ, dylib_fizz_des)
}