return false
}
-// deptab lists changes to the default dependencies for a given prefix.
-// deps ending in /* read the whole directory; deps beginning with -
-// exclude files with that prefix.
-// Note that this table applies only to the build of cmd/go,
-// after the main compiler bootstrap.
-// Files listed here should also be listed in ../distpack/pack.go's srcArch.Remove list.
-var deptab = []struct {
- prefix string // prefix of target
- dep []string // dependency tweaks for targets with that prefix
-}{
- {"cmd/go/internal/cfg", []string{
- "zdefaultcc.go",
- }},
- {"go/build", []string{
- "zcgo.go",
- }},
- {"internal/platform", []string{
- "zosarch.go",
- }},
- {"runtime/internal/sys", []string{
- "zversion.go",
- }},
- {"time/tzdata", []string{
- "zzipdata.go",
- }},
-}
-
// depsuffix records the allowed suffixes for source files.
var depsuffix = []string{
".s",
}
// gentab records how to generate some trivial files.
+// Files listed here should also be listed in ../distpack/pack.go's srcArch.Remove list.
var gentab = []struct {
- nameprefix string
- gen func(string, string)
+ pkg string // Relative to $GOROOT/src
+ file string
+ gen func(dir, file string)
}{
- {"zcgo.go", mkzcgo},
- {"zdefaultcc.go", mkzdefaultcc},
- {"zosarch.go", mkzosarch},
- {"zversion.go", mkzversion},
- {"zzipdata.go", mktzdata},
+ {"go/build", "zcgo.go", mkzcgo},
+ {"cmd/go/internal/cfg", "zdefaultcc.go", mkzdefaultcc},
+ {"internal/platform", "zosarch.go", mkzosarch},
+ {"runtime/internal/sys", "zversion.go", mkzversion},
+ {"time/tzdata", "zzipdata.go", mktzdata},
}
// installed maps from a dir name (as given to install) to a chan
return ch
}
-// runInstall installs the library, package, or binary associated with dir,
+// runInstall installs the library, package, or binary associated with pkg,
// which is relative to $GOROOT/src.
func runInstall(pkg string, ch chan struct{}) {
if pkg == "net" || pkg == "os/user" || pkg == "crypto/x509" {
return !strings.HasPrefix(p, ".") && (!strings.HasPrefix(p, "_") || !strings.HasSuffix(p, ".go"))
})
- for _, dt := range deptab {
- if pkg == dt.prefix || strings.HasSuffix(dt.prefix, "/") && strings.HasPrefix(pkg, dt.prefix) {
- for _, p := range dt.dep {
- p = os.ExpandEnv(p)
- files = append(files, p)
- }
+ // Add generated files for this package.
+ for _, gt := range gentab {
+ if gt.pkg == pkg {
+ files = append(files, gt.file)
}
}
files = uniq(files)
}
// Is the target up-to-date?
- var gofiles, sfiles, missing []string
+ var gofiles, sfiles []string
stale := rebuildall
files = filter(files, func(p string) bool {
for _, suf := range depsuffix {
if t.After(ttarg) {
stale = true
}
- if t.IsZero() {
- missing = append(missing, p)
- }
return true
})
}
// Generate any missing files; regenerate existing ones.
- for _, p := range files {
- elem := filepath.Base(p)
- for _, gt := range gentab {
- if gt.gen == nil {
- continue
- }
- if strings.HasPrefix(elem, gt.nameprefix) {
- if vflag > 1 {
- errprintf("generate %s\n", p)
- }
- gt.gen(dir, p)
- // Do not add generated file to clean list.
- // In runtime, we want to be able to
- // build the package with the go tool,
- // and it assumes these generated files already
- // exist (it does not know how to build them).
- // The 'clean' command can remove
- // the generated files.
- goto built
- }
+ for _, gt := range gentab {
+ if gt.pkg != pkg {
+ continue
}
- // Did not rebuild p.
- if find(p, missing) >= 0 {
- fatalf("missing file %s", p)
+ p := pathf("%s/%s", dir, gt.file)
+ if vflag > 1 {
+ errprintf("generate %s\n", p)
}
- built:
+ gt.gen(dir, p)
+ // Do not add generated file to clean list.
+ // In runtime, we want to be able to
+ // build the package with the go tool,
+ // and it assumes these generated files already
+ // exist (it does not know how to build them).
+ // The 'clean' command can remove
+ // the generated files.
}
// Resolve imported packages to actual package paths.
"zversion.go",
}
-// cleanlist is a list of packages with generated files and commands.
-var cleanlist = []string{
- "runtime/internal/sys",
- "cmd/cgo",
- "cmd/go/internal/cfg",
- "internal/platform",
- "go/build",
-}
-
func clean() {
- for _, name := range cleanlist {
- path := pathf("%s/src/%s", goroot, name)
- // Remove generated files.
- for _, elem := range xreaddir(path) {
- for _, gt := range gentab {
- if strings.HasPrefix(elem, gt.nameprefix) {
- xremove(pathf("%s/%s", path, elem))
- }
- }
- }
+ // Remove generated files.
+ for _, gt := range gentab {
+ path := pathf("%s/src/%s/%s", goroot, gt.pkg, gt.file)
+ xremove(path)
}
// remove runtimegen files.