forked from hwaf/hwaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_waf_show_project_version.go
54 lines (44 loc) · 1.16 KB
/
cmd_waf_show_project_version.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 (
"fmt"
"path/filepath"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"github.com/hwaf/hwaf/hwaflib"
)
func hwaf_make_cmd_waf_show_project_version() *commander.Command {
cmd := &commander.Command{
Run: hwaf_run_cmd_waf_show_project_version,
UsageLine: "project-version",
Short: "show local project's version",
Long: `
show project-version displays the project's version.
ex:
$ hwaf show project-version
0.0.1
`,
Flag: *flag.NewFlagSet("hwaf-waf-show-project-version", flag.ExitOnError),
}
return cmd
}
func hwaf_run_cmd_waf_show_project_version(cmd *commander.Command, args []string) {
var err error
//n := "hwaf-" + cmd.Name()
workdir, err := g_ctx.Workarea()
handle_err(err)
// FIXME: get actual value from waf, somehow
pinfo_name := filepath.Join(workdir, "__build__", "c4che", "_cache.py")
if !path_exists(pinfo_name) {
err = fmt.Errorf(
"no such file [%s]. did you run \"hwaf configure\" ?",
pinfo_name,
)
handle_err(err)
}
pinfo, err := hwaflib.NewProjectInfo(pinfo_name)
handle_err(err)
val, err := pinfo.Get("HWAF_PROJECT_VERSION")
handle_err(err)
fmt.Printf("%s\n", val)
}
// EOF