@@ -59,9 +59,6 @@ type Builder struct {
5959 // Parallel processes
6060 jobs int
6161
62- // Custom build properties defined by user (line by line as "key=value" pairs)
63- customBuildProperties []string
64-
6562 // core related
6663 coreBuildCachePath * paths.Path
6764 extraCoreBuildCachePaths paths.PathList
@@ -89,7 +86,7 @@ type Builder struct {
8986 lineOffset int
9087
9188 targetPlatform * cores.PlatformRelease
92- actualPlatform * cores.PlatformRelease
89+ buildPlatform * cores.PlatformRelease
9390
9491 buildArtifacts * buildArtifacts
9592
@@ -125,19 +122,20 @@ func NewBuilder(
125122 coreBuildCachePath * paths.Path ,
126123 extraCoreBuildCachePaths paths.PathList ,
127124 jobs int ,
128- requestBuildProperties []string ,
129- hardwareDirs , otherLibrariesDirs paths.PathList ,
125+ customBuildProperties []string ,
126+ hardwareDirs paths.PathList ,
127+ librariesDirs paths.PathList ,
130128 builtInLibrariesDirs * paths.Path ,
131129 fqbn * fqbn.FQBN ,
132130 clean bool ,
133131 sourceOverrides map [string ]string ,
134132 onlyUpdateCompilationDatabase bool ,
135- targetPlatform , actualPlatform * cores.PlatformRelease ,
133+ targetPlatform , buildPlatform * cores.PlatformRelease ,
136134 useCachedLibrariesResolution bool ,
137135 librariesManager * librariesmanager.LibrariesManager ,
138- libraryDirs paths.PathList ,
136+ customLibraryDirs paths.PathList ,
139137 stdout , stderr io.Writer , verbosity logger.Verbosity , warningsLevel string ,
140- progresCB rpc.TaskProgressCB ,
138+ progressCB rpc.TaskProgressCB ,
141139 toolEnv []string ,
142140) (* Builder , error ) {
143141 buildProperties := properties .NewMap ()
@@ -146,14 +144,12 @@ func NewBuilder(
146144 }
147145 if sk != nil {
148146 buildProperties .SetPath ("sketch_path" , sk .FullPath )
147+ buildProperties .Set ("build.project_name" , sk .MainFile .Base ())
148+ buildProperties .SetPath ("build.source.path" , sk .FullPath )
149149 }
150150 if buildPath != nil {
151151 buildProperties .SetPath ("build.path" , buildPath )
152152 }
153- if sk != nil {
154- buildProperties .Set ("build.project_name" , sk .MainFile .Base ())
155- buildProperties .SetPath ("build.source.path" , sk .FullPath )
156- }
157153 if optimizeForDebug {
158154 if debugFlags , ok := buildProperties .GetOk ("compiler.optimization_flags.debug" ); ok {
159155 buildProperties .Set ("compiler.optimization_flags" , debugFlags )
@@ -165,12 +161,11 @@ func NewBuilder(
165161 }
166162
167163 // 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 {
170167 return nil , fmt .Errorf ("invalid build properties: %w" , err )
171168 }
172- buildProperties .Merge (customBuildProperties )
173- customBuildPropertiesArgs := append (requestBuildProperties , "build.warn_data_percentage=75" )
174169
175170 sketchBuildPath , err := buildPath .Join ("sketch" ).Abs ()
176171 if err != nil {
@@ -190,16 +185,20 @@ func NewBuilder(
190185 }
191186
192187 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 ,
197196 )
198197 if err != nil {
199198 return nil , err
200199 }
201200 if log .VerbosityLevel () == logger .VerbosityVerbose {
202- log .Warn (string (verboseOut ))
201+ log .Warn (string (libsLoadingWarnings ))
203202 }
204203
205204 diagnosticStore := diagnostics .NewStore ()
@@ -212,25 +211,26 @@ func NewBuilder(
212211 coreBuildPath : coreBuildPath ,
213212 librariesBuildPath : librariesBuildPath ,
214213 jobs : jobs ,
215- customBuildProperties : customBuildPropertiesArgs ,
216214 coreBuildCachePath : coreBuildCachePath ,
217215 extraCoreBuildCachePaths : extraCoreBuildCachePaths ,
218216 logger : log ,
219217 clean : clean ,
220218 sourceOverrides : sourceOverrides ,
221219 onlyUpdateCompilationDatabase : onlyUpdateCompilationDatabase ,
222220 compilationDatabase : compilation .NewDatabase (buildPath .Join ("compile_commands.json" )),
223- Progress : progress .New (progresCB ),
221+ Progress : progress .New (progressCB ),
224222 executableSectionsSize : []ExecutableSectionSize {},
225223 buildArtifacts : & buildArtifacts {},
226224 targetPlatform : targetPlatform ,
227- actualPlatform : actualPlatform ,
225+ buildPlatform : buildPlatform ,
228226 toolEnv : toolEnv ,
229227 buildOptions : newBuildOptions (
230- hardwareDirs , otherLibrariesDirs ,
231- builtInLibrariesDirs , buildPath ,
228+ hardwareDirs ,
229+ librariesDirs ,
230+ builtInLibrariesDirs ,
231+ buildPath ,
232232 sk ,
233- customBuildPropertiesArgs ,
233+ customBuildProperties ,
234234 fqbn ,
235235 clean ,
236236 buildProperties .Get ("compiler.optimization_flags" ),
@@ -322,10 +322,19 @@ func (b *Builder) preprocess() error {
322322 b .librariesBuildPath ,
323323 b .buildProperties ,
324324 b .targetPlatform .Platform .Architecture ,
325+ b .jobs ,
325326 )
326327 if err != nil {
327328 return err
328329 }
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+ }
329338 b .Progress .CompleteStep ()
330339
331340 b .warnAboutArchIncompatibleLibraries (b .libsDetector .ImportedLibraries ())
@@ -492,29 +501,26 @@ func (b *Builder) prepareCommandForRecipe(buildProperties *properties.Map, recip
492501 commandLine = properties .DeleteUnexpandedPropsFromString (commandLine )
493502 }
494503
495- parts , err := properties .SplitQuotedString (commandLine , `"'` , false )
496- if err != nil {
497- return nil , err
498- }
504+ args , _ := properties .SplitQuotedString (commandLine , `"'` , false )
499505
500506 // if the overall commandline is too long for the platform
501507 // try reducing the length by making the filenames relative
502508 // and changing working directory to build.path
503509 var relativePath string
504510 if len (commandLine ) > 30000 {
505511 relativePath = buildProperties .Get ("build.path" )
506- for i , arg := range parts {
512+ for i , arg := range args {
507513 if _ , err := os .Stat (arg ); os .IsNotExist (err ) {
508514 continue
509515 }
510516 rel , err := filepath .Rel (relativePath , arg )
511517 if err == nil && ! strings .Contains (rel , ".." ) && len (rel ) < len (arg ) {
512- parts [i ] = rel
518+ args [i ] = rel
513519 }
514520 }
515521 }
516522
517- command , err := paths .NewProcess (b .toolEnv , parts ... )
523+ command , err := paths .NewProcess (b .toolEnv , args ... )
518524 if err != nil {
519525 return nil , err
520526 }
0 commit comments