Skip to content

Commit 672b006

Browse files
committed
Display cached warnings for previously compiled files
The mutex is needed because the map could be concurrently accessed (when using parallel compilation)
1 parent afbcc4d commit 672b006

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

builder_utils/utils.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ func compileFilesWithRecipe(ctx *types.Context, objectFiles []string, sourcePath
207207
}
208208
}
209209

210+
var outputCacheMutex sync.Mutex
211+
210212
func compileFileWithRecipe(ctx *types.Context, sourcePath string, source string, buildPath string, buildProperties properties.Map, includes []string, recipe string) (string, error) {
211213
logger := ctx.GetLogger()
212214
properties := buildProperties.Clone()
@@ -230,12 +232,26 @@ func compileFileWithRecipe(ctx *types.Context, sourcePath string, source string,
230232
}
231233

232234
if !objIsUpToDate {
233-
_, _, err = ExecRecipe(ctx, properties, recipe, false /* stdout */, utils.ShowIfVerbose /* stderr */, utils.Show)
235+
stdout, stderr, err := ExecRecipe(ctx, properties, recipe, false /* stdout */, utils.ShowIfVerbose /* stderr */, utils.Show)
234236
if err != nil {
235237
return "", i18n.WrapError(err)
236238
}
237-
} else if ctx.Verbose {
238-
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_PREVIOUS_COMPILED_FILE, properties[constants.BUILD_PROPERTIES_OBJECT_FILE])
239+
outputCacheMutex.Lock()
240+
ctx.OutputCache[source] = types.Streams{
241+
Stderr: stderr,
242+
Stdout: stdout,
243+
}
244+
outputCacheMutex.Unlock()
245+
} else {
246+
if ctx.Verbose {
247+
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_PREVIOUS_COMPILED_FILE, properties[constants.BUILD_PROPERTIES_OBJECT_FILE])
248+
}
249+
if len(ctx.OutputCache[source].Stderr) > 0 && ctx.WarningsLevel != "none" {
250+
logger.UnformattedWrite(os.Stderr, ctx.OutputCache[source].Stderr)
251+
}
252+
if len(ctx.OutputCache[source].Stdout) > 0 && ctx.WarningsLevel != "none" {
253+
logger.UnformattedWrite(os.Stdout, ctx.OutputCache[source].Stdout)
254+
}
239255
}
240256

241257
return properties[constants.BUILD_PROPERTIES_OBJECT_FILE], nil

0 commit comments

Comments
 (0)