MCPcopy Create free account
hub / github.com/nsf/gocode / autobuild

Function autobuild

declcache.go:192–216  ·  view source on GitHub ↗

autobuild compares the mod time of the source files of the package, and if any of them is newer than the package object file will rebuild it.

(p *build.Package)

Source from the content-addressed store, hash-verified

190// autobuild compares the mod time of the source files of the package, and if any of them is newer
191// than the package object file will rebuild it.
192func autobuild(p *build.Package) error {
193 if p.Dir == "" {
194 return fmt.Errorf("no files to build")
195 }
196 ps, err := os.Stat(p.PkgObj)
197 if err != nil {
198 // Assume package file does not exist and build for the first time.
199 return build_package(p)
200 }
201 pt := ps.ModTime()
202 fs, err := readdir_lstat(p.Dir)
203 if err != nil {
204 return err
205 }
206 for _, f := range fs {
207 if f.IsDir() {
208 continue
209 }
210 if f.ModTime().After(pt) {
211 // Source file is newer than package file; rebuild.
212 return build_package(p)
213 }
214 }
215 return nil
216}
217
218// build_package builds the package by calling `go install package/import`. If everything compiles
219// correctly, the newly compiled package should then be in the usual place in the `$GOPATH/pkg`

Callers 1

try_autobuildFunction · 0.85

Calls 2

build_packageFunction · 0.85
readdir_lstatFunction · 0.85

Tested by

no test coverage detected