forked from hwaf/hwaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_waf_show_flags.go
75 lines (61 loc) · 1.51 KB
/
cmd_waf_show_flags.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
73
74
75
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_flags() *commander.Command {
cmd := &commander.Command{
Run: hwaf_run_cmd_waf_show_flags,
UsageLine: "flags [options] [<flag-name> [<flag-name> [...]]]",
Short: "show local project's 'flags-name' value",
Long: `
show flags displays the value of some flags.
ex:
$ hwaf show flags CXXFLAGS
['-O2', '-fPIC', '-pipe', '-ansi', '-Wall', '-W', '-pthread', '-m64', '-Wno-deprecated']
$ hwaf show flags
`,
Flag: *flag.NewFlagSet("hwaf-waf-show-flags", flag.ExitOnError),
}
return cmd
}
func hwaf_run_cmd_waf_show_flags(cmd *commander.Command, args []string) {
var err error
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)
switch len(args) {
case 0:
args = pinfo.Keys()
}
err_stack := []error{}
for _, k := range args {
val, err2 := pinfo.Get(k)
if err2 != nil {
err_stack = append(err_stack, err2)
err = err2
continue
}
fmt.Printf("%s=%s\n", k, val)
}
if len(err_stack) != 0 {
for _, err := range err_stack {
fmt.Printf("**error: %v\n", err)
}
handle_err(err)
}
}
// EOF