Skip to content

Commit 0051a83

Browse files
facchinmcmaglie
authored andcommitted
Fix syncronization issues with "Multiple libraries found"
Signed-off-by: Martino Facchin <m.facchin@arduino.cc>
1 parent 543663f commit 0051a83

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

arduino-builder/main.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,6 @@ func main() {
177177
return
178178
}
179179

180-
if *jobsFlag > 0 {
181-
runtime.GOMAXPROCS(*jobsFlag)
182-
} else {
183-
runtime.GOMAXPROCS(runtime.NumCPU())
184-
}
185-
186180
ctx := &types.Context{}
187181

188182
if *buildOptionsFileFlag != "" {
@@ -200,6 +194,14 @@ func main() {
200194
ctx.InjectBuildOptions(buildOptions)
201195
}
202196

197+
// Parallel Jobs flag
198+
if *jobsFlag > 0 {
199+
ctx.Jobs = *jobsFlag
200+
} else {
201+
ctx.Jobs = runtime.NumCPU()
202+
}
203+
runtime.GOMAXPROCS(ctx.Jobs)
204+
203205
// FLAG_HARDWARE
204206
if hardwareFolders, err := toSliceOfUnquoted(hardwareFoldersFlag); err != nil {
205207
printCompleteError(err)

print_used_and_not_used_libraries.go

+4-2
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
}

types/context.go

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ type Context struct {
8888

8989
// ReadFileAndStoreInContext command
9090
FileToRead string
91+
92+
// Max jobs
93+
Jobs int
9194
}
9295

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

0 commit comments

Comments
 (0)