OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package build provides tools for building Go packages. | 5 // Package build provides tools for building Go packages. |
6 package build | 6 package build |
7 | 7 |
8 import ( | 8 import ( |
9 "bytes" | 9 "bytes" |
10 "errors" | 10 "errors" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Stale returns true if the build's inputs are newer than its outputs. | 152 // Stale returns true if the build's inputs are newer than its outputs. |
153 func (s *Script) Stale() bool { | 153 func (s *Script) Stale() bool { |
154 var latest time.Time | 154 var latest time.Time |
155 // get latest mtime of outputs | 155 // get latest mtime of outputs |
156 for _, file := range s.Output { | 156 for _, file := range s.Output { |
157 fi, err := os.Stat(file) | 157 fi, err := os.Stat(file) |
158 if err != nil { | 158 if err != nil { |
159 // any error reading output files means stale | 159 // any error reading output files means stale |
160 return true | 160 return true |
161 } | 161 } |
162 » » if fi.ModTime.After(latest) { | 162 » » if mtime := fi.ModTime(); mtime.After(latest) { |
163 » » » latest = fi.ModTime | 163 » » » latest = mtime |
164 } | 164 } |
165 } | 165 } |
166 for _, file := range s.Input { | 166 for _, file := range s.Input { |
167 fi, err := os.Stat(file) | 167 fi, err := os.Stat(file) |
168 » » if err != nil || fi.ModTime.After(latest) { | 168 » » if err != nil || fi.ModTime().After(latest) { |
169 // any error reading input files means stale | 169 // any error reading input files means stale |
170 // (attempt to rebuild to figure out why) | 170 // (attempt to rebuild to figure out why) |
171 return true | 171 return true |
172 } | 172 } |
173 } | 173 } |
174 return false | 174 return false |
175 } | 175 } |
176 | 176 |
177 // Clean removes the Script's Intermediate files. | 177 // Clean removes the Script's Intermediate files. |
178 // It tries to remove every file and returns the first error it encounters. | 178 // It tries to remove every file and returns the first error it encounters. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 }) | 437 }) |
438 b.script.addIntermediate(importC) | 438 b.script.addIntermediate(importC) |
439 | 439 |
440 // cc _cgo_import.ARCH | 440 // cc _cgo_import.ARCH |
441 importObj := b.obj + "_cgo_import." + b.arch | 441 importObj := b.obj + "_cgo_import." + b.arch |
442 b.cc(importObj, importC) | 442 b.cc(importObj, importC) |
443 outObj = append(outObj, importObj) | 443 outObj = append(outObj, importObj) |
444 | 444 |
445 return | 445 return |
446 } | 446 } |
OLD | NEW |