cockroach: github.com/cockroachdb/cockroach/pkg/cmd/prereqs Files

Command prereqs

prereqs generates Make prerequisites for Go binaries. It works much like the traditional makedepend tool for C.

Given the path to a Go package, prereqs will traverse the package's dependency graph to determine what files impact its compilation. It then outputs a Makefile that expresses these dependencies. For example:

$ prereqs ./pkg/cmd/foo
# Code generated by prereqs. DO NOT EDIT!

bin/foo: ./pkg/cmd/foo/foo.go ./some/dep.go ./some/other_dep.go

./pkg/cmd/foo/foo.go:
./some/dep.go:
./some/other_dep.go:

The intended usage is automatic dependency generation from another Makefile:

bin/target:
 prereqs ./pkg/cmd/target > bin/target.d
 go build -o $@ ./pkg/cmd/target

include bin/target.d

Notice that depended-upon files are mentioned not only in the prerequisites list but also as a rule with no prerequisite or recipe. This prevents Make from complaining if the prerequisite is deleted. See [0] for details on the approach.

[0]: http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/

Package Files

prereqs.go

Package main imports 7 packages (graph). Updated 2019-07-07. Refresh now. Tools for package owners.