Skip to content

Commit 427ea7d

Browse files
Let ObjFileIsUpToDate output verbose debug output
If -debug-level=20 is passed, whenever the cached file is not usable for whatever reason, a message is displayed. This should help debug caching problems. The messages are hardcoded in the source and not put into `constants`, since they are only debug messages. Signed-off-by: Matthijs Kooijman <[email protected]>
1 parent 4327e72 commit 427ea7d

File tree

1 file changed

+32
-0
lines changed
  • src/arduino.cc/builder/builder_utils

1 file changed

+32
-0
lines changed

Diff for: src/arduino.cc/builder/builder_utils/utils.go

+32
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
166166
objectFile = filepath.Clean(objectFile)
167167
dependencyFile = filepath.Clean(dependencyFile)
168168

169+
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+
}
172+
169173
sourceFileStat, err := os.Stat(sourceFile)
170174
if err != nil {
171175
return false, i18n.WrapError(err)
@@ -174,6 +178,9 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
174178
objectFileStat, err := os.Stat(objectFile)
175179
if err != nil {
176180
if os.IsNotExist(err) {
181+
if debugLevel >= 20 {
182+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Not found: {0}", objectFile);
183+
}
177184
return false, nil
178185
} else {
179186
return false, i18n.WrapError(err)
@@ -183,16 +190,25 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
183190
dependencyFileStat, err := os.Stat(dependencyFile)
184191
if err != nil {
185192
if os.IsNotExist(err) {
193+
if debugLevel >= 20 {
194+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Not found: {0}", dependencyFile);
195+
}
186196
return false, nil
187197
} else {
188198
return false, i18n.WrapError(err)
189199
}
190200
}
191201

192202
if sourceFileStat.ModTime().After(objectFileStat.ModTime()) {
203+
if debugLevel >= 20 {
204+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", sourceFile, objectFile);
205+
}
193206
return false, nil
194207
}
195208
if sourceFileStat.ModTime().After(dependencyFileStat.ModTime()) {
209+
if debugLevel >= 20 {
210+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", sourceFile, dependencyFile);
211+
}
196212
return false, nil
197213
}
198214

@@ -212,10 +228,16 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
212228

213229
firstRow := rows[0]
214230
if !strings.HasSuffix(firstRow, ":") {
231+
if debugLevel >= 20 {
232+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "No colon in first line of depfile");
233+
}
215234
return false, nil
216235
}
217236
objFileInDepFile := firstRow[:len(firstRow)-1]
218237
if objFileInDepFile != objectFile {
238+
if debugLevel >= 20 {
239+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Depfile is about different file: {0}", objFileInDepFile);
240+
}
219241
return false, nil
220242
}
221243

@@ -225,12 +247,22 @@ func ObjFileIsUpToDate(sourceFile, objectFile, dependencyFile string, debugLevel
225247
if err != nil && !os.IsNotExist(err) {
226248
// There is probably a parsing error of the dep file
227249
// Ignore the error and trigger a full rebuild anyway
250+
if debugLevel >= 20 {
251+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Failed to read: {0}", row)
252+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, i18n.WrapError(err).Error())
253+
}
228254
return false, nil
229255
}
230256
if os.IsNotExist(err) {
257+
if debugLevel >= 20 {
258+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "Not found: {0}", row)
259+
}
231260
return false, nil
232261
}
233262
if depStat.ModTime().After(objectFileStat.ModTime()) {
263+
if debugLevel >= 20 {
264+
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, "{0} newer than {1}", row, objectFile);
265+
}
234266
return false, nil
235267
}
236268
}

0 commit comments

Comments
 (0)