Skip to content

Commit cf6b28e

Browse files
committed
Fix syncronization issues with "Multiple libraries found"
Signed-off-by: Martino Facchin <[email protected]>
1 parent 0a3d888 commit cf6b28e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/arduino.cc/arduino-builder/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,6 @@ func main() {
173173
return
174174
}
175175

176-
if *jobsFlag > 0 {
177-
runtime.GOMAXPROCS(*jobsFlag)
178-
} else {
179-
runtime.GOMAXPROCS(runtime.NumCPU())
180-
}
181-
182176
ctx := &types.Context{}
183177

184178
if *buildOptionsFileFlag != "" {
@@ -196,6 +190,14 @@ func main() {
196190
ctx.InjectBuildOptions(buildOptions)
197191
}
198192

193+
// Parallel Jobs flag
194+
if *jobsFlag > 0 {
195+
ctx.Jobs = *jobsFlag
196+
} else {
197+
ctx.Jobs = runtime.NumCPU()
198+
}
199+
runtime.GOMAXPROCS(ctx.Jobs)
200+
199201
// FLAG_HARDWARE
200202
if hardwareFolders, err := toSliceOfUnquoted(hardwareFoldersFlag); err != nil {
201203
printCompleteError(err)

src/arduino.cc/builder/print_used_and_not_used_libraries.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func (s *PrintUsedAndNotUsedLibraries) Run(ctx *types.Context) error {
5353
return nil
5454
}
5555

56+
if ctx.Jobs > 1 {
57+
time.Sleep(100 * time.Millisecond)
58+
}
59+
5660
logger := ctx.GetLogger()
5761
libraryResolutionResults := ctx.LibrariesResolutionResults
5862

@@ -64,7 +68,5 @@ func (s *PrintUsedAndNotUsedLibraries) Run(ctx *types.Context) error {
6468
}
6569
}
6670

67-
time.Sleep(100 * time.Millisecond)
68-
6971
return nil
7072
}

src/arduino.cc/builder/types/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ type Context struct {
8686

8787
// ReadFileAndStoreInContext command
8888
FileToRead string
89+
90+
// Max jobs
91+
Jobs int
8992
}
9093

9194
func (ctx *Context) ExtractBuildOptions() properties.Map {

0 commit comments

Comments
 (0)