-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
54 lines (47 loc) · 1.1 KB
/
main.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 main
import (
"encoding/json"
"flag"
"fmt"
"os"
"vs_export/sln"
"io/ioutil"
"path/filepath"
)
func main() {
path := flag.String("s", "", "sln file path")
configuration := flag.String("c", "Debug|Win32",
"Configuration, [configuration|platform], default Debug|Win32")
flag.Parse()
if *path == "" {
usage()
os.Exit(1)
}
solution, err := sln.NewSln(*path)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
cmdList, err := solution.CompileCommandsJson(*configuration)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
js, err := json.Marshal(cmdList)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("%s\n", js[:])
ioutil.WriteFile("compile_commands.json", js[:], 0644)
}
func usage() {
var echo = `Usage: %s -s <path> -c <configuration>
Where:
-s path sln filename
-c configuration project configuration,eg Debug|Win32.
default Debug|Win32
`
echo = fmt.Sprintf(echo, filepath.Base(os.Args[0]))
fmt.Println(echo)
}