Skip to content

Commit 4006605

Browse files
committed
Cache and print also stdout
1 parent 48c8a10 commit 4006605

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

builder_utils/utils.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,25 @@ func compileFileWithRecipe(ctx *types.Context, sourcePath string, source string,
232232
}
233233

234234
if !objIsUpToDate {
235-
_, stderrCache, 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)
236236
if err != nil {
237237
return "", i18n.WrapError(err)
238238
}
239239
warningCacheMutex.Lock()
240-
ctx.WarningsCache[source] = string(stderrCache)
240+
ctx.WarningsCache[source] = types.Streams{
241+
Stderr: stderr,
242+
Stdout: stdout,
243+
}
241244
warningCacheMutex.Unlock()
242245
} else {
243246
if ctx.Verbose {
244247
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_PREVIOUS_COMPILED_FILE, properties[constants.BUILD_PROPERTIES_OBJECT_FILE])
245248
}
246-
if ctx.WarningsCache[source] != "" {
247-
logger.UnformattedFprintln(os.Stderr, ctx.WarningsCache[source])
249+
if len(ctx.WarningsCache[source].Stderr) > 0 && ctx.WarningsLevel != "none" {
250+
logger.UnformattedWrite(os.Stderr, ctx.WarningsCache[source].Stderr)
251+
}
252+
if len(ctx.WarningsCache[source].Stdout) > 0 && ctx.WarningsLevel != "none" {
253+
logger.UnformattedWrite(os.Stdout, ctx.WarningsCache[source].Stdout)
248254
}
249255
}
250256

load_previous_build_options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type LoadPreviousWarningsMap struct{}
6767

6868
func (s *LoadPreviousWarningsMap) Run(ctx *types.Context) error {
6969
cachedWarningsFile := filepath.Join(ctx.BuildPath, constants.FILE_WARNINGS_CACHE)
70-
ctx.WarningsCache = make(map[string]string)
70+
ctx.WarningsCache = make(map[string]types.Streams)
7171

7272
_, err := os.Stat(cachedWarningsFile)
7373
if err != nil {

types/context.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ type ProgressStruct struct {
1414
Progress float64
1515
}
1616

17+
type Streams struct {
18+
Stdout []byte
19+
Stderr []byte
20+
}
21+
1722
// Context structure
1823
type Context struct {
1924
// Build options
@@ -65,7 +70,7 @@ type Context struct {
6570
CodeCompletions string
6671

6772
WarningsLevel string
68-
WarningsCache map[string]string
73+
WarningsCache map[string]Streams
6974

7075
// Libraries handling
7176
Libraries []*Library

0 commit comments

Comments
 (0)