blob: 5feaeb875803b66b366e594ac9d5b3af730d7ffd (
plain)
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
|
package pkglint
type Toplevel struct {
dir string
previousSubdir string
subdirs []string
}
func CheckdirToplevel(dir string) {
if trace.Tracing {
defer trace.Call1(dir)()
}
ctx := Toplevel{dir, "", nil}
filename := dir + "/Makefile"
mklines := LoadMk(filename, NotEmpty|LogErrors)
if mklines == nil {
return
}
for _, mkline := range mklines.mklines {
if (mkline.IsVarassign() || mkline.IsCommentedVarassign()) && mkline.Varname() == "SUBDIR" {
ctx.checkSubdir(mkline)
}
}
mklines.Check()
if G.Opts.Recursive {
if G.Opts.CheckGlobal {
G.Pkgsrc.UsedLicenses = make(map[string]bool)
G.Pkgsrc.Hashes = make(map[string]*Hash)
}
G.Todo = append(append([]string(nil), ctx.subdirs...), G.Todo...)
}
}
func (ctx *Toplevel) checkSubdir(mkline MkLine) {
subdir := mkline.Value()
if mkline.IsCommentedVarassign() && (mkline.VarassignComment() == "#" || mkline.VarassignComment() == "") {
mkline.Warnf("%q commented out without giving a reason.", subdir)
}
if !hasSuffix(mkline.ValueAlign(), "=\t") {
mkline.Warnf("Indentation should be a single tab character.")
}
if contains(subdir, "$") || !fileExists(ctx.dir+"/"+subdir+"/Makefile") {
return
}
prev := ctx.previousSubdir
switch {
case subdir > prev:
// Correctly ordered
case subdir == prev:
mkline.Errorf("Each subdir must only appear once.")
case subdir == "archivers" && prev == "x11":
// This exception is documented in the top-level Makefile.
default:
mkline.Warnf("%s should come before %s.", subdir, prev)
}
ctx.previousSubdir = subdir
if !mkline.IsCommentedVarassign() {
ctx.subdirs = append(ctx.subdirs, ctx.dir+"/"+subdir)
}
}
|