-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprofile.go
More file actions
61 lines (57 loc) · 1.76 KB
/
Copy pathprofile.go
File metadata and controls
61 lines (57 loc) · 1.76 KB
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
package main
import (
"fmt"
"os"
"text/tabwriter"
)
type Profile struct {
Name string `json:"name"`
SrcDir string `json:"src_dir"`
Arch string `json:"arch"`
CrossComile string `json:"cross_compile"`
ExtraOpts string `json:"extra_opts"`
BuildDir string `json:"build_dir"`
DefConfig string `json:"defconfig"`
Target string `json:"target"`
DTB string `json:"dtb"`
ExtraDTBs string `json:"extra_dtbs"`
ModInstallDir string `json:"mod_install_dir"`
ThreadNum int `json:"thread_num"`
}
// do not include 'Name' filed.
func (p *Profile) String() string {
line := ""
line += fmt.Sprintln(" SrcDir\t:", p.SrcDir)
line += fmt.Sprintln(" Arch\t:", p.Arch)
line += fmt.Sprintln(" CC\t:", p.CrossComile)
line += fmt.Sprintln(" ExtraOpts\t:", p.ExtraOpts)
line += fmt.Sprintln(" BuildDir\t:", p.BuildDir)
line += fmt.Sprintln(" DefConfig\t:", p.DefConfig)
line += fmt.Sprintln(" Target\t:", p.Target)
line += fmt.Sprintln(" DTB\t:", p.DTB)
line += fmt.Sprintln(" ExtraDTBs\t:", p.ExtraDTBs)
line += fmt.Sprintln(" ModInsDir\t:", p.ModInstallDir)
line += fmt.Sprintln(" ThreadNum\t:", p.ThreadNum)
return line
}
func printProfile(p *Profile, verbose bool, current bool, i int) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.TabIndent)
header := func(p *Profile, current bool) {
if current {
fmt.Printf("\n" + defMark() + " ")
} else {
fmt.Printf("\n ")
}
fmt.Println(cWrap(cGREEN, fmt.Sprintf("[%d] '%s'", i, p.Name)))
}
if verbose {
header(p, current)
fmt.Fprintf(w, "%v", p)
} else {
header(p, current)
fmt.Fprintf(w, " SrcDir\t: %s\n", p.SrcDir)
fmt.Fprintf(w, " Arch\t: %s\n", p.Arch)
fmt.Fprintf(w, " BuildDir\t: %s\n", p.BuildDir)
}
w.Flush()
}