Skip to content

Commit d4e9078

Browse files
Generalize ObjFileIsUpToDate to BuildResultIsUpToDate
This renames this function and adds a resultFile parameter. This resultFile is used for all timestamp checks against other files (source file, dep file, header files from the dep file), while the objectFile passed is now only used to check against the contents of the dep file. Both calls to this function still pass the same filename as objectFile and resultFile, so this commit should not change any behavior. Signed-off-by: Matthijs Kooijman <[email protected]>
1 parent 824a5ff commit d4e9078

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/arduino.cc/builder/builder_utils/utils.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func compileFileWithRecipe(sourcePath string, source string, buildPath string, b
144144
return "", i18n.WrapError(err)
145145
}
146146

147-
objIsUpToDate, err := ObjFileIsUpToDate(properties[constants.BUILD_PROPERTIES_SOURCE_FILE], properties[constants.BUILD_PROPERTIES_OBJECT_FILE], filepath.Join(buildPath, relativeSource+".d"), debugLevel, logger)
147+
objIsUpToDate, err := BuildResultIsUpToDate(properties[constants.BUILD_PROPERTIES_SOURCE_FILE], properties[constants.BUILD_PROPERTIES_OBJECT_FILE], properties[constants.BUILD_PROPERTIES_OBJECT_FILE], filepath.Join(buildPath, relativeSource+".d"), debugLevel, logger)
148148
if err != nil {
149149
return "", i18n.WrapError(err)
150150
}
@@ -161,25 +161,26 @@ func compileFileWithRecipe(sourcePath string, source string, buildPath string, b
161161
return properties[constants.BUILD_PROPERTIES_OBJECT_FILE], nil
162162
}
163163

164-
func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel int, logger i18n.Logger) (bool, error) {
164+
func BuildResultIsUpToDate(sourceFile, resultFile, objectFile, dependencyFile string, debugLevel int, logger i18n.Logger) (bool, error) {
165165
sourceFile = filepath.Clean(sourceFile)
166+
resultFile = filepath.Clean(resultFile)
166167
objectFile = filepath.Clean(objectFile)
167168
dependencyFile = filepath.Clean(dependencyFile)
168169

169170
if debugLevel >= 20 {
170-
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Checking previous results for {0} (result = {1}, dep = {2})", sourceFile, objectFile, dependencyFile)
171+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Checking build results for {0} (result = {1}, dep = {2})", sourceFile, objectFile, dependencyFile)
171172
}
172173

173174
sourceFileStat, err := os.Stat(sourceFile)
174175
if err != nil {
175176
return false, i18n.WrapError(err)
176177
}
177178

178-
objectFileStat, err := os.Stat(objectFile)
179+
resultFileStat, err := os.Stat(resultFile)
179180
if err != nil {
180181
if os.IsNotExist(err) {
181182
if debugLevel >= 20 {
182-
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Not found: {0}", objectFile)
183+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Not found: {0}", resultFile)
183184
}
184185
return false, nil
185186
} else {
@@ -199,9 +200,9 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
199200
}
200201
}
201202

202-
if sourceFileStat.ModTime().After(objectFileStat.ModTime()) {
203+
if sourceFileStat.ModTime().After(resultFileStat.ModTime()) {
203204
if debugLevel >= 20 {
204-
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", sourceFile, objectFile)
205+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", sourceFile, resultFile)
205206
}
206207
return false, nil
207208
}
@@ -259,9 +260,9 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
259260
}
260261
return false, nil
261262
}
262-
if depStat.ModTime().After(objectFileStat.ModTime()) {
263+
if depStat.ModTime().After(resultFileStat.ModTime()) {
263264
if debugLevel >= 20 {
264-
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", row, objectFile)
265+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", row, resultFile)
265266
}
266267
return false, nil
267268
}

src/arduino.cc/builder/container_find_includes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
305305
// TODO: This reads the dependency file, but the actual building
306306
// does it again. Should the result be somehow cached? Perhaps
307307
// remove the object file if it is found to be stale?
308-
unchanged, err := builder_utils.ObjFileIsUpToDate(sourcePath, objPath, depPath, ctx.DebugLevel, ctx.GetLogger())
308+
unchanged, err := builder_utils.BuildResultIsUpToDate(sourcePath, objPath, objPath, depPath, ctx.DebugLevel, ctx.GetLogger())
309309
if err != nil {
310310
return i18n.WrapError(err)
311311
}

0 commit comments

Comments
 (0)