-
Notifications
You must be signed in to change notification settings - Fork 2
/
gobind_wrapper.go
47 lines (42 loc) · 929 Bytes
/
gobind_wrapper.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
package main
import (
"flag"
"os"
"os/exec"
"path/filepath"
)
var (
gobind = flag.String("gobind", "", "")
zipper = flag.String("zipper", "", "")
outdir = flag.String("outdir", "", "")
outjar = flag.String("outjar", "", "")
)
func run(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
func makeArchive(archive, dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
return nil
}
args := []string{"c", archive}
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return nil
}
args = append(args, path[len(dir)+1:]+"="+path)
return nil
})
return run(*zipper, args...)
}
func main() {
flag.Parse()
if err := run(*gobind, flag.Args()...); err != nil {
panic(err)
}
if err := makeArchive(*outjar, *outdir+"/java"); err != nil {
panic(err)
}
}