@@ -59,9 +59,6 @@ type Builder struct {
59
59
// Parallel processes
60
60
jobs int
61
61
62
- // Custom build properties defined by user (line by line as "key=value" pairs)
63
- customBuildProperties []string
64
-
65
62
// core related
66
63
coreBuildCachePath * paths.Path
67
64
extraCoreBuildCachePaths paths.PathList
@@ -89,7 +86,7 @@ type Builder struct {
89
86
lineOffset int
90
87
91
88
targetPlatform * cores.PlatformRelease
92
- actualPlatform * cores.PlatformRelease
89
+ buildPlatform * cores.PlatformRelease
93
90
94
91
buildArtifacts * buildArtifacts
95
92
@@ -125,19 +122,20 @@ func NewBuilder(
125
122
coreBuildCachePath * paths.Path ,
126
123
extraCoreBuildCachePaths paths.PathList ,
127
124
jobs int ,
128
- requestBuildProperties []string ,
129
- hardwareDirs , otherLibrariesDirs paths.PathList ,
125
+ customBuildProperties []string ,
126
+ hardwareDirs paths.PathList ,
127
+ librariesDirs paths.PathList ,
130
128
builtInLibrariesDirs * paths.Path ,
131
129
fqbn * fqbn.FQBN ,
132
130
clean bool ,
133
131
sourceOverrides map [string ]string ,
134
132
onlyUpdateCompilationDatabase bool ,
135
- targetPlatform , actualPlatform * cores.PlatformRelease ,
133
+ targetPlatform , buildPlatform * cores.PlatformRelease ,
136
134
useCachedLibrariesResolution bool ,
137
135
librariesManager * librariesmanager.LibrariesManager ,
138
- libraryDirs paths.PathList ,
136
+ customLibraryDirs paths.PathList ,
139
137
stdout , stderr io.Writer , verbosity logger.Verbosity , warningsLevel string ,
140
- progresCB rpc.TaskProgressCB ,
138
+ progressCB rpc.TaskProgressCB ,
141
139
toolEnv []string ,
142
140
) (* Builder , error ) {
143
141
buildProperties := properties .NewMap ()
@@ -146,14 +144,12 @@ func NewBuilder(
146
144
}
147
145
if sk != nil {
148
146
buildProperties .SetPath ("sketch_path" , sk .FullPath )
147
+ buildProperties .Set ("build.project_name" , sk .MainFile .Base ())
148
+ buildProperties .SetPath ("build.source.path" , sk .FullPath )
149
149
}
150
150
if buildPath != nil {
151
151
buildProperties .SetPath ("build.path" , buildPath )
152
152
}
153
- if sk != nil {
154
- buildProperties .Set ("build.project_name" , sk .MainFile .Base ())
155
- buildProperties .SetPath ("build.source.path" , sk .FullPath )
156
- }
157
153
if optimizeForDebug {
158
154
if debugFlags , ok := buildProperties .GetOk ("compiler.optimization_flags.debug" ); ok {
159
155
buildProperties .Set ("compiler.optimization_flags" , debugFlags )
@@ -165,12 +161,11 @@ func NewBuilder(
165
161
}
166
162
167
163
// Add user provided custom build properties
168
- customBuildProperties , err := properties .LoadFromSlice (requestBuildProperties )
169
- if err != nil {
164
+ if p , err := properties .LoadFromSlice (customBuildProperties ); err == nil {
165
+ buildProperties .Merge (p )
166
+ } else {
170
167
return nil , fmt .Errorf ("invalid build properties: %w" , err )
171
168
}
172
- buildProperties .Merge (customBuildProperties )
173
- customBuildPropertiesArgs := append (requestBuildProperties , "build.warn_data_percentage=75" )
174
169
175
170
sketchBuildPath , err := buildPath .Join ("sketch" ).Abs ()
176
171
if err != nil {
@@ -190,16 +185,20 @@ func NewBuilder(
190
185
}
191
186
192
187
log := logger .New (stdout , stderr , verbosity , warningsLevel )
193
- libsManager , libsResolver , verboseOut , err := detector .LibrariesLoader (
194
- useCachedLibrariesResolution , librariesManager ,
195
- builtInLibrariesDirs , libraryDirs , otherLibrariesDirs ,
196
- actualPlatform , targetPlatform ,
188
+ libsManager , libsResolver , libsLoadingWarnings , err := detector .LibrariesLoader (
189
+ useCachedLibrariesResolution ,
190
+ librariesManager ,
191
+ builtInLibrariesDirs ,
192
+ customLibraryDirs ,
193
+ librariesDirs ,
194
+ buildPlatform ,
195
+ targetPlatform ,
197
196
)
198
197
if err != nil {
199
198
return nil , err
200
199
}
201
200
if log .VerbosityLevel () == logger .VerbosityVerbose {
202
- log .Warn (string (verboseOut ))
201
+ log .Warn (string (libsLoadingWarnings ))
203
202
}
204
203
205
204
diagnosticStore := diagnostics .NewStore ()
@@ -212,25 +211,26 @@ func NewBuilder(
212
211
coreBuildPath : coreBuildPath ,
213
212
librariesBuildPath : librariesBuildPath ,
214
213
jobs : jobs ,
215
- customBuildProperties : customBuildPropertiesArgs ,
216
214
coreBuildCachePath : coreBuildCachePath ,
217
215
extraCoreBuildCachePaths : extraCoreBuildCachePaths ,
218
216
logger : log ,
219
217
clean : clean ,
220
218
sourceOverrides : sourceOverrides ,
221
219
onlyUpdateCompilationDatabase : onlyUpdateCompilationDatabase ,
222
220
compilationDatabase : compilation .NewDatabase (buildPath .Join ("compile_commands.json" )),
223
- Progress : progress .New (progresCB ),
221
+ Progress : progress .New (progressCB ),
224
222
executableSectionsSize : []ExecutableSectionSize {},
225
223
buildArtifacts : & buildArtifacts {},
226
224
targetPlatform : targetPlatform ,
227
- actualPlatform : actualPlatform ,
225
+ buildPlatform : buildPlatform ,
228
226
toolEnv : toolEnv ,
229
227
buildOptions : newBuildOptions (
230
- hardwareDirs , otherLibrariesDirs ,
231
- builtInLibrariesDirs , buildPath ,
228
+ hardwareDirs ,
229
+ librariesDirs ,
230
+ builtInLibrariesDirs ,
231
+ buildPath ,
232
232
sk ,
233
- customBuildPropertiesArgs ,
233
+ customBuildProperties ,
234
234
fqbn ,
235
235
clean ,
236
236
buildProperties .Get ("compiler.optimization_flags" ),
@@ -322,10 +322,19 @@ func (b *Builder) preprocess() error {
322
322
b .librariesBuildPath ,
323
323
b .buildProperties ,
324
324
b .targetPlatform .Platform .Architecture ,
325
+ b .jobs ,
325
326
)
326
327
if err != nil {
327
328
return err
328
329
}
330
+ if b .libsDetector .IncludeFoldersChanged () && b .librariesBuildPath .Exist () {
331
+ if b .logger .VerbosityLevel () == logger .VerbosityVerbose {
332
+ b .logger .Info (i18n .Tr ("The list of included libraries has been changed... rebuilding all libraries." ))
333
+ }
334
+ if err := b .librariesBuildPath .RemoveAll (); err != nil {
335
+ return err
336
+ }
337
+ }
329
338
b .Progress .CompleteStep ()
330
339
331
340
b .warnAboutArchIncompatibleLibraries (b .libsDetector .ImportedLibraries ())
@@ -492,29 +501,26 @@ func (b *Builder) prepareCommandForRecipe(buildProperties *properties.Map, recip
492
501
commandLine = properties .DeleteUnexpandedPropsFromString (commandLine )
493
502
}
494
503
495
- parts , err := properties .SplitQuotedString (commandLine , `"'` , false )
496
- if err != nil {
497
- return nil , err
498
- }
504
+ args , _ := properties .SplitQuotedString (commandLine , `"'` , false )
499
505
500
506
// if the overall commandline is too long for the platform
501
507
// try reducing the length by making the filenames relative
502
508
// and changing working directory to build.path
503
509
var relativePath string
504
510
if len (commandLine ) > 30000 {
505
511
relativePath = buildProperties .Get ("build.path" )
506
- for i , arg := range parts {
512
+ for i , arg := range args {
507
513
if _ , err := os .Stat (arg ); os .IsNotExist (err ) {
508
514
continue
509
515
}
510
516
rel , err := filepath .Rel (relativePath , arg )
511
517
if err == nil && ! strings .Contains (rel , ".." ) && len (rel ) < len (arg ) {
512
- parts [i ] = rel
518
+ args [i ] = rel
513
519
}
514
520
}
515
521
}
516
522
517
- command , err := paths .NewProcess (b .toolEnv , parts ... )
523
+ command , err := paths .NewProcess (b .toolEnv , args ... )
518
524
if err != nil {
519
525
return nil , err
520
526
}
0 commit comments