@@ -18,14 +18,17 @@ package builder
18
18
import (
19
19
"errors"
20
20
"fmt"
21
+ "io"
21
22
22
- "github.com/arduino/arduino-cli/arduino/builder/compilation"
23
- "github.com/arduino/arduino-cli/arduino/builder/detector"
24
- "github.com/arduino/arduino-cli/arduino/builder/logger"
25
- "github.com/arduino/arduino-cli/arduino/builder/progress"
23
+ "github.com/arduino/arduino-cli/arduino/builder/internal/ compilation"
24
+ "github.com/arduino/arduino-cli/arduino/builder/internal/ detector"
25
+ "github.com/arduino/arduino-cli/arduino/builder/internal/ logger"
26
+ "github.com/arduino/arduino-cli/arduino/builder/internal/ progress"
26
27
"github.com/arduino/arduino-cli/arduino/cores"
28
+ "github.com/arduino/arduino-cli/arduino/libraries"
27
29
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
28
30
"github.com/arduino/arduino-cli/arduino/sketch"
31
+ rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
29
32
"github.com/arduino/go-paths-helper"
30
33
"github.com/arduino/go-properties-orderedmap"
31
34
)
@@ -77,14 +80,15 @@ type Builder struct {
77
80
targetPlatform * cores.PlatformRelease
78
81
actualPlatform * cores.PlatformRelease
79
82
80
- buildArtifacts * BuildArtifacts
83
+ buildArtifacts * buildArtifacts
81
84
82
- * detector.SketchLibrariesDetector
83
- * BuildOptionsManager
85
+ buildOptions * buildOptions
86
+
87
+ libsDetector * detector.SketchLibrariesDetector
84
88
}
85
89
86
- // BuildArtifacts contains the result of various build
87
- type BuildArtifacts struct {
90
+ // buildArtifacts contains the result of various build
91
+ type buildArtifacts struct {
88
92
// populated by BuildCore
89
93
coreArchiveFilePath * paths.Path
90
94
coreObjectsFiles paths.PathList
@@ -115,8 +119,8 @@ func NewBuilder(
115
119
useCachedLibrariesResolution bool ,
116
120
librariesManager * librariesmanager.LibrariesManager ,
117
121
libraryDirs paths.PathList ,
118
- logger * logger. BuilderLogger ,
119
- progressStats * progress. Struct ,
122
+ stdout , stderr io. Writer , verbose bool , warningsLevel string ,
123
+ progresCB rpc. TaskProgressCB ,
120
124
) (* Builder , error ) {
121
125
buildProperties := properties .NewMap ()
122
126
if boardBuildProperties != nil {
@@ -165,10 +169,7 @@ func NewBuilder(
165
169
return nil , ErrSketchCannotBeLocatedInBuildPath
166
170
}
167
171
168
- if progressStats == nil {
169
- progressStats = progress .New (nil )
170
- }
171
-
172
+ logger := logger .New (stdout , stderr , verbose , warningsLevel )
172
173
libsManager , libsResolver , verboseOut , err := detector .LibrariesLoader (
173
174
useCachedLibrariesResolution , librariesManager ,
174
175
builtInLibrariesDirs , libraryDirs , otherLibrariesDirs ,
@@ -196,18 +197,18 @@ func NewBuilder(
196
197
sourceOverrides : sourceOverrides ,
197
198
onlyUpdateCompilationDatabase : onlyUpdateCompilationDatabase ,
198
199
compilationDatabase : compilation .NewDatabase (buildPath .Join ("compile_commands.json" )),
199
- Progress : progressStats ,
200
+ Progress : progress . New ( progresCB ) ,
200
201
executableSectionsSize : []ExecutableSectionSize {},
201
- buildArtifacts : & BuildArtifacts {},
202
+ buildArtifacts : & buildArtifacts {},
202
203
targetPlatform : targetPlatform ,
203
204
actualPlatform : actualPlatform ,
204
- SketchLibrariesDetector : detector .NewSketchLibrariesDetector (
205
+ libsDetector : detector .NewSketchLibrariesDetector (
205
206
libsManager , libsResolver ,
206
207
useCachedLibrariesResolution ,
207
208
onlyUpdateCompilationDatabase ,
208
209
logger ,
209
210
),
210
- BuildOptionsManager : NewBuildOptionsManager (
211
+ buildOptions : newBuildOptions (
211
212
hardwareDirs , builtInToolsDirs , otherLibrariesDirs ,
212
213
builtInLibrariesDirs , buildPath ,
213
214
sk ,
@@ -217,7 +218,6 @@ func NewBuilder(
217
218
buildProperties .Get ("compiler.optimization_flags" ),
218
219
buildProperties .GetPath ("runtime.platform.path" ),
219
220
buildProperties .GetPath ("build.core.path" ), // TODO can we buildCorePath ?
220
- logger ,
221
221
),
222
222
}, nil
223
223
}
@@ -237,6 +237,11 @@ func (b *Builder) ExecutableSectionsSize() ExecutablesFileSections {
237
237
return b .executableSectionsSize
238
238
}
239
239
240
+ // ImportedLibraries fixdoc
241
+ func (b * Builder ) ImportedLibraries () libraries.List {
242
+ return b .libsDetector .ImportedLibraries ()
243
+ }
244
+
240
245
// Preprocess fixdoc
241
246
func (b * Builder ) Preprocess () error {
242
247
b .Progress .AddSubSteps (6 )
@@ -249,7 +254,10 @@ func (b *Builder) preprocess() error {
249
254
return err
250
255
}
251
256
252
- if err := b .BuildOptionsManager .WipeBuildPath (); err != nil {
257
+ if err := b .wipeBuildPathIfBuildOptionsChanged (); err != nil {
258
+ return err
259
+ }
260
+ if err := b .createBuildOptionsJSON (); err != nil {
253
261
return err
254
262
}
255
263
b .Progress .CompleteStep ()
@@ -268,7 +276,7 @@ func (b *Builder) preprocess() error {
268
276
b .Progress .PushProgress ()
269
277
270
278
b .logIfVerbose (false , tr ("Detecting libraries used..." ))
271
- err := b .SketchLibrariesDetector .FindIncludes (
279
+ err := b .libsDetector .FindIncludes (
272
280
b .buildPath ,
273
281
b .buildProperties .GetPath ("build.core.path" ),
274
282
b .buildProperties .GetPath ("build.variant.path" ),
@@ -284,12 +292,12 @@ func (b *Builder) preprocess() error {
284
292
b .Progress .CompleteStep ()
285
293
b .Progress .PushProgress ()
286
294
287
- b .warnAboutArchIncompatibleLibraries (b .SketchLibrariesDetector .ImportedLibraries ())
295
+ b .warnAboutArchIncompatibleLibraries (b .libsDetector .ImportedLibraries ())
288
296
b .Progress .CompleteStep ()
289
297
b .Progress .PushProgress ()
290
298
291
299
b .logIfVerbose (false , tr ("Generating function prototypes..." ))
292
- if err := b .preprocessSketch (b .SketchLibrariesDetector .IncludeFolders ()); err != nil {
300
+ if err := b .preprocessSketch (b .libsDetector .IncludeFolders ()); err != nil {
293
301
return err
294
302
}
295
303
b .Progress .CompleteStep ()
@@ -327,18 +335,18 @@ func (b *Builder) Build() error {
327
335
328
336
buildErr := b .build ()
329
337
330
- b .SketchLibrariesDetector .PrintUsedAndNotUsedLibraries (buildErr != nil )
338
+ b .libsDetector .PrintUsedAndNotUsedLibraries (buildErr != nil )
331
339
b .Progress .CompleteStep ()
332
340
b .Progress .PushProgress ()
333
341
334
- b .printUsedLibraries (b .SketchLibrariesDetector .ImportedLibraries ())
342
+ b .printUsedLibraries (b .libsDetector .ImportedLibraries ())
335
343
b .Progress .CompleteStep ()
336
344
b .Progress .PushProgress ()
337
345
338
346
if buildErr != nil {
339
347
return buildErr
340
348
}
341
- if err := b .exportProjectCMake (b .SketchLibrariesDetector .ImportedLibraries (), b .SketchLibrariesDetector .IncludeFolders ()); err != nil {
349
+ if err := b .exportProjectCMake (b .libsDetector .ImportedLibraries (), b .libsDetector .IncludeFolders ()); err != nil {
342
350
return err
343
351
}
344
352
b .Progress .CompleteStep ()
@@ -362,7 +370,7 @@ func (b *Builder) build() error {
362
370
b .Progress .CompleteStep ()
363
371
b .Progress .PushProgress ()
364
372
365
- if err := b .BuildSketch (b .SketchLibrariesDetector .IncludeFolders ()); err != nil {
373
+ if err := b .BuildSketch (b .libsDetector .IncludeFolders ()); err != nil {
366
374
return err
367
375
}
368
376
b .Progress .CompleteStep ()
@@ -381,13 +389,13 @@ func (b *Builder) build() error {
381
389
b .Progress .CompleteStep ()
382
390
b .Progress .PushProgress ()
383
391
384
- if err := b .removeUnusedCompiledLibraries (b .SketchLibrariesDetector .ImportedLibraries ()); err != nil {
392
+ if err := b .removeUnusedCompiledLibraries (b .libsDetector .ImportedLibraries ()); err != nil {
385
393
return err
386
394
}
387
395
b .Progress .CompleteStep ()
388
396
b .Progress .PushProgress ()
389
397
390
- if err := b .buildLibraries (b .SketchLibrariesDetector .IncludeFolders (), b .SketchLibrariesDetector .ImportedLibraries ()); err != nil {
398
+ if err := b .buildLibraries (b .libsDetector .IncludeFolders (), b .libsDetector .ImportedLibraries ()); err != nil {
391
399
return err
392
400
}
393
401
b .Progress .CompleteStep ()
0 commit comments